From 1435f19a1cf31a9a968cfa80c8e3d7dcb0564b2e Mon Sep 17 00:00:00 2001 From: Waldek Date: Mon, 4 Jan 2021 19:42:57 +0100 Subject: [PATCH] Moved checking lastheard.log at program startup --- monitor.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/monitor.py b/monitor.py index e488f60..de5d33c 100644 --- a/monitor.py +++ b/monitor.py @@ -632,11 +632,7 @@ def process_message(_bmessage): log_lh_message = '{},{},{},{},{},{},{},TS{},TG{},{},{},{}'.format(_now, p[9], p[0], p[1], p[3], p[5], alias_call(int(p[5]), subscriber_ids), p[7], p[8],alias_tgid(int(p[8]),talkgroup_ids),p[6], alias_short(int(p[6]), subscriber_ids)) lh_logfile = open(LOG_PATH+"lastheard.log", "a") lh_logfile.write(log_lh_message + '\n') - lh_logfile.close() - try: - check_call("sed -i -e 's|\\x0||g' {}".format(LOG_PATH+"lastheard.log"), shell=True) - except CalledProcessError as err: - print(err) + lh_logfile.close() # Lastheard in Dashboard by SP2ONG my_list=[] n=0 @@ -833,7 +829,13 @@ if __name__ == '__main__': logging.info('monitor.py starting up') logger.info('\n\n\tCopyright (c) 2016, 2017, 2018, 2019\n\tThe Regents of the K0USY Group. All rights reserved.\n\n\tPython 3 port:\n\t2019 Steve Miller, KC1AWV \n\n\tVersion by:\t SP2ONG 2019-2021\n\n') - + # Check lastheard.log file + if os.path.isfile(LOG_PATH+"lastheard.log"): + try: + check_call("sed -i -e 's|\\x0||g' {}".format(LOG_PATH+"lastheard.log"), shell=True) + logging.info('Check lastheard.log file') + except CalledProcessError as err: + print(err) # Download alias files result = try_download(PATH, PEER_FILE, PEER_URL, (FILE_RELOAD * 86400)) logging.info(result)