grab_session_options function
This commit is contained in:
parent
33e1bdee97
commit
3d16485c6f
2 changed files with 35 additions and 9 deletions
11
cli/koji
11
cli/koji
|
|
@ -7171,15 +7171,8 @@ if __name__ == "__main__":
|
|||
else:
|
||||
logger.setLevel(logging.WARN)
|
||||
|
||||
session_opts = {}
|
||||
for k in ('user', 'password', 'krbservice', 'debug_xmlrpc', 'debug', 'max_retries',
|
||||
'retry_interval', 'offline_retry', 'offline_retry_interval',
|
||||
'anon_retry', 'keepalive', 'timeout', 'use_fast_upload',
|
||||
'upload_blocksize', 'krb_rdns', 'use_old_ssl', 'serverca'):
|
||||
value = getattr(options,k)
|
||||
if value is not None:
|
||||
session_opts[k] = value
|
||||
session = koji.ClientSession(options.server,session_opts)
|
||||
session_opts = koji.grab_session_options(options)
|
||||
session = koji.ClientSession(options.server, session_opts)
|
||||
rv = 0
|
||||
try:
|
||||
rv = locals()[command].__call__(options, session, args)
|
||||
|
|
|
|||
|
|
@ -1906,6 +1906,38 @@ class VirtualMethod(object):
|
|||
return self.__func(self.__name, args, opts)
|
||||
|
||||
|
||||
def grab_session_options(options):
|
||||
'''Convert optparse options to a dict that ClientSession can handle'''
|
||||
s_opts = (
|
||||
'user',
|
||||
'password',
|
||||
'krbservice',
|
||||
'debug_xmlrpc',
|
||||
'debug',
|
||||
'max_retries',
|
||||
'retry_interval',
|
||||
'offline_retry',
|
||||
'offline_retry_interval',
|
||||
'anon_retry',
|
||||
'keepalive',
|
||||
'timeout',
|
||||
'use_fast_upload',
|
||||
'upload_blocksize',
|
||||
'krb_rdns',
|
||||
'use_old_ssl',
|
||||
'no_ssl_verify',
|
||||
'serverca',
|
||||
)
|
||||
# cert is omitted for now
|
||||
ret = {}
|
||||
for key in s_opts:
|
||||
if not hasattr(options, key):
|
||||
continue
|
||||
value = getattr(options, key)
|
||||
if value is not None:
|
||||
ret[key] = value
|
||||
|
||||
|
||||
class ClientSession(object):
|
||||
|
||||
def __init__(self, baseurl, opts=None, sinfo=None):
|
||||
|
|
@ -1925,6 +1957,7 @@ class ClientSession(object):
|
|||
self.new_session()
|
||||
self.opts.setdefault('timeout', 60 * 60 * 12)
|
||||
|
||||
|
||||
def new_session(self):
|
||||
self.logger.debug("Opening new requests session")
|
||||
if self.rsession:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue