publish data structure to file
This commit is contained in:
parent
6e8292d5f1
commit
e02c03a099
|
@ -3,6 +3,7 @@
|
||||||
*.out
|
*.out
|
||||||
Icon
|
Icon
|
||||||
dmrlink.cfg
|
dmrlink.cfg
|
||||||
|
stats.py
|
||||||
pub*
|
pub*
|
||||||
bridge_rules.py
|
bridge_rules.py
|
||||||
playback_config.py
|
playback_config.py
|
||||||
|
|
|
@ -23,6 +23,8 @@ import logging
|
||||||
import time
|
import time
|
||||||
import signal
|
import signal
|
||||||
|
|
||||||
|
import cPickle as pickle
|
||||||
|
|
||||||
from logging.config import dictConfig
|
from logging.config import dictConfig
|
||||||
from hmac import new as hmac_new
|
from hmac import new as hmac_new
|
||||||
from binascii import b2a_hex as h
|
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\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']))
|
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.
|
# Shut ourselves down gracefully with the IPSC peers.
|
||||||
#
|
#
|
||||||
def handler(_signal, _frame):
|
def handler(_signal, _frame):
|
||||||
|
@ -1279,4 +1286,6 @@ if __name__ == '__main__':
|
||||||
if NETWORK[ipsc_network]['LOCAL']['ENABLED']:
|
if NETWORK[ipsc_network]['LOCAL']['ENABLED']:
|
||||||
networks[ipsc_network] = IPSC(ipsc_network)
|
networks[ipsc_network] = IPSC(ipsc_network)
|
||||||
reactor.listenUDP(NETWORK[ipsc_network]['LOCAL']['PORT'], networks[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()
|
reactor.run()
|
|
@ -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()
|
Loading…
Reference in New Issue