コード例 #1
0
class GoesUploader(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 = FtpUpload(self.ftpmeta)
    self.rootdir = f.get_rootdir()

  #TODO: verify ftp server, verify the findfiles part to see if changes need to be made to FtpUpload in remote
#  def upload(self,pattern, directory, variable):
#    """ 
#    pattern: if you want to upload more than one file use wildcards
#                else just give the file name
#    
#    directory: location of the file to be uploaded
#    
#    variable: variable to upload to. Ex: 'WIND', 'SOLAR' and 'PRECIPITATION'
#    """
#    
#    uploads = self.findFiles(pattern, directory)
#    logging.debug("Uploads: "+str(uploads))
#    
#    if self.ftp.isClosed():
#      self.ftp = FtpUpload(self.ftpmeta)
#    
#    remotedir = urlparse.urljoin(self.rootdir, variable)
#    self.ftp.wput(remotedir, uploads)

  def close(self):
    """
    Closes the connection
    """
    if not self.ftp.isClosed():
      self.ftp.close()
コード例 #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 = FtpUpload(self.ftpmeta)
   self.rootdir = f.get_rootdir()