def __do_send__(self): self.logger.debug("sending/copying %s to %s " % (self.local_path, self.remote_dir)) try: if self.do_send: return self.do_send(self) elif self.details.url.scheme in ['ftp', 'ftps']: if not hasattr(self, 'ftp_link'): self.ftp_link = ftp_transport() return self.ftp_link.send(self) elif self.details.url.scheme == 'sftp': try: from sr_sftp import sftp_transport except: from sarra.sr_sftp import sftp_transport if not hasattr(self, 'sftp_link'): self.sftp_link = sftp_transport() return self.sftp_link.send(self) except: (stype, svalue, tb) = sys.exc_info() self.logger.error("Sender Type: %s, Value: %s, ..." % (stype, svalue)) if self.reportback: self.msg.report_publish(503, "Unable to process") self.logger.error("Could not send") if self.reportback: self.msg.report_publish( 503, "Service unavailable %s" % self.msg.url.scheme)
def __do_send__(self): self.logger.debug("sending/copying %s " % self.local_path) try : if self.do_send : return self.do_send(self) elif self.details.url.scheme in ['ftp','ftps'] : if not hasattr(self,'ftp_link') : self.ftp_link = ftp_transport() return self.ftp_link.send(self) elif self.details.url.scheme == 'sftp' : try : from sr_sftp import sftp_transport except : from sarra.sr_sftp import sftp_transport if not hasattr(self,'sftp_link') : self.sftp_link = sftp_transport() return self.sftp_link.send(self) except : (stype, svalue, tb) = sys.exc_info() self.logger.error("Sender Type: %s, Value: %s, ..." % (stype, svalue)) self.msg.report_publish(503,"Unable to process") self.logger.error("Could not send") self.msg.report_publish(503,"Service unavailable %s" % self.msg.url.scheme)
def __do_send__(self): self.logger.debug("sending/copying %s to %s " % (self.msg.relpath, self.msg.new_dir)) # try registered do_send first... might overload defaults scheme = self.details.url.scheme try: if scheme in self.do_sends: self.logger.debug("using registered do_send for %s" % scheme) do_send = self.do_sends[scheme] ok = do_send(self) # if ok == None it means that the scheme was one # of the supported python one (sftp,ftp[s]) # and the plugin decided to go with the python defaults if ok != None: return ok except: self.logger.debug('Exception details:', exc_info=True) # try supported hardcoded send try: if scheme in ['ftp', 'ftps']: if not hasattr(self, 'ftp_link'): self.ftp_link = ftp_transport() ok = self.ftp_link.send(self) return ok elif scheme == 'sftp': try: from sr_sftp import sftp_transport except: from sarra.sr_sftp import sftp_transport if not hasattr(self, 'sftp_link'): self.sftp_link = sftp_transport() ok = self.sftp_link.send(self) return ok # user defined send scripts # if many are configured, this one is the last one in config elif self.do_send: ok = self.do_send(self) return ok except: if self.reportback: self.msg.report_publish(503, "Unable to process") self.logger.error("sender/__do_send__: could not send") self.logger.debug('Exception details: ', exc_info=True) # something went wrong if self.reportback: self.msg.report_publish( 503, "Service unavailable %s" % self.msg.url.scheme) return False
def __do_download__(self): self.logger.debug("downloading/copying into %s " % self.msg.local_file) try: if self.msg.url.scheme == 'http': if not hasattr(self, 'http_link'): self.http_link = http_transport() return self.http_link.download(self) elif self.msg.url.scheme == 'ftp': if not hasattr(self, 'ftp_link'): self.ftp_link = ftp_transport() return self.ftp_link.download(self) elif self.msg.url.scheme == 'sftp': try: from sr_sftp import sftp_transport except: from sarra.sr_sftp import sftp_transport if not hasattr(self, 'sftp_link'): self.sftp_link = sftp_transport() return self.sftp_link.download(self) elif self.msg.url.scheme == 'file': return file_process(self) # user defined download scripts elif self.do_download: return self.do_download(self) except: (stype, svalue, tb) = sys.exc_info() self.logger.error("Download Type: %s, Value: %s, ..." % (stype, svalue)) self.msg.report_publish(503, "Unable to process") self.logger.error("sr_sarra: could not download") self.msg.report_publish(503, "Service unavailable %s" % self.msg.url.scheme)
def __do_download__(self): self.logger.debug("downloading/copying into %s " % self.msg.local_file) try : if self.msg.url.scheme == 'http' : if not hasattr(self,'http_link') : self.http_link = http_transport() return self.http_link.download(self) elif self.msg.url.scheme == 'ftp' : if not hasattr(self,'ftp_link') : self.ftp_link = ftp_transport() return self.ftp_link.download(self) elif self.msg.url.scheme == 'sftp' : try : from sr_sftp import sftp_transport except : from sarra.sr_sftp import sftp_transport if not hasattr(self,'sftp_link') : self.sftp_link = sftp_transport() return self.sftp_link.download(self) elif self.msg.url.scheme == 'file' : return file_process(self) # user defined download scripts elif self.do_download : return self.do_download(self) except : (stype, svalue, tb) = sys.exc_info() self.logger.error("Download Type: %s, Value: %s, ..." % (stype, svalue)) self.msg.report_publish(503,"Unable to process") self.logger.error("sr_subscribe: Could not download") self.msg.report_publish(503,"Service unavailable %s" % self.msg.url.scheme)