same = ptr.check_dates(ecats, orig_ecats) has_recon, reconnotes_rsync = ptr.get_reconnotes_fromsync(recondir, real_tracer) recon_fname = ptr.gen_recon_fname(ecats, arda_dir, real_tracer) orig_exists, orig_notes = ptr.glob_file('%s/*notes*.txt'%(arda_dir)) copy = ptr.check_recon_notes(recon_fname, orig_notes) print 'same',same, 'copy reconnotes', copy, arda_dir logging.info(arda_dir) logging.info('Same Files (%s): %s'%(same, arda_dir)) logging.info('%s Copy ReconNotes: %s (exists: %s)'%(subid, copy, has_recon)) if not same: #copy ecats to new dir logging.info('NEW COPY: %s, %s'%(subid, os.path.split(arda_dir)[-1])) ptr.update_outdir(arda_dir, clobber=True) ptr.copy_files_withdate(ecats, arda_dir) if copy and has_recon: ptr.copy_file_withdate(reconnotes_rsync, os.path.join(arda_dir, recon_fname)) # clean out known problem subid ardascans = [ x for x in ardascans if not 'B07-275' in x] if len(ardascans) > 0: logfile = os.path.join(logdir,'logs', 'ARDAERROR-%s_%s%s.log'%(tracer, __file__, cleantime)) fid = open(logfile, 'w+') for item in ardascans:
copy = True else: biographs.remove(outdir) arda_tgz, arda_ntgz=bio.tgz_in_recon(outdir, subid) same_file = ptr.check_dates(tgzs, arda_tgz) if same_file: logging.info('%s exists, files are the same'%(outdir)) copy = False else: copy = True logging.info('%s exists, files NOT same'%(outdir)) if copy: os.system('rm %s/*'%(outdir)) ptr.copy_files_withdate(tgzs, outdir) logging.info('COPIED TGZ: '%(tgzs)) # check for recon notes in sync recon_notes = bio.check_reconnotes(recon) if recon_notes is None: # nothing to copy continue # check for recon notes in arda _ , rn_fname = os.path.split(recon_notes) globstr = os.path.join(outdir, rn_fname) arda_reconnotes = utils.find_single_file(globstr) # copy recon notes if new or missing if arda_reconnotes is None: ptr.copy_file_withdate(recon_notes, outdir) logging.info('No recon_notes in arda, copy %s'%(recon_notes))