|
@@ -22,31 +22,40 @@ logger.addHandler(fh)
|
|
logger.info('Starting up')
|
|
logger.info('Starting up')
|
|
|
|
|
|
a = AlfredParser()
|
|
a = AlfredParser()
|
|
|
|
+b = BatmanParser()
|
|
d = DashingClient('dashing.krombel.de', 'TODO')
|
|
d = DashingClient('dashing.krombel.de', 'TODO')
|
|
g = GraphitePush('fdca:ffee:ff12:a254::da7a', 2003)
|
|
g = GraphitePush('fdca:ffee:ff12:a254::da7a', 2003)
|
|
data = { }
|
|
data = { }
|
|
|
|
|
|
if DUMMY_MODE:
|
|
if DUMMY_MODE:
|
|
- a.alfred_json = '/home/ffpb-statusbot/status-daemon/alfred-json'
|
|
|
|
|
|
+ import os
|
|
|
|
+ mydir = os.path.realpath(os.path.dirname(__file__))
|
|
|
|
+ a.alfred_json = os.path.join(mydir, 'alfred-json')
|
|
|
|
+ print('DUMMY.a =', a.alfred_json)
|
|
|
|
+ b.batadv_vis = os.path.join(mydir, 'batadv_vis')
|
|
|
|
+ print('DUMMY.b =', b.batadv_vis)
|
|
g.dont_send = True
|
|
g.dont_send = True
|
|
|
|
|
|
-try:
|
|
|
|
- a.sanitycheck()
|
|
|
|
-except Exception as err:
|
|
|
|
- logger.critical('AlfredParser.sanitycheck() failed: ' + str(err))
|
|
|
|
- print('FAILED SANITY CHECK: ' + str(err))
|
|
|
|
- sys.exit(1)
|
|
|
|
|
|
+for i in [ ('AlfredParser', a), ('BatmanParser', b) ]:
|
|
|
|
+ try:
|
|
|
|
+ i[1].sanitycheck()
|
|
|
|
+ except Exception as err:
|
|
|
|
+ logger.critical(i[0] + '.sanitycheck() failed: ' + str(err))
|
|
|
|
+ print('FAILED SANITY CHECK: ' + str(err))
|
|
|
|
+ sys.exit(1)
|
|
|
|
|
|
daemon_context = daemon.DaemonContext(
|
|
daemon_context = daemon.DaemonContext(
|
|
files_preserve = [ fh.stream ],
|
|
files_preserve = [ fh.stream ],
|
|
)
|
|
)
|
|
with daemon_context:
|
|
with daemon_context:
|
|
-
|
|
|
|
while True:
|
|
while True:
|
|
try:
|
|
try:
|
|
ts = int(time.time())
|
|
ts = int(time.time())
|
|
logger.debug('Step 1/3: Fetching data ...')
|
|
logger.debug('Step 1/3: Fetching data ...')
|
|
- newdata = a.fetch()
|
|
|
|
|
|
+ alfreddata = a.fetch()
|
|
|
|
+ batmandata = b.fetch()
|
|
|
|
+ newdata = dict_merge(alfreddata, batmandata)
|
|
|
|
+ logger.info('Fetched data: {0} ALFRED with {1} BATMAN makes {2} total'.format(len(alfreddata), len(batmandata), len(newdata)))
|
|
|
|
|
|
logger.debug('Step 2/3: Pushing update data ...')
|
|
logger.debug('Step 2/3: Pushing update data ...')
|
|
graphitedata = g.push(newdata, ts=ts)
|
|
graphitedata = g.push(newdata, ts=ts)
|