Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions RMS/StartCapture.py
Original file line number Diff line number Diff line change
Expand Up @@ -909,7 +909,17 @@ def runCapture(config, duration=None, video_file=None, nodetect=False, detect_en
# Standard mode: need to run it all just once
# Continuous mode: if the program just got done with nighttime processing and needs to reboot
elif (not config.continuous_capture) or (not daytime_mode_prev and config.reboot_after_processing):
break

# Continuous mode: stop the capture before returning for the reboot. If the reboot
# fails, the main loop calls runCapture again - the old capture must not be left
# running, or two captures will run in parallel and save every frame twice, with the
# old one stamping a stale day/night suffix (it holds the previous daytime_mode)
if config.continuous_capture:
log.info('Ending capture before reboot...')
dropped_frames = bc.stopCapture()
log.info('Total number of late or dropped frames: ' + str(dropped_frames))

break

ran_once = True

Expand Down Expand Up @@ -1264,7 +1274,13 @@ def processIncompleteCaptures(config, upload_manager):

# Reboot the computer (script needs sudo privileges, works only on Linux)
try:
os.system('sudo shutdown -r now')
exit_status = os.system('sudo shutdown -r now')

# os.system returns a wait status, not the exit code directly
if exit_status != 0:
log.error('Reboot command failed with exit code {}, '
'giving up on rebooting'.format(exit_status >> 8))
break

except Exception as e:
log.debug('Rebooting failed with message:\n' + repr(e))
Expand Down Expand Up @@ -1292,7 +1308,7 @@ def processIncompleteCaptures(config, upload_manager):

# If reboot didn't happen in continuous capture mode, reset so capture resumes normally
if config.continuous_capture:
log.warning("Reboot failed after 4 hours of attempts, resuming capture")
log.warning("Reboot did not happen, resuming capture")
ran_once = False


Expand Down