parameters: (run, logger)
docstring: Fetch a camera folder from the archive if it exists.  Returns
      True if we got the file. If more than one, return the latest by
      modification time.
docstring_summary: Fetch a camera folder from the archive if it exists.  Returns
      True if we got the file. If more than one, return the latest by
      modification time.
docstring_tokens: Fetch a camera folder from the archive if it exists . Returns True if we got the file . If more than one return the latest by modification time .
function: def fetchCameraFolder(run, logger):
      '''Fetch a camera folder from the archive if it exists.  Returns
      True if we got the file. If more than one, return the latest by
      modification time.'''
      
      logger.info('Fetching camera folder for ' + str(run))
      
      # Tar up the camera files and send them at the same time using the shiftc command
      cameraFolder = run.getCameraFolder()
      fileName     = run.getCameraTarName()
  
      # There could be multiple camera folders, fetch the latest by modification time.
      strippedName = fileName
      m = re.match('^(.*?)\.tar', strippedName)
      if m:
          strippedName = m.group(1)
      m = re.match('^(.*?)' + run.suffix, strippedName)
      if m:
          strippedName = m.group(1)
  
      # Look for the tarred camera files in each remote folder
      # - TODO: This may not get the latest if cameras are in each folder!
      found_rcf = ''
      for rcf in [REMOTE_CAMERA_FOLDER_OLEG, REMOTE_CAMERA_FOLDER_SCOTT]:
  
          cmd = 'ssh lfe "ls -dt ' + stripHost(rcf) + '/' + strippedName + '*.tar"'
          logger.info(cmd)
          (out, err, status) = asp_system_utils.executeCommand(cmd, outputPath = None, 
                                                               suppressOutput = True, redo = True,
                                                               noThrow = True)
          out  = out.strip()
          vals = out.split()
          if len(vals) >= 1:
              # Pick the first one, which is the newest
              out = vals[0]
          if out != '':
              found_rcf = rcf
              break
      if found_rcf == '':
          logger.info('Did not find camera file for run.')
          return False
  
      fileName = os.path.basename(out)
      lfePath  = os.path.join(found_rcf, fileName)
      cmd = 'shiftc --wait -d -r --extract-tar ' + lfePath + ' .'  
  
      # Don't try too hard below, if failed first time that means there are no cameras
      # to fetch
      logger.info(cmd)
      status = os.system(cmd)
      if status != 0:
          logger.info('Did not find camera file for run.')
          return False
      else:
          logger.info('Finished retrieving cameras from lfe.')
          return True
function_tokens: def fetchCameraFolder ( run , logger ) : logger . info ( 'Fetching camera folder for ' + str ( run ) ) # Tar up the camera files and send them at the same time using the shiftc command cameraFolder = run . getCameraFolder ( ) fileName = run . getCameraTarName ( ) # There could be multiple camera folders, fetch the latest by modification time. strippedName = fileName m = re . match ( '^(.*?)\.tar' , strippedName ) if m : strippedName = m . group ( 1 ) m = re . match ( '^(.*?)' + run . suffix , strippedName ) if m : strippedName = m . group ( 1 ) # Look for the tarred camera files in each remote folder # - TODO: This may not get the latest if cameras are in each folder! found_rcf = '' for rcf in [ REMOTE_CAMERA_FOLDER_OLEG , REMOTE_CAMERA_FOLDER_SCOTT ] : cmd = 'ssh lfe "ls -dt ' + stripHost ( rcf ) + '/' + strippedName + '*.tar"' logger . info ( cmd ) ( out , err , status ) = asp_system_utils . executeCommand ( cmd , outputPath = None , suppressOutput = True , redo = True , noThrow = True ) out = out . strip ( ) vals = out . split ( ) if len ( vals ) >= 1 : # Pick the first one, which is the newest out = vals [ 0 ] if out != '' : found_rcf = rcf break if found_rcf == '' : logger . info ( 'Did not find camera file for run.' ) return False fileName = os . path . basename ( out ) lfePath = os . path . join ( found_rcf , fileName ) cmd = 'shiftc --wait -d -r --extract-tar ' + lfePath + ' .' # Don't try too hard below, if failed first time that means there are no cameras # to fetch logger . info ( cmd ) status = os . system ( cmd ) if status != 0 : logger . info ( 'Did not find camera file for run.' ) return False else : logger . info ( 'Finished retrieving cameras from lfe.' ) return True