4 CAT : package for electronics and data processing 8 from arguments
import *
11 hist_file = os.path.expandvars(
"$CATPATH/.cathistory")
12 max_size_bytes = 10000
20 from os.path
import getsize
24 print "Resetting history file %s because it exceeded %s %s; it has %s." % (hist_file,max_size,reason,size,)
25 f = open(hist_file,
'w')
28 print "Couldn't reset history file %s [%s]." % (hist_file,e,)
32 size = getsize(hist_file)
40 if size > max_size_bytes:
44 readline.read_history_file(hist_file)
45 lines = readline.get_current_history_length()
46 if lines > max_size_lines:
48 readline.clear_history()
50 print "readline.clear_history() not supported (%s), please delete history file %s by hand." % (e,hist_file,)
54 f = open(hist_file,
'a')
57 print "The file %s can't be created, check your hist_file variable." % hist_file
61 print "Current history file (%s) size: %s bytes, %s lines." % (hist_file,size,readline.get_current_history_length(),)
63 readline.parse_and_bind(
"tab: complete")
65 atexit.register(readline.write_history_file,hist_file)
73 print 'starting shell...' 78 print 'starting gui...' 81 if __name__ ==
"__main__":
def reset_file(size, max_size, reason)
def safe_getsize(hist_file)