def loadConfiguration(self): self.log.debug(">>> loadConfiguration") try: config = ConfigParser.ConfigParser() configfile = os.getcwd( ) + "/" + self.CONFIG_PATH + "/" + self.CONFIG_FILE_NAME config.readfp(open(configfile)) # read default configs self.SEND_REPORT = Iprods_String_Utils.smart_bool( config.get('application', 'SEND_REPORT')) self.WRITE_REPORT = Iprods_String_Utils.smart_bool( config.get('application', 'WRITE_REPORT')) self.VERBOSE_REPORT = Iprods_String_Utils.smart_bool( config.get('application', 'VERBOSE_REPORT')) self.LINK_DEPTH = config.getint('application', 'LINK_DEPTH') self.REPORT_PATH = config.get('application', 'REPORT_PATH') self.REPORT_LEVEL = config.get('application', 'REPORT_LEVEL') self.USERAGENT = config.get('application', 'USERAGENT') self.CHECK_EXTERNAL = config.get('application', 'CHECK_EXTERNAL') self.MAX_THREADS = config.getint('application', 'MAX_THREADS') self.TIMEOUT = config.getfloat('application', 'TIMEOUT') self.HTTP_TIMEOUT = config.getint('application', 'HTTP_TIMEOUT') self.SMTP_SERVER = config.get('application', 'SMTP_SERVER') self.SMTP_TTLS = config.get('application', 'SMTP_TTLS') self.SMTP_PORT = config.get('application', 'SMTP_PORT') self.SMTP_USERNAME = config.get('application', 'SMTP_USERNAME') self.SMTP_PASSWORD = config.get('application', 'SMTP_PASSWORD') self.MAIL_SUBJECT = config.get('application', 'MAIL_SUBJECT') self.MAIL_TO = config.get('application', 'MAIL_TO') self.MAIL_FROM = config.get('application', 'MAIL_FROM') self.MAIL_CC = config.get('application', 'MAIL_CC') self.MAIL_BCC = config.get('application', 'MAIL_BCC') self.log.info( "application config loaded successfully... [SEND_REPORT: %s, WRITE_REPORT: %s, VERBOSE_REPORT: %s, LINK_DEPTH: %s, REPORT_PATH: %s, REPORT_LEVEL: %s, USERAGENT: %s, TIMEOUT: %s, HTTP_TIMEOUT: %s, SMTP_SERVER: %s, SMTP_TTLS: %s, SMTP_PORT: %s, SMTP_USERNAME: %s, MAIL_SUBJECT: %s, MAIL_TO: %s, MAIL_FROM: %s, MAIL_BCC: %s]" % (self.SEND_REPORT, self.WRITE_REPORT, self.VERBOSE_REPORT, self.LINK_DEPTH, self.REPORT_PATH, self.REPORT_LEVEL, self.USERAGENT, self.TIMEOUT, self.HTTP_TIMEOUT, self.SMTP_SERVER, self.SMTP_TTLS, self.SMTP_PORT, self.SMTP_USERNAME, self.MAIL_SUBJECT, self.MAIL_TO, self.MAIL_FROM, self.MAIL_BCC)) except StandardError: config = None exctype, value = sys.exc_info()[:2] self.log.exception( "loadConfiguration failed. exctype: %s, value: %s [file: %s]" % (exctype, value, self.CONFIG_FILE_NAME)) self.log.debug("<<< loadConfiguration [config: %s]", config) return config
def loadConfiguration(self): self.log.debug(">>> loadConfiguration") try: config = ConfigParser.ConfigParser() configfile = os.getcwd( ) + "/" + self.CONFIG_PATH + "/" + self.CONFIG_FILE_NAME config.readfp(open(configfile)) # read default configs self.SEND_REPORT = Iprods_String_Utils.smart_bool(config.get('application', 'SEND_REPORT')) self.WRITE_REPORT = Iprods_String_Utils.smart_bool(config.get('application', 'WRITE_REPORT')) self.VERBOSE_REPORT = Iprods_String_Utils.smart_bool(config.get('application', 'VERBOSE_REPORT')) self.LINK_DEPTH = config.getint('application', 'LINK_DEPTH') self.REPORT_PATH = config.get('application', 'REPORT_PATH') self.REPORT_LEVEL = config.get('application', 'REPORT_LEVEL') self.USERAGENT = config.get('application', 'USERAGENT') self.CHECK_EXTERNAL = config.get('application', 'CHECK_EXTERNAL') self.MAX_THREADS = config.getint('application', 'MAX_THREADS') self.TIMEOUT = config.getfloat('application', 'TIMEOUT') self.HTTP_TIMEOUT = config.getint('application', 'HTTP_TIMEOUT') self.SMTP_SERVER = config.get('application', 'SMTP_SERVER') self.SMTP_TTLS = config.get('application', 'SMTP_TTLS') self.SMTP_PORT = config.get('application', 'SMTP_PORT') self.SMTP_USERNAME = config.get('application', 'SMTP_USERNAME') self.SMTP_PASSWORD = config.get('application', 'SMTP_PASSWORD') self.MAIL_SUBJECT = config.get('application', 'MAIL_SUBJECT') self.MAIL_TO = config.get('application', 'MAIL_TO') self.MAIL_FROM = config.get('application', 'MAIL_FROM') self.MAIL_CC = config.get('application', 'MAIL_CC') self.MAIL_BCC = config.get('application', 'MAIL_BCC') self.log.info("application config loaded successfully... [SEND_REPORT: %s, WRITE_REPORT: %s, VERBOSE_REPORT: %s, LINK_DEPTH: %s, REPORT_PATH: %s, REPORT_LEVEL: %s, USERAGENT: %s, TIMEOUT: %s, HTTP_TIMEOUT: %s, SMTP_SERVER: %s, SMTP_TTLS: %s, SMTP_PORT: %s, SMTP_USERNAME: %s, MAIL_SUBJECT: %s, MAIL_TO: %s, MAIL_FROM: %s, MAIL_BCC: %s]" % (self.SEND_REPORT, self.WRITE_REPORT, self.VERBOSE_REPORT, self.LINK_DEPTH, self.REPORT_PATH, self.REPORT_LEVEL, self.USERAGENT, self.TIMEOUT, self.HTTP_TIMEOUT, self.SMTP_SERVER, self.SMTP_TTLS, self.SMTP_PORT, self.SMTP_USERNAME, self.MAIL_SUBJECT, self.MAIL_TO, self.MAIL_FROM, self.MAIL_BCC)) except StandardError: config = None exctype, value = sys.exc_info()[:2] self.log.exception("loadConfiguration failed. exctype: %s, value: %s [file: %s]" % (exctype, value, self.CONFIG_FILE_NAME)) self.log.debug("<<< loadConfiguration [config: %s]", config) return config
def loadConfigurationSite(self, sitename): config = '' self.log.debug(">>> loadConfigurationSite [sitename: %s]" % (sitename)) if sitename: try: config = ConfigParser.ConfigParser() configfile = os.getcwd( ) + "/" + self.CONFIG_PATH + "/" + sitename + ".cfg" config.readfp(open(configfile)) if (config.has_section(sitename)): # read site configs self.DOMAIN = config.get(sitename, 'DOMAIN') self.PATH = config.get(sitename, 'PATH') if (config.has_option(sitename, 'MAX_THREADS')): self.MAX_THREADS = config.getint( sitename, 'MAX_THREADS') if (config.has_option(sitename, 'LINK_DEPTH')): self.LINK_DEPTH = config.getint(sitename, 'LINK_DEPTH') if (config.has_option(sitename, 'REPORT_LEVEL')): self.REPORT_LEVEL = config.get(sitename, 'REPORT_LEVEL') if (config.has_option(sitename, 'EXCLUDE_PATTERN') and len( config.get(sitename, 'EXCLUDE_PATTERN').strip()) > 0): self.EXCLUDE_PATTERN = config.get( sitename, 'EXCLUDE_PATTERN').strip().split(",") else: self.EXCLUDE_PATTERN = '' if (config.has_option(sitename, 'INCLUDE_FILETYPES') and len( config.get(sitename, 'INCLUDE_FILETYPES').strip()) > 0): self.INCLUDE_FILETYPES = config.get( sitename, 'INCLUDE_FILETYPES').strip().split(",") else: self.INCLUDE_FILETYPES = '' if (config.has_option(sitename, 'CHECK_EXTERNAL')): self.CHECK_EXTERNAL = Iprods_String_Utils.smart_bool( config.get(sitename, 'CHECK_EXTERNAL')) if (config.has_option(sitename, 'SEND_REPORT')): self.SEND_REPORT = Iprods_String_Utils.smart_bool( config.get(sitename, 'SEND_REPORT')) if (config.has_option(sitename, 'WRITE_REPORT')): self.WRITE_REPORT = Iprods_String_Utils.smart_bool( config.get(sitename, 'WRITE_REPORT')) if (config.has_option(sitename, 'VERBOSE_REPORT')): self.VERBOSE_REPORT = Iprods_String_Utils.smart_bool( config.get(sitename, 'VERBOSE_REPORT')) if (config.has_option(sitename, 'TIMEOUT')): self.TIMEOUT = config.getfloat(sitename, 'TIMEOUT') if (config.has_option(sitename, 'HTTP_TIMEOUT')): self.HTTP_TIMEOUT = config.getint( sitename, 'HTTP_TIMEOUT') if (config.has_option(sitename, 'SMTP_SERVER')): self.SMTP_SERVER = config.get(sitename, 'SMTP_SERVER') if (config.has_option(sitename, 'SMTP_TTLS')): self.SMTP_TTLS = config.get(sitename, 'SMTP_TTLS') if (config.has_option(sitename, 'SMTP_PORT')): self.SMTP_PORT = config.get(sitename, 'SMTP_PORT') if (config.has_option(sitename, 'SMTP_USERNAME')): self.SMTP_USERNAME = config.get( sitename, 'SMTP_USERNAME') if (config.has_option(sitename, 'SMTP_PASSWORD')): self.SMTP_PASSWORD = config.get( sitename, 'SMTP_PASSWORD') if (config.has_option(sitename, 'MAIL_SUBJECT')): self.MAIL_SUBJECT = "%s - %s" % (config.get( sitename, 'MAIL_SUBJECT'), self.DOMAIN) if (config.has_option(sitename, 'MAIL_FROM')): self.MAIL_FROM = config.get(sitename, 'MAIL_FROM') if (config.has_option(sitename, 'MAIL_TO')): self.MAIL_TO = config.get(sitename, 'MAIL_TO') if (config.has_option(sitename, 'MAIL_CC')): self.MAIL_CC = config.get(sitename, 'MAIL_CC') if (config.has_option(sitename, 'MAIL_BCC')): self.MAIL_BCC = config.get(sitename, 'MAIL_BCC') self.log.info( "site configuration loaded successfully... [sitename: %s, SEND_REPORT: %s, WRITE_REPORT: %s, VERBOSE_REPORT: %s, LINK_DEPTH: %s, REPORT_PATH: %s, REPORT_LEVEL: %s, USERAGENT: %s, TIMEOUT: %s, HTTP_TIMEOUT: %s, SMTP_SERVER: %s, SMTP_TTLS: %s, SMTP_PORT: %s, SMTP_USERNAME: %s, MAIL_SUBJECT: %s, MAIL_TO: %s, MAIL_FROM: %s, MAIL_BCC: %s]" % (sitename, self.SEND_REPORT, self.WRITE_REPORT, self.VERBOSE_REPORT, self.LINK_DEPTH, self.REPORT_PATH, self.REPORT_LEVEL, self.USERAGENT, self.TIMEOUT, self.HTTP_TIMEOUT, self.SMTP_SERVER, self.SMTP_TTLS, self.SMTP_PORT, self.SMTP_USERNAME, self.MAIL_SUBJECT, self.MAIL_TO, self.MAIL_FROM, self.MAIL_BCC)) else: config = None self.log.error( "loadConfigurationSite failed. [sitename:%s]. " % (sitename)) except StandardError: config = None exctype, value = sys.exc_info()[:2] self.log.exception( "loadConfigurationSite failed. exctype: %s, value: %s [sitename: %s]" % (exctype, value, sitename)) self.log.debug("<<< loadConfigurationSite [config: %s]", config) return config
def loadConfigurationSite(self, sitename): config = '' self.log.debug(">>> loadConfigurationSite [sitename: %s]" % (sitename)) if sitename: try: config = ConfigParser.ConfigParser() configfile = os.getcwd( ) + "/" + self.CONFIG_PATH + "/" + sitename + ".cfg" config.readfp(open(configfile)) if (config.has_section(sitename)): # read site configs self.DOMAIN = config.get(sitename, 'DOMAIN') self.PATH = config.get(sitename, 'PATH') if (config.has_option(sitename, 'MAX_THREADS')): self.MAX_THREADS = config.getint(sitename, 'MAX_THREADS') if (config.has_option(sitename, 'LINK_DEPTH')): self.LINK_DEPTH = config.getint(sitename, 'LINK_DEPTH') if (config.has_option(sitename, 'REPORT_LEVEL')): self.REPORT_LEVEL = config.get(sitename, 'REPORT_LEVEL') if (config.has_option(sitename, 'EXCLUDE_PATTERN') and len(config.get(sitename, 'EXCLUDE_PATTERN').strip()) > 0): self.EXCLUDE_PATTERN = config.get(sitename, 'EXCLUDE_PATTERN').strip().split(",") else: self.EXCLUDE_PATTERN = '' if (config.has_option(sitename, 'INCLUDE_FILETYPES') and len(config.get(sitename, 'INCLUDE_FILETYPES').strip()) > 0): self.INCLUDE_FILETYPES = config.get(sitename, 'INCLUDE_FILETYPES').strip().split(",") else: self.INCLUDE_FILETYPES = '' if (config.has_option(sitename, 'CHECK_EXTERNAL')): self.CHECK_EXTERNAL = Iprods_String_Utils.smart_bool(config.get(sitename, 'CHECK_EXTERNAL')) if (config.has_option(sitename, 'SEND_REPORT')): self.SEND_REPORT = Iprods_String_Utils.smart_bool(config.get(sitename, 'SEND_REPORT')) if (config.has_option(sitename, 'WRITE_REPORT')): self.WRITE_REPORT = Iprods_String_Utils.smart_bool(config.get(sitename, 'WRITE_REPORT')) if (config.has_option(sitename, 'VERBOSE_REPORT')): self.VERBOSE_REPORT = Iprods_String_Utils.smart_bool(config.get(sitename, 'VERBOSE_REPORT')) if (config.has_option(sitename, 'TIMEOUT')): self.TIMEOUT = config.getfloat(sitename, 'TIMEOUT') if (config.has_option(sitename, 'HTTP_TIMEOUT')): self.HTTP_TIMEOUT = config.getint(sitename, 'HTTP_TIMEOUT') if (config.has_option(sitename, 'SMTP_SERVER')): self.SMTP_SERVER = config.get(sitename, 'SMTP_SERVER') if (config.has_option(sitename, 'SMTP_TTLS')): self.SMTP_TTLS = config.get(sitename, 'SMTP_TTLS') if (config.has_option(sitename, 'SMTP_PORT')): self.SMTP_PORT = config.get(sitename, 'SMTP_PORT') if (config.has_option(sitename, 'SMTP_USERNAME')): self.SMTP_USERNAME = config.get(sitename, 'SMTP_USERNAME') if (config.has_option(sitename, 'SMTP_PASSWORD')): self.SMTP_PASSWORD = config.get(sitename, 'SMTP_PASSWORD') if (config.has_option(sitename, 'MAIL_SUBJECT')): self.MAIL_SUBJECT = "%s - %s" % (config.get(sitename, 'MAIL_SUBJECT'), self.DOMAIN) if (config.has_option(sitename, 'MAIL_FROM')): self.MAIL_FROM = config.get(sitename, 'MAIL_FROM') if (config.has_option(sitename, 'MAIL_TO')): self.MAIL_TO = config.get(sitename, 'MAIL_TO') if (config.has_option(sitename, 'MAIL_CC')): self.MAIL_CC = config.get(sitename, 'MAIL_CC') if (config.has_option(sitename, 'MAIL_BCC')): self.MAIL_BCC = config.get(sitename, 'MAIL_BCC') self.log.info("site configuration loaded successfully... [sitename: %s, SEND_REPORT: %s, WRITE_REPORT: %s, VERBOSE_REPORT: %s, LINK_DEPTH: %s, REPORT_PATH: %s, REPORT_LEVEL: %s, USERAGENT: %s, TIMEOUT: %s, HTTP_TIMEOUT: %s, SMTP_SERVER: %s, SMTP_TTLS: %s, SMTP_PORT: %s, SMTP_USERNAME: %s, MAIL_SUBJECT: %s, MAIL_TO: %s, MAIL_FROM: %s, MAIL_BCC: %s]" % (sitename, self.SEND_REPORT, self.WRITE_REPORT, self.VERBOSE_REPORT, self.LINK_DEPTH, self.REPORT_PATH, self.REPORT_LEVEL, self.USERAGENT, self.TIMEOUT, self.HTTP_TIMEOUT, self.SMTP_SERVER, self.SMTP_TTLS, self.SMTP_PORT, self.SMTP_USERNAME, self.MAIL_SUBJECT, self.MAIL_TO, self.MAIL_FROM, self.MAIL_BCC)) else: config = None self.log.error("loadConfigurationSite failed. [sitename:%s]. " % (sitename)) except StandardError: config = None exctype, value = sys.exc_info()[:2] self.log.exception("loadConfigurationSite failed. exctype: %s, value: %s [sitename: %s]" % (exctype, value, sitename)) self.log.debug("<<< loadConfigurationSite [config: %s]", config) return config