koji-gc: from_addr option, make network timeout hack an option, misc cleanup

This commit is contained in:
Mike McLean 2007-10-24 15:58:48 -04:00
parent aebd6f520c
commit a343624257

View file

@ -34,8 +34,6 @@ if optparse.__version__ == "1.4.1+":
sys.exit(2)
OptionParser.error = _op_error
#XXX - hack
socket.setdefaulttimeout(180)
class MySession(koji.ClientSession):
"""This is a hack to work around server timeouts"""
@ -62,11 +60,7 @@ class MySession(koji.ClientSession):
self.multicall = False
calls = self._calls
self._calls = []
#return self.proxy.multiCall(self._calls)
#print "multicall: %r" % (calls,)
ret = self._callMethod('multiCall', (calls,), {})
#print "result: %r" % (ret,)
return ret
return self._callMethod('multiCall', (calls,), {})
def _(args):
@ -88,6 +82,8 @@ def get_options():
parser.add_option("--password", help=_("specify password"))
parser.add_option("--noauth", action="store_true", default=False,
help=_("do not authenticate"))
parser.add_option("--network-hack", action="store_true", default=False,
help=_("enable hackish workaround for broken networks"))
parser.add_option("--cert", default='/etc/koji-gc/client.crt',
help=_("SSL certification file for authentication"))
parser.add_option("--ca", default='/etc/koji-gc/clientca.crt',
@ -159,6 +155,7 @@ def get_options():
['server', None, 'string'],
['weburl', None, 'string'],
['smtp_host', None, 'string'],
['from_addr', None, 'string'],
['mail', None, 'boolean'],
['delay', None, 'string'],
['unprotected_keys', None, 'string'],
@ -197,8 +194,8 @@ def get_options():
options.unprotected_key_patterns = []
#parse key aliases
options.key_aliases = {}
try:
options.key_aliases = {}
if config and config.has_option('main', 'key_aliases'):
for line in config.get('main','key_aliases').splitlines():
parts = line.split()
@ -371,9 +368,9 @@ refer to the document linked above for instructions."""
msg['Subject'] = "1 build marked for deletion"
else:
msg['Subject'] = "%i builds marked for deletion" % len(builds)
msg['From'] = "Koji Build System <buildsys@fedoraproject.org>" #XXX
msg['From'] = options.from_addr
msg['To'] = "%s@fedoraproject.org" % owner_name #XXX!
msg['X-Brew-Builder'] = owner_name
msg['X-Koji-Builder'] = owner_name
if options.test:
if options.debug:
print str(msg)
@ -946,7 +943,11 @@ if __name__ == "__main__":
session_opts = {}
for k in ('user', 'password', 'debug_xmlrpc', 'debug'):
session_opts[k] = getattr(options,k)
session = MySession(options.server, session_opts)
if options.network_hack:
socket.setdefaulttimeout(180)
session = MySession(options.server, session_opts)
else:
session = koji.ClientSession(options.server, session_opts)
rv = 0
try:
if not options.skip_main: