CroatianMeteorNetwork / RMS

RPi Meteor Station
https://globalmeteornetwork.org/
GNU General Public License v3.0
169 stars 47 forks source link

Exception when trying to delete log files that no longer exist #177

Closed rabssm closed 1 year ago

rabssm commented 1 year ago

An exception is thrown in the deleteOldLogfiles function if a log file no longer exists. This can be caused for example on a multi-camera system where another RMS camera process has already removed the log file. This causes a failure to start capturing that persists for the rest of the night.

https://github.com/CroatianMeteorNetwork/RMS/blob/ee4dc687762b6fc11048e466d08b8b83e5396325/RMS/DeleteOldObservations.py#L353

One solution would be to catch exceptions on the lines 353 to 356.

The terminal output showing this issue below:

2023/06/07 20:51:55-INFO-StartCapture-line:694 - Program start 2023/06/07 20:51:55-INFO-StartCapture-line:695 - Station code: UK000S 2023/06/07 20:51:55-INFO-StartCapture-line:774 - Starting the upload manager... 2023/06/07 20:51:55-INFO-StartCapture-line:787 - Next start time: 2023-06-07 21:01:21.010467 UTC 2023/06/07 20:51:55-DEBUG-StartCapture-line:561 - Checking for folders containing partially-processed data 2023/06/07 20:51:57-DEBUG-StartCapture-line:586 - Checking folder: UK000S_20230529_205046_516391 2023/06/07 20:51:57-DEBUG-StartCapture-line:613 - ... fully processed! 2023/06/07 20:51:57-DEBUG-StartCapture-line:586 - Checking folder: UK000S_20230530_205207_369649 2023/06/07 20:51:57-DEBUG-StartCapture-line:613 - ... fully processed! 2023/06/07 20:51:57-DEBUG-StartCapture-line:586 - Checking folder: UK000S_20230531_205325_083612 2023/06/07 20:51:57-DEBUG-StartCapture-line:613 - ... fully processed! 2023/06/07 20:51:57-DEBUG-StartCapture-line:586 - Checking folder: UK000S_20230601_205439_797743 2023/06/07 20:51:57-DEBUG-StartCapture-line:613 - ... fully processed! 2023/06/07 20:51:57-DEBUG-StartCapture-line:586 - Checking folder: UK000S_20230602_205553_443601 2023/06/07 20:51:57-DEBUG-StartCapture-line:613 - ... fully processed! 2023/06/07 20:51:57-DEBUG-StartCapture-line:586 - Checking folder: UK000S_20230603_205703_575601 2023/06/07 20:51:57-DEBUG-StartCapture-line:613 - ... fully processed! 2023/06/07 20:51:57-DEBUG-StartCapture-line:586 - Checking folder: UK000S_20230604_205811_495791 2023/06/07 20:51:57-DEBUG-StartCapture-line:613 - ... fully processed! 2023/06/07 20:51:57-DEBUG-StartCapture-line:586 - Checking folder: UK000S_20230605_205917_244373 2023/06/07 20:51:57-DEBUG-StartCapture-line:613 - ... fully processed! 2023/06/07 20:51:57-DEBUG-StartCapture-line:586 - Checking folder: UK000S_20230606_210020_360920 2023/06/07 20:51:57-DEBUG-StartCapture-line:613 - ... fully processed! 2023/06/07 20:51:57-INFO-StartCapture-line:941 - Waiting 0:09:23.467467 to start recording for 6.153 hrs 2023/06/07 21:01:20-INFO-StartCapture-line:1013 - Freeing up disk space... Traceback (most recent call last): File "/usr/lib/python3.8/runpy.py", line 194, in _run_module_as_main return _run_code(code, main_globals, None, File "/usr/lib/python3.8/runpy.py", line 87, in _run_code exec(code, run_globals) File "/home/pi/vRMS/lib/python3.8/site-packages/RMS-0.1-py3.8-linux-x86_64.egg/RMS/StartCapture.py", line 1016, in if not deleteOldObservations(config.data_dir, config.captured_dir, config.archived_dir, config, File "/home/pi/vRMS/lib/python3.8/site-packages/RMS-0.1-py3.8-linux-x86_64.egg/RMS/DeleteOldObservations.py", line 203, in deleteOldObservations deleteOldLogfiles(data_dir, config) File "/home/pi/vRMS/lib/python3.8/site-packages/RMS-0.1-py3.8-linux-x86_64.egg/RMS/DeleteOldObservations.py", line 353, in deleteOldLogfiles file_mtime = os.stat(os.path.join(log_dir, fl)).st_mtime FileNotFoundError: [Errno 2] No such file or directory: '/home/pi/RMS_data/logs/log_UK0001_20230508_133815.741131.log' 2023/06/08 03:21:56-INFO-UploadManager-line:107 - Establishing SSH connection to: gmn.uwo.ca:22... 2023/06/08 03:21:57-INFO-UploadManager-line:64 - Trying ssh-agent key b'cc024e11ae185fc9dd0baf580fb1d174' 2023/06/08 03:21:57-INFO-UploadManager-line:69 - ... success! 2023/06/08 03:22:00-INFO-UploadManager-line:156 - Copying /home/pi/RMS_data/ArchivedFiles/UK000H_20230607_210120_831837_detected.tar.bz2 to files/UK000H_20230607_210120_831837_detected.tar.bz2 2023/06/08 03:26:49-INFO-UploadManager-line:170 - File upload verified: files/UK000H_20230607_210120_831837_detected.tar.bz2 2023/06/08 03:26:49-INFO-UploadManager-line:370 - Upload successful!

dvida commented 1 year ago

check added to the dev branch for testing