From 7a57927cba2e420419e49cd1576c0d99876f145c Mon Sep 17 00:00:00 2001 From: Mark McIntyre Date: Mon, 3 Nov 2025 11:23:39 +0000 Subject: [PATCH 1/3] improve error messages for missing keys --- uploadToArchive.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/uploadToArchive.py b/uploadToArchive.py index b26209b..d69f5ab 100644 --- a/uploadToArchive.py +++ b/uploadToArchive.py @@ -30,7 +30,7 @@ def readKeyFile(filename, inifvals): if not os.path.isfile(filename): - log.error('Config file missing, cannot continue') + log.error('Keyfile {} not downloaded. Check ssh key and station location with ukmon team.'.format(filename)) return False with open(filename, 'r') as fin: lis = fin.readlines() @@ -114,7 +114,7 @@ def getAWSKey(inifvals): def readIniFile(filename): if not os.path.isfile(filename): - log.error('ukmon.ini missing, cannot continue') + log.error('{} missing, cannot continue'.format(filename)) return False with open(filename, 'r') as fin: lis = fin.readlines() From 126320c8c8cd2c011aef16c2124f45ebbe5d8ceb Mon Sep 17 00:00:00 2001 From: Mark McIntyre Date: Fri, 7 Nov 2025 21:24:05 +0000 Subject: [PATCH 2/3] rename the logger to be unique --- liveMonitor.py | 2 +- sendToLive.py | 2 +- ukmonInstaller.py | 2 +- ukmonPostProc.py | 5 ++++- uploadToArchive.py | 2 +- 5 files changed, 8 insertions(+), 5 deletions(-) diff --git a/liveMonitor.py b/liveMonitor.py index 08a66bb..a59e9d7 100644 --- a/liveMonitor.py +++ b/liveMonitor.py @@ -12,7 +12,7 @@ from ukmonPostProc import setupLogging -log = logging.getLogger() +log = logging.getLogger("ukmonlogger") timetowait = 30 # seconds to wait for a new line before deciding the log is stale diff --git a/sendToLive.py b/sendToLive.py index 4eb720e..72c0d8b 100644 --- a/sendToLive.py +++ b/sendToLive.py @@ -18,7 +18,7 @@ from RMS.Formats.FieldIntensities import readFieldIntensitiesBin -log = logging.getLogger("logger") +log = logging.getLogger("ukmonlogger") def getBlockBrightness(dirpath, filename): diff --git a/ukmonInstaller.py b/ukmonInstaller.py index 19fe450..5fac352 100644 --- a/ukmonInstaller.py +++ b/ukmonInstaller.py @@ -20,7 +20,7 @@ from RMS.Misc import isRaspberryPi from uploadToArchive import readIniFile -log = logging.getLogger() +log = logging.getLogger("ukmonlogger") log.setLevel(logging.WARNING) oldip = '3.9.65.98' diff --git a/ukmonPostProc.py b/ukmonPostProc.py index 6d67455..094d96f 100644 --- a/ukmonPostProc.py +++ b/ukmonPostProc.py @@ -23,7 +23,7 @@ from uploadToArchive import uploadToArchive, readIniFile -log = logging.getLogger() +log = logging.getLogger("ukmonlogger") log.setLevel(logging.INFO) @@ -31,6 +31,9 @@ def setupLogging(logpath, prefix): print('about to initialise logger') logdir = os.path.expanduser(logpath) os.makedirs(logdir, exist_ok=True) + log.info('removing any existing log handlers') + for handler in log.handlers[:]: + log.removeHandler(handler) logfilename = os.path.join(logdir, prefix + datetime.datetime.now(datetime.timezone.utc).strftime('%Y%m%d_%H%M%S.%f') + '.log') handler = logging.handlers.TimedRotatingFileHandler(logfilename, when='D', interval=1) diff --git a/uploadToArchive.py b/uploadToArchive.py index d69f5ab..2484827 100644 --- a/uploadToArchive.py +++ b/uploadToArchive.py @@ -25,7 +25,7 @@ import tempfile from RMS.Formats.FTPdetectinfo import readFTPdetectinfo -log = logging.getLogger("logger") +log = logging.getLogger("ukmonlogger") def readKeyFile(filename, inifvals): From 2a234c008a9bd1537d04269e001439335ca4222a Mon Sep 17 00:00:00 2001 From: Mark McIntyre Date: Sat, 8 Nov 2025 13:09:44 +0000 Subject: [PATCH 3/3] a bit more log messaging --- uploadToArchive.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/uploadToArchive.py b/uploadToArchive.py index 2484827..8da3bda 100644 --- a/uploadToArchive.py +++ b/uploadToArchive.py @@ -90,7 +90,7 @@ def getAWSKey(inifvals): handle, tmpfnam = tempfile.mkstemp() ftp_client.get(inifvals['LOCATION']+'.csv', tmpfnam) except Exception as e: - log.error('unable to find AWS key') + log.error('unable to find AWS key, check location in ukmon.ini') log.info(e, exc_info=True) ftp_client.close() try: @@ -99,7 +99,7 @@ def getAWSKey(inifvals): os.remove(tmpfnam) key, sec = lis[1].split(',') except Exception as e: - log.error('malformed AWS key') + log.error('malformed AWS key, contact support') log.info(e, exc_info=True) except Exception as e: log.error('unable to retrieve AWS key')