parameters: (self, filepath)
docstring: Dump a file to the host.
docstring_summary: Dump a file to the host.
docstring_tokens: Dump a file to the host .
function: def dump_file(self, filepath):
          """Dump a file to the host."""
          if not os.path.isfile(filepath):
              log.warning("File at path %r does not exist, skip.", filepath)
              return False
  
          # Check whether we've already dumped this file - in that case skip it.
          try:
              sha256 = hash_file(hashlib.sha256, filepath)
              if sha256 in self.dumped:
                  return
          except IOError as e:
              log.info("Error dumping file from path \"%s\": %s", filepath, e)
              return
  
          filename = "%s_%s" % (sha256[:16], os.path.basename(filepath))
          upload_path = os.path.join("files", filename)
  
          try:
              upload_to_host(
                  # If available use the original filepath, the one that is
                  # not lowercased.
                  self.files_orig.get(filepath.lower(), filepath),
                  upload_path, self.files.get(filepath.lower(), [])
              )
              self.dumped.append(sha256)
          except (IOError, socket.error) as e:
              log.error(
                  "Unable to upload dropped file at path \"%s\": %s",
                  filepath, e
              )
function_tokens: def dump_file ( self , filepath ) : if not os . path . isfile ( filepath ) : log . warning ( "File at path %r does not exist, skip." , filepath ) return False # Check whether we've already dumped this file - in that case skip it. try : sha256 = hash_file ( hashlib . sha256 , filepath ) if sha256 in self . dumped : return except IOError as e : log . info ( "Error dumping file from path \"%s\": %s" , filepath , e ) return filename = "%s_%s" % ( sha256 [ : 16 ] , os . path . basename ( filepath ) ) upload_path = os . path . join ( "files" , filename ) try : upload_to_host ( # If available use the original filepath, the one that is # not lowercased. self . files_orig . get ( filepath . lower ( ) , filepath ) , upload_path , self . files . get ( filepath . lower ( ) , [ ] ) ) self . dumped . append ( sha256 ) except ( IOError , socket . error ) as e : log . error ( "Unable to upload dropped file at path \"%s\": %s" , filepath , e )