publish data structure to file

This commit is contained in:
Cort Buffington 2014-10-05 22:11:56 -05:00
parent 6e8292d5f1
commit e02c03a099
3 changed files with 24 additions and 0 deletions

1
.gitignore vendored
View File

@ -3,6 +3,7 @@
*.out
Icon
dmrlink.cfg
stats.py
pub*
bridge_rules.py
playback_config.py

View File

@ -23,6 +23,8 @@ import logging
import time
import signal
import cPickle as pickle
from logging.config import dictConfig
from hmac import new as hmac_new
from binascii import b2a_hex as h
@ -595,6 +597,11 @@ def print_master(_network):
print('\t\tStatus: {}, KeepAlives Sent: {}, KeepAlives Outstanding: {}, KeepAlives Missed: {}' .format(_master['STATUS']['CONNECTED'], _master['STATUS']['KEEP_ALIVES_SENT'], _master['STATUS']['KEEP_ALIVES_OUTSTANDING'], _master['STATUS']['KEEP_ALIVES_MISSED']))
print('\t\t KeepAlives Received: {}, Last KeepAlive Received at: {}' .format(_master['STATUS']['KEEP_ALIVES_RECEIVED'], _master['STATUS']['KEEP_ALIVE_RX_TIME']))
def write_ipsc_stats():
file = open('stats.py', 'w')
pickle.dump(NETWORK, file)
file.close()
# Shut ourselves down gracefully with the IPSC peers.
#
def handler(_signal, _frame):
@ -1279,4 +1286,6 @@ if __name__ == '__main__':
if NETWORK[ipsc_network]['LOCAL']['ENABLED']:
networks[ipsc_network] = IPSC(ipsc_network)
reactor.listenUDP(NETWORK[ipsc_network]['LOCAL']['PORT'], networks[ipsc_network])
write_stats = task.LoopingCall(write_ipsc_stats)
write_stats.start(10)
reactor.run()

14
report.py Normal file
View File

@ -0,0 +1,14 @@
from pprint import pprint
from twisted.internet import reactor
from twisted.internet import task
import cPickle as pickle
def print_stats():
stats_file = open('stats.py', 'r')
NETWORK = pickle.load(stats_file)
stats_file.close()
pprint(NETWORK['C-BRIDGE'])
output_stats = task.LoopingCall(print_stats)
output_stats.start(10)
reactor.run()