flake8: apply E3 rules
This commit is contained in:
parent
05340b146b
commit
0f727a2ab4
32 changed files with 534 additions and 70 deletions
|
|
@ -56,14 +56,17 @@ KOJIKAMID = True
|
|||
|
||||
# INSERT kojikamid dup #
|
||||
|
||||
|
||||
class fakemodule(object):
|
||||
pass
|
||||
|
||||
|
||||
# make parts of the above insert accessible as koji.X
|
||||
koji = fakemodule()
|
||||
koji.GenericError = GenericError # noqa: F821
|
||||
koji.BuildError = BuildError # noqa: F821
|
||||
|
||||
|
||||
def encode_int(n):
|
||||
"""If n is too large for a 32bit signed, convert it to a string"""
|
||||
if n <= 2147483647:
|
||||
|
|
@ -71,6 +74,7 @@ def encode_int(n):
|
|||
# else
|
||||
return str(n)
|
||||
|
||||
|
||||
class WindowsBuild(object):
|
||||
|
||||
LEADING_CHAR = re.compile('^[^A-Za-z_]')
|
||||
|
|
@ -529,6 +533,7 @@ class WindowsBuild(object):
|
|||
self.expireBuildroot()
|
||||
return self.gatherResults()
|
||||
|
||||
|
||||
def run(cmd, chdir=None, fatal=False, log=True):
|
||||
global logfd
|
||||
output = ''
|
||||
|
|
@ -558,6 +563,7 @@ def run(cmd, chdir=None, fatal=False, log=True):
|
|||
raise BuildError(msg) # noqa: F821
|
||||
return ret, output
|
||||
|
||||
|
||||
def find_net_info():
|
||||
"""
|
||||
Find the network gateway configured for this VM.
|
||||
|
|
@ -586,6 +592,7 @@ def find_net_info():
|
|||
gateway = None
|
||||
return macaddr, gateway
|
||||
|
||||
|
||||
def upload_file(server, prefix, path):
|
||||
"""upload a single file to the vmd"""
|
||||
logger = logging.getLogger('koji.vm')
|
||||
|
|
@ -606,6 +613,7 @@ def upload_file(server, prefix, path):
|
|||
server.verifyChecksum(path, digest, 'md5')
|
||||
logger.info('Uploaded %s (%s bytes, md5: %s)', destpath, offset, digest)
|
||||
|
||||
|
||||
def get_mgmt_server():
|
||||
"""Get a ServerProxy object we can use to retrieve task info"""
|
||||
logger = logging.getLogger('koji.vm')
|
||||
|
|
@ -624,6 +632,7 @@ def get_mgmt_server():
|
|||
logger.debug('found task-specific port %s', task_port)
|
||||
return six.moves.xmlrpc_client.ServerProxy('http://%s:%s/' % (gateway, task_port), allow_none=True)
|
||||
|
||||
|
||||
def get_options():
|
||||
"""handle usage and parse options"""
|
||||
usage = """%prog [options]
|
||||
|
|
@ -637,6 +646,7 @@ def get_options():
|
|||
(options, args) = parser.parse_args()
|
||||
return options
|
||||
|
||||
|
||||
def setup_logging(opts):
|
||||
global logfile, logfd
|
||||
logger = logging.getLogger('koji.vm')
|
||||
|
|
@ -651,11 +661,13 @@ def setup_logging(opts):
|
|||
logger.addHandler(handler)
|
||||
return handler
|
||||
|
||||
|
||||
def log_local(msg):
|
||||
tb = ''.join(traceback.format_exception(*sys.exc_info()))
|
||||
sys.stderr.write('%s: %s\n' % (time.ctime(), msg))
|
||||
sys.stderr.write(tb)
|
||||
|
||||
|
||||
def stream_logs(server, handler, builds):
|
||||
"""Stream logs incrementally to the server.
|
||||
The global logfile will always be streamed.
|
||||
|
|
@ -693,6 +705,7 @@ def stream_logs(server, handler, builds):
|
|||
log_local('error uploading %s' % relpath)
|
||||
time.sleep(1)
|
||||
|
||||
|
||||
def fail(server, handler):
|
||||
"""do the right thing when a build fails"""
|
||||
global logfile, logfd
|
||||
|
|
@ -719,6 +732,7 @@ def fail(server, handler):
|
|||
logfile = '/tmp/build.log'
|
||||
logfd = None
|
||||
|
||||
|
||||
def main():
|
||||
prog = os.path.basename(sys.argv[0])
|
||||
opts = get_options()
|
||||
|
|
|
|||
|
|
@ -68,6 +68,8 @@ def libvirt_callback(ignore, err):
|
|||
if err[3] != libvirt.VIR_ERR_ERROR:
|
||||
# Don't log libvirt errors: global error handler will do that
|
||||
logging.warn("Non-error from libvirt: '%s'", err[2])
|
||||
|
||||
|
||||
libvirt.registerErrorHandler(f=libvirt_callback, ctx=None)
|
||||
|
||||
|
||||
|
|
@ -191,6 +193,7 @@ def get_options():
|
|||
|
||||
return options
|
||||
|
||||
|
||||
def quit(msg=None, code=1):
|
||||
if msg:
|
||||
logging.getLogger("koji.vm").error(msg)
|
||||
|
|
@ -198,6 +201,7 @@ def quit(msg=None, code=1):
|
|||
sys.stderr.flush()
|
||||
sys.exit(code)
|
||||
|
||||
|
||||
def main(options, session):
|
||||
logger = logging.getLogger("koji.vm")
|
||||
logger.info('Starting up')
|
||||
|
|
@ -209,8 +213,10 @@ def main(options, session):
|
|||
for name in options.plugin:
|
||||
logger.info('Loading plugin: %s', name)
|
||||
tm.scanPlugin(pt.load(name))
|
||||
|
||||
def shutdown(*args):
|
||||
raise SystemExit
|
||||
|
||||
def restart(*args):
|
||||
logger.warn("Initiating graceful restart")
|
||||
tm.restart_pending = True
|
||||
|
|
@ -416,6 +422,7 @@ class WinBuildTask(MultiPlatformTask):
|
|||
parent=self.id)
|
||||
self.wait(tag_task_id)
|
||||
|
||||
|
||||
class VMExecTask(BaseTaskHandler):
|
||||
"""
|
||||
Handles the startup, state-tracking, and shutdown of a VM
|
||||
|
|
@ -883,6 +890,7 @@ class VMExecTask(BaseTaskHandler):
|
|||
else:
|
||||
raise koji.BuildError(self.output)
|
||||
|
||||
|
||||
class VMTaskManager(TaskManager):
|
||||
def __init__(self, options, session):
|
||||
super(VMTaskManager, self).__init__(options, session)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue