本文整理汇总了Python中six.moves.configparser.RawConfigParser.getint方法的典型用法代码示例。如果您正苦于以下问题:Python RawConfigParser.getint方法的具体用法?Python RawConfigParser.getint怎么用?Python RawConfigParser.getint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类six.moves.configparser.RawConfigParser
的用法示例。
在下文中一共展示了RawConfigParser.getint方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: load_config
# 需要导入模块: from six.moves.configparser import RawConfigParser [as 别名]
# 或者: from six.moves.configparser.RawConfigParser import getint [as 别名]
def load_config(self, environ):
"""Load configuration options
Options are read from a config file.
Backwards compatibility:
- if ConfigFile is not set, opts are loaded from http config
- if ConfigFile is set, then the http config must not provide Koji options
- In a future version we will load the default hub config regardless
- all PythonOptions (except koji.web.ConfigFile) are now deprecated and
support for them will disappear in a future version of Koji
"""
cf = environ.get('koji.web.ConfigFile', '/etc/kojiweb/web.conf')
cfdir = environ.get('koji.web.ConfigDir', '/etc/kojiweb/web.conf.d')
if cfdir:
configs = koji.config_directory_contents(cfdir)
else:
configs = []
if cf and os.path.isfile(cf):
configs.append(cf)
if configs:
config = RawConfigParser()
config.read(configs)
else:
raise koji.GenericError("Configuration missing")
opts = {}
for name, dtype, default in self.cfgmap:
key = ('web', name)
if config and config.has_option(*key):
if dtype == 'integer':
opts[name] = config.getint(*key)
elif dtype == 'boolean':
opts[name] = config.getboolean(*key)
elif dtype == 'list':
opts[name] = [x.strip() for x in config.get(*key).split(',')]
else:
opts[name] = config.get(*key)
else:
opts[name] = default
opts['Secret'] = koji.util.HiddenValue(opts['Secret'])
self.options = opts
return opts
示例2: getint
# 需要导入模块: from six.moves.configparser import RawConfigParser [as 别名]
# 或者: from six.moves.configparser.RawConfigParser import getint [as 别名]
def getint(self, section, option):
if not self.has_option(section, option):
return self.DEF_INT
return RawConfigParser.getint(self, section, option)
示例3: print
# 需要导入模块: from six.moves.configparser import RawConfigParser [as 别名]
# 或者: from six.moves.configparser.RawConfigParser import getint [as 别名]
thisjob.day.on(newcrontime.datetime.day) # get new month of the year
cron.write()
os._exit(0) # don't use sys.exit(0) as this throws an exception that is caught by "except": https://stackoverflow.com/a/173323/1862861
except:
errmsg = "Error... could not reset the crontab to wait for rescue DAG completion."
print(errmsg, file=sys.stderr)
remove_cron(cronid)
if email != None:
subject = sys.argv[0] + ': Error message'
send_email(FROM, email, subject, errmsg, server)
sys.exit(1)
# Get the start time of the automated analysis - if not present default to the current time
if cp.has_option('times', 'starttime'):
try:
starttime = cp.getint('times', 'starttime')
except:
errmsg = "Error... could not parse 'starttime' in '[times]'. A start time is required."
print(errmsg, file=sys.stderr)
if email != None:
subject = sys.argv[0] + ': Error message'
send_email(FROM, email, subject, errmsg, server)
if not startcron: remove_cron(cronid)
sys.exit(1)
# check start time is in the past
if starttime >= gpsnow:
errmsg = "Error... start time (%f) must be in the past!" % starttime
print(errmsg, file=sys.stderr)
if email != None:
subject = sys.argv[0] + ': Error message'
示例4: load_config
# 需要导入模块: from six.moves.configparser import RawConfigParser [as 别名]
# 或者: from six.moves.configparser.RawConfigParser import getint [as 别名]
def load_config(environ):
"""Load configuration options
Options are read from a config file. The config file location is
controlled by the PythonOption ConfigFile in the httpd config.
Backwards compatibility:
- if ConfigFile is not set, opts are loaded from http config
- if ConfigFile is set, then the http config must not provide Koji options
- In a future version we will load the default hub config regardless
- all PythonOptions (except ConfigFile) are now deprecated and support for them
will disappear in a future version of Koji
"""
logger = logging.getLogger("koji")
#get our config file(s)
cf = environ.get('koji.hub.ConfigFile', '/etc/koji-hub/hub.conf')
cfdir = environ.get('koji.hub.ConfigDir', '/etc/koji-hub/hub.conf.d')
if cfdir:
configs = koji.config_directory_contents(cfdir)
else:
configs = []
if cf and os.path.isfile(cf):
configs.append(cf)
if configs:
config = RawConfigParser()
config.read(configs)
else:
config = None
cfgmap = [
#option, type, default
['DBName', 'string', None],
['DBUser', 'string', None],
['DBHost', 'string', None],
['DBhost', 'string', None], # alias for backwards compatibility
['DBPort', 'integer', None],
['DBPass', 'string', None],
['KojiDir', 'string', None],
['AuthPrincipal', 'string', None],
['AuthKeytab', 'string', None],
['ProxyPrincipals', 'string', ''],
['HostPrincipalFormat', 'string', None],
['DNUsernameComponent', 'string', 'CN'],
['ProxyDNs', 'string', ''],
['CheckClientIP', 'boolean', True],
['LoginCreatesUser', 'boolean', True],
['KojiWebURL', 'string', 'http://localhost.localdomain/koji'],
['EmailDomain', 'string', None],
['NotifyOnSuccess', 'boolean', True],
['DisableNotifications', 'boolean', False],
['Plugins', 'string', ''],
['PluginPath', 'string', '/usr/lib/koji-hub-plugins'],
['KojiDebug', 'boolean', False],
['KojiTraceback', 'string', None],
['VerbosePolicy', 'boolean', False],
['EnableFunctionDebug', 'boolean', False],
['LogLevel', 'string', 'WARNING'],
['LogFormat', 'string', '%(asctime)s [%(levelname)s] m=%(method)s u=%(user_name)s p=%(process)s r=%(remoteaddr)s %(name)s: %(message)s'],
['MissingPolicyOk', 'boolean', True],
['EnableMaven', 'boolean', False],
['EnableWin', 'boolean', False],
['RLIMIT_AS', 'string', None],
['RLIMIT_CORE', 'string', None],
['RLIMIT_CPU', 'string', None],
['RLIMIT_DATA', 'string', None],
['RLIMIT_FSIZE', 'string', None],
['RLIMIT_MEMLOCK', 'string', None],
['RLIMIT_NOFILE', 'string', None],
['RLIMIT_NPROC', 'string', None],
['RLIMIT_OFILE', 'string', None],
['RLIMIT_RSS', 'string', None],
['RLIMIT_STACK', 'string', None],
['MemoryWarnThreshold', 'integer', 5000],
['MaxRequestLength', 'integer', 4194304],
['LockOut', 'boolean', False],
['ServerOffline', 'boolean', False],
['OfflineMessage', 'string', None],
]
opts = {}
for name, dtype, default in cfgmap:
key = ('hub', name)
if config and config.has_option(*key):
if dtype == 'integer':
opts[name] = config.getint(*key)
elif dtype == 'boolean':
opts[name] = config.getboolean(*key)
else:
opts[name] = config.get(*key)
continue
opts[name] = default
#.........这里部分代码省略.........