Skip to content

Commit

Permalink
it's more efficient to delete the bad symlinks after making all of th…
Browse files Browse the repository at this point in the history
…em first
  • Loading branch information
jchiang87 committed Oct 25, 2019
1 parent 0dfe9e5 commit 5023772
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions harnessed_jobs/BOT_acq_recovery/v0/producer_BOT_acq_recovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,19 @@
for job_id_dir in job_id_dirs:
frame_dirs = glob.glob(os.path.join(job_id_dir, '*'))
for frame_dir in frame_dirs:
if bad_frames:
fits_images = []
for bad_frame in bad_frames:
pattern = os.path.join(frame_dir, f'*{bad_frame}*.fits')
fits_images.extend(glob.glob(pattern))
dest = os.path.join(outdir, os.path.basename(frame_dir))
if ((os.path.islink(frame_dir) or frame_dir.endswith('.cfg'))
and not os.path.lexists(dest)
and not fits_images):
and not os.path.lexists(dest)):
shutil.copyfile(frame_dir, dest, follow_symlinks=False)

# Delete any folders with bad data
for bad_frame in bad_frames:
fits_images = []
for bad_frame in bad_frames:
pattern = os.path.join('*', f'*{bad_frame}*.fits')
fits_images.extend(glob.glob(pattern))
bad_symlinks = set([os.path.dirname(_) for _ in fits_images])
for bad_symlink in bad_symlinks:
os.remove(bad_symlink)

pathlib.Path('PRESERVE_SYMLINKS').touch()

0 comments on commit 5023772

Please sign in to comment.