Ejemplo n.º 1
0
class GoesWputUploader(object):
  """
  Uploads all the files specified in the ftpProps.
  It must have the following properties:
    user
    password
    host - hydroclimate.ece.uprm.edu
    port
    rootdir - GOES-PRWEB_RESULTS/
  """
  def __init__(self, ftpProps):
    f = ftpProps
    self.ftpmeta = FtpMeta(f.get_host(), f.get_user(), f.get_password(), f.get_port())
    self.ftp = WputFtpUpload(self.ftpmeta)
    self.rootdir = f.get_rootdir()

  def upload(self, pattern, directory, variable):
    """
    Uploads the files found with specified pattern.

    pattern - If in need to upload more than one file, using wildcards. Else just use the filename to upload the file
    directory - directory to look for the files.
    variable - which variable to upload the found files

    """
    uploads = util.findFiles(pattern, directory)
    uploads = map(os.path.basename, uploads)
    remotedir = urlparse.urljoin(self.rootdir, variable)
    #If '/' is missing, it needs to append one to comply with wput
    if remotedir[-1] != '/':
      remotedir += '/'
    logger.debug("Remotedir:" + remotedir)
    self.ftp.wput(directory, remotedir, uploads)
Ejemplo n.º 2
0
 def __init__(self, ftpProps):
   f = ftpProps
   self.ftpmeta = FtpMeta(f.get_host(), f.get_user(), f.get_password(), f.get_port())
   self.ftp = WputFtpUpload(self.ftpmeta)
   self.rootdir = f.get_rootdir()