diff --git a/pickle_stat_reader.py b/pickle_stat_reader.py new file mode 100644 index 0000000..1b46a9b --- /dev/null +++ b/pickle_stat_reader.py @@ -0,0 +1,34 @@ +from __future__ import print_function +from cPickle import load +from pprint import pprint +from os.path import getmtime +from time import sleep + + +# This is the only user-configuration necessary +# Tell the program where the pickle file is +stat_file = 'dmrlink_stats.pickle' + + +last = getmtime(stat_file) + + +def read_dict(): + try: + with open(stat_file, 'rb') as file: + NETWORK = load(file) + return NETWORK + except IOError as detail: + print('I/O Error: {}'.format(detail)) + except EOFError: + print('EOFError') + + +pprint(read_dict()) + +while 1: + sleep(1) + now = getmtime(stat_file) + if now > last: + last = now + pprint(read_dict()) \ No newline at end of file