Initial File Upload
This commit is contained in:
parent
8e85b71e27
commit
d7f11d955c
34
pickle_stat_reader.py
Normal file
34
pickle_stat_reader.py
Normal file
@ -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())
|
Loading…
x
Reference in New Issue
Block a user