Skip to content

Commit

Permalink
Don't change status unless running in autoupload mode
Browse files Browse the repository at this point in the history
  • Loading branch information
rhandberg committed May 20, 2021
1 parent b9dd904 commit 9ee2c97
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions run_photometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,14 @@ def process_fileid(fid, output_folder_root=None, attempt_imagematch=True, autoup
target_name = datafile['target_name']

# Folder to save output:
output_folder = os.path.join(output_folder_root, target_name, '%05d' % fid)
output_folder = os.path.join(output_folder_root, target_name, f'{fid:05d}')

photfile = None
_filehandler = None
try:
# Set the status to indicate that we have started processing:
api.set_photometry_status(fid, 'running')
if autoupload:
api.set_photometry_status(fid, 'running')

# Create the output directory if it doesn't exist:
os.makedirs(output_folder, exist_ok=True)
Expand All @@ -56,12 +57,14 @@ def process_fileid(fid, output_folder_root=None, attempt_imagematch=True, autoup
if os.path.exists(output_folder):
shutil.rmtree(output_folder, ignore_errors=True)
photfile = None
api.set_photometry_status(fid, 'abort')
if autoupload:
api.set_photometry_status(fid, 'abort')

except: # noqa: E722, pragma: no cover
logger.exception("Photometry failed")
photfile = None
api.set_photometry_status(fid, 'error')
if autoupload:
api.set_photometry_status(fid, 'error')

if _filehandler is not None:
logger.removeHandler(_filehandler)
Expand Down

0 comments on commit 9ee2c97

Please sign in to comment.