def deleteFile(self,remoteHost,remotePath): if not remoteHost in self.allHosts: self.log.info("Available hosts:" % (self.allHosts.keys())) raise InputError("Host '%s' is not known" % remoteHost) u1 = uploader.uploaderFacade() u1.uploader = self.allHosts[remoteHost]["writeProto"] u1.remotePrefix = self.allHosts[remoteHost]["uriReplace"] u1.externalPrefix = self.allHosts[remoteHost]["uriMatch"] return u1.delete(remotePath)
def uploadFile(self,localPath,remoteHost,remotePath): if not remoteHost in self.allHosts: self.log.info("Available hosts:" % (self.allHosts.keys())) raise InputError("Host '%s' is not known" % remoteHost) if not os.path.isfile(localPath): raise InputError("file not found at localpath '%s'" % localPath) u1 = uploader.uploaderFacade() u1.uploader = self.allHosts[remoteHost]["writeProto"] u1.remotePrefix = self.allHosts[remoteHost]["uriReplace"] u1.externalPrefix = self.allHosts[remoteHost]["uriMatch"] return u1.upload(localPath,remotePath)
def replaceFile(self,localPath,remoteHost,externalPath): numberHosts = len(self.allHosts) if numberHosts == 0: self.log.warning("No hosts configred, please check the configuration file.") raise InputError("No hosts configured") if not remoteHost in self.allHosts: self.log.warning("Hosts '%s' is not configured." % (remoteHost)) self.log.info("Available hosts:" % (self.allHosts.keys())) raise InputError("Host '%s' is not registered" % remoteHost) if not os.path.isfile(localPath): raise InputError("File not found at path '%s'" % localPath) u1 = uploader.uploaderFacade() u1.uploader = self.allHosts[remoteHost]["writeProto"] u1.remotePrefix = self.allHosts[remoteHost]["uriReplace"] u1.externalPrefix = self.allHosts[remoteHost]["uriMatch"] output = u1.replace(localPath,externalPath) return output
def _validateCfg(self,remoteHost): numberHosts = len(self.allHosts) if numberHosts == 0: self.log.warning("No hosts configred, please check the configuration file.") raise InputError("No hosts configured") if not remoteHost in self.allHosts: self.log.warning("Hosts '%s' is not configured." % (remoteHost)) self.log.info("Available hosts:" % (self.allHosts.keys())) raise InputError("Host '%s' is not registered" % remoteHost) self.facard = uploader.uploaderFacade() try: self.facard.uploader = self.allHosts[remoteHost]["writeProto"] except uploader.InputError as exp: self.log.error("Section '%s' has invalid protocol:%s" % (self.allHosts[remoteHost]["section"], self.allHosts[remoteHost]["writeProto"])) raise InputError(exp.msg) self.facard.remotePrefix = self.allHosts[remoteHost]["uriReplace"] self.facard.externalPrefix = self.allHosts[remoteHost]["uriMatch"] if hasattr(self, 'flags'): self.facard.flags = self.flags
def _validateCfg(self, remoteHost): numberHosts = len(self.allHosts) if numberHosts == 0: self.log.warning( "No hosts configred, please check the configuration file.") raise InputError("No hosts configured") if not remoteHost in self.allHosts: self.log.warning("Hosts '%s' is not configured." % (remoteHost)) self.log.info("Available hosts:" % (self.allHosts.keys())) raise InputError("Host '%s' is not registered" % remoteHost) self.facard = uploader.uploaderFacade() try: self.facard.uploader = self.allHosts[remoteHost]["writeProto"] except uploader.InputError as exp: self.log.error("Section '%s' has invalid protocol:%s" % (self.allHosts[remoteHost]["section"], self.allHosts[remoteHost]["writeProto"])) raise InputError(exp.msg) self.facard.remotePrefix = self.allHosts[remoteHost]["uriReplace"] self.facard.externalPrefix = self.allHosts[remoteHost]["uriMatch"] if hasattr(self, 'flags'): self.facard.flags = self.flags