def parseCmdLine(self, argv): optlist, args = [], [] short_opts = 'hBo:f:kvs:n:tFlCMO:V' long_opts = ['no-summary', 'only-filter', 'activate-cursor', 'help', 'download-order=', 'mbox-file=', 'verbose', 'max-size=', 'max-to-download=', 'syslog-output', 'quiet', 'check', 'fetchmail', 'only-from=', 'version'] try: optslist, args = getopt.getopt(argv, short_opts, long_opts) for cmdline, value in optslist: if cmdline in ['-l', '--no-summary']: self.optnotlog = True elif cmdline in ['-F', '--only-filter']: self.optonlyfilter = True elif cmdline in ['-k', '--activate-cursor']: general.cursor_on() sys.exit(0) elif cmdline in ['-h', '--help']: general.usage() sys.exit(0) elif cmdline in ['-o', '--download-order']: if not value or not \ value.lower() in ['arrival', 'bin', 'small']: raise getopt.error, _("option --download-order \ supplied with invalid value.") self.optorder = value elif cmdline in ['-f', '--mbox-file']: self.mboxfile = value self.check_mbox() self.optmbox = True elif cmdline in ['-v', '--verbose']: self.optv = True elif cmdline in ['-s', '--max-size']: try: if not value: raise ValueError self.max_size = int(value) self.optsize = True except ValueError: raise getopt.error, _("option --max-to-download \ suplied with invalid value.") elif cmdline in ['-n', '--max-to-download']: self.optmax = True self.max_number = int(value[1]) elif cmdline in ['-B', '--syslog-output']: self.optsyslog = True self.optv = False self.optnotlog = True self.optcolors = False elif cmdline in ['-t', '--quiet']: self.optquiet = True elif cmdline == '--display': pass elif cmdline in ['-C', '--check']: self.optcheck = True self.optnotlog = True elif cmdline in ['-M', '--fetchmail']: self.optfetchmail = True self.optcheck = True self.optnotlog = True elif cmdline in ['-O', '--only-from']: self.onlyServersList = value.split(',') elif cmdline in ['-V', '--version']: print general.VERSION sys.exit(0) else: general.usage() # end for except getopt.error, x: print _("%s:error: %s") % (sys.argv[0], str(x)) general.usage() sys.exit(1)
print _("Socket error sending to the local SMTP, it won't be deleted from the mail server:"), str(x) try: smtp.quit() smtp.connect() except AttributeError: pass if not self.config.optnotlog: logAgent.incident(indice_log, str(x)) continue except mboxException, x: print print _("CRITICAL ERROR. There was an error delivering to MBox, aborting, message won't be deleted from the mail server: "), str(x) sys.exit(1) except maildirException, x: print print _("CRITICAL ERROR. There was an error delivering to Maildir, aborting, message won't be deleted from the mail server: "), str(x) sys.exit(1) except socket.sslerror, x: print print _("Socket error on SSL connection:"), str(x) if not self.config.optnotlog and must_deliver: (foo,emailaddr) = rfc822.parseaddr(fromm) logAgent.append_downloaded(indice_log, emailaddr, msg['size']) if not self.config.optsyslog: aprint('-'* 21, general.GREEN) general.cursor_on() #********************************************************************************
def parseCmdLine(self, argv): optlist, args = [], [] short_opts = 'hBo:f:kvs:n:tFlCMO:V' long_opts = [ 'no-summary', 'only-filter', 'activate-cursor', 'help', 'download-order=', 'mbox-file=', 'verbose', 'max-size=', 'max-to-download=', 'syslog-output', 'quiet', 'check', 'fetchmail', 'only-from=', 'version' ] try: optslist, args = getopt.getopt(argv, short_opts, long_opts) for cmdline, value in optslist: if cmdline in ['-l', '--no-summary']: self.optnotlog = True elif cmdline in ['-F', '--only-filter']: self.optonlyfilter = True elif cmdline in ['-k', '--activate-cursor']: general.cursor_on() sys.exit(0) elif cmdline in ['-h', '--help']: general.usage() sys.exit(0) elif cmdline in ['-o', '--download-order']: if not value or not \ value.lower() in ['arrival', 'bin', 'small']: raise getopt.error, _("option --download-order \ supplied with invalid value.") self.optorder = value elif cmdline in ['-f', '--mbox-file']: self.mboxfile = value self.check_mbox() self.optmbox = True elif cmdline in ['-v', '--verbose']: self.optv = True elif cmdline in ['-s', '--max-size']: try: if not value: raise ValueError self.max_size = int(value) self.optsize = True except ValueError: raise getopt.error, _("option --max-to-download \ suplied with invalid value.") elif cmdline in ['-n', '--max-to-download']: self.optmax = True self.max_number = int(value[1]) elif cmdline in ['-B', '--syslog-output']: self.optsyslog = True self.optv = False self.optnotlog = True self.optcolors = False elif cmdline in ['-t', '--quiet']: self.optquiet = True elif cmdline == '--display': pass elif cmdline in ['-C', '--check']: self.optcheck = True self.optnotlog = True elif cmdline in ['-M', '--fetchmail']: self.optfetchmail = True self.optcheck = True self.optnotlog = True elif cmdline in ['-O', '--only-from']: self.onlyServersList = value.split(',') elif cmdline in ['-V', '--version']: print general.VERSION sys.exit(0) else: general.usage() # end for except getopt.error, x: print _("%s:error: %s") % (sys.argv[0], str(x)) general.usage() sys.exit(1)
def error_msg(self, msg_str, excep, log_index): msg = ' '.join((msg_str, str(excep))) aprint(msg, general.RED) if not self.config.optnotlog: self.logAgent.incident(log_index, msg) general.cursor_on()
def error_msg(self, msg_str, excep, log_index): msg = ' '.join( (msg_str, str(excep)) ) aprint(msg, general.RED) if not self.config.optnotlog: self.logAgent.incident(log_index, msg) general.cursor_on()