flake8: follow E265 rule
This commit is contained in:
parent
642508ccf6
commit
97cfaa4fcf
27 changed files with 794 additions and 793 deletions
161
koji/__init__.py
161
koji/__init__.py
|
|
@ -128,7 +128,7 @@ for h in (
|
|||
'RECOMMENDNAME', 'RECOMMENDVERSION', 'RECOMMENDFLAGS'):
|
||||
SUPPORTED_OPT_DEP_HDRS[h] = hasattr(rpm, 'RPMTAG_%s' % h)
|
||||
|
||||
## BEGIN kojikamid dup
|
||||
# BEGIN kojikamid dup #
|
||||
|
||||
class Enum(dict):
|
||||
"""A simple class to track our enumerated constants
|
||||
|
|
@ -167,7 +167,7 @@ class Enum(dict):
|
|||
|
||||
# deprecated
|
||||
getvalue = _notImplemented
|
||||
#read-only
|
||||
# read-only
|
||||
__setitem__ = _notImplemented
|
||||
__delitem__ = _notImplemented
|
||||
clear = _notImplemented
|
||||
|
|
@ -176,7 +176,7 @@ class Enum(dict):
|
|||
update = _notImplemented
|
||||
setdefault = _notImplemented
|
||||
|
||||
## END kojikamid dup
|
||||
# END kojikamid dup #
|
||||
|
||||
API_VERSION = 1
|
||||
|
||||
|
|
@ -215,7 +215,7 @@ AUTHTYPE_KERB = 1
|
|||
AUTHTYPE_SSL = 2
|
||||
AUTHTYPE_GSSAPI = 3
|
||||
|
||||
#dependency types
|
||||
# dependency types
|
||||
DEP_REQUIRE = 0
|
||||
DEP_PROVIDE = 1
|
||||
DEP_OBSOLETE = 2
|
||||
|
|
@ -225,7 +225,7 @@ DEP_ENHANCE = 5
|
|||
DEP_SUPPLEMENT = 6
|
||||
DEP_RECOMMEND = 7
|
||||
|
||||
#dependency flags
|
||||
# dependency flags
|
||||
RPMSENSE_LESS = 2
|
||||
RPMSENSE_GREATER = 4
|
||||
RPMSENSE_EQUAL = 8
|
||||
|
|
@ -266,7 +266,7 @@ TAG_UPDATE_TYPES = Enum((
|
|||
'MANUAL',
|
||||
))
|
||||
|
||||
## BEGIN kojikamid dup
|
||||
# BEGIN kojikamid dup #
|
||||
|
||||
CHECKSUM_TYPES = Enum((
|
||||
'md5',
|
||||
|
|
@ -274,9 +274,9 @@ CHECKSUM_TYPES = Enum((
|
|||
'sha256',
|
||||
))
|
||||
|
||||
## END kojikamid dup
|
||||
# END kojikamid dup #
|
||||
|
||||
#PARAMETERS
|
||||
# PARAMETERS
|
||||
BASEDIR = '/mnt/koji'
|
||||
# default task priority
|
||||
PRIO_DEFAULT = 20
|
||||
|
|
@ -285,9 +285,9 @@ PRIO_DEFAULT = 20
|
|||
DEFAULT_REQUEST_TIMEOUT = 60 * 60 * 12
|
||||
DEFAULT_AUTH_TIMEOUT = 60
|
||||
|
||||
## BEGIN kojikamid dup
|
||||
# BEGIN kojikamid dup #
|
||||
|
||||
#Exceptions
|
||||
# Exceptions
|
||||
PythonImportError = ImportError # will be masked by koji's one
|
||||
|
||||
class GenericError(Exception):
|
||||
|
|
@ -302,7 +302,7 @@ class GenericError(Exception):
|
|||
return str(self.args[0])
|
||||
except:
|
||||
return str(self.__dict__)
|
||||
## END kojikamid dup
|
||||
# END kojikamid dup #
|
||||
|
||||
class LockError(GenericError):
|
||||
"""Raised when there is a lock conflict"""
|
||||
|
|
@ -320,12 +320,12 @@ class ActionNotAllowed(GenericError):
|
|||
"""Raised when the session does not have permission to take some action"""
|
||||
faultCode = 1004
|
||||
|
||||
## BEGIN kojikamid dup
|
||||
# BEGIN kojikamid dup #
|
||||
|
||||
class BuildError(GenericError):
|
||||
"""Raised when a build fails"""
|
||||
faultCode = 1005
|
||||
## END kojikamid dup
|
||||
# END kojikamid dup #
|
||||
|
||||
class AuthLockError(AuthError):
|
||||
"""Raised when a lock prevents authentication"""
|
||||
|
|
@ -403,7 +403,7 @@ class MultiCallInProgress(object):
|
|||
pass
|
||||
|
||||
|
||||
#A function to get create an exception from a fault
|
||||
# A function to get create an exception from a fault
|
||||
def convertFault(fault):
|
||||
"""Convert a fault to the corresponding Exception type, if possible"""
|
||||
code = getattr(fault, 'faultCode', None)
|
||||
|
|
@ -415,7 +415,7 @@ def convertFault(fault):
|
|||
ret = v(fault.faultString)
|
||||
ret.fromFault = True
|
||||
return ret
|
||||
#otherwise...
|
||||
# otherwise...
|
||||
return fault
|
||||
|
||||
def listFaults():
|
||||
|
|
@ -440,7 +440,7 @@ def listFaults():
|
|||
ret.sort(key=lambda x: x['faultCode'])
|
||||
return ret
|
||||
|
||||
#functions for encoding/decoding optional arguments
|
||||
# functions for encoding/decoding optional arguments
|
||||
|
||||
def encode_args(*args, **opts):
|
||||
"""The function encodes optional arguments as regular arguments.
|
||||
|
|
@ -481,10 +481,10 @@ def decode_int(n):
|
|||
"""If n is not an integer, attempt to convert it"""
|
||||
if isinstance(n, six.integer_types):
|
||||
return n
|
||||
#else
|
||||
# else
|
||||
return int(n)
|
||||
|
||||
#commonly used functions
|
||||
# commonly used functions
|
||||
|
||||
def safe_xmlrpc_loads(s):
|
||||
"""Load xmlrpc data from a string, but catch faults"""
|
||||
|
|
@ -493,7 +493,7 @@ def safe_xmlrpc_loads(s):
|
|||
except Fault as f:
|
||||
return f
|
||||
|
||||
## BEGIN kojikamid dup
|
||||
# BEGIN kojikamid dup #
|
||||
|
||||
|
||||
def ensuredir(directory):
|
||||
|
|
@ -528,7 +528,7 @@ def ensuredir(directory):
|
|||
raise
|
||||
return directory
|
||||
|
||||
## END kojikamid dup
|
||||
# END kojikamid dup #
|
||||
|
||||
def daemonize():
|
||||
"""Detach and run in background"""
|
||||
|
|
@ -537,12 +537,12 @@ def daemonize():
|
|||
os._exit(0)
|
||||
os.setsid()
|
||||
signal.signal(signal.SIGHUP, signal.SIG_IGN)
|
||||
#fork again
|
||||
# fork again
|
||||
pid = os.fork()
|
||||
if pid:
|
||||
os._exit(0)
|
||||
os.chdir("/")
|
||||
#redirect stdin/stdout/sterr
|
||||
# redirect stdin/stdout/sterr
|
||||
fd0 = os.open('/dev/null', os.O_RDONLY)
|
||||
fd1 = os.open('/dev/null', os.O_RDWR)
|
||||
fd2 = os.open('/dev/null', os.O_RDWR)
|
||||
|
|
@ -597,7 +597,7 @@ def rpm_hdr_size(f, ofs=None):
|
|||
il = multibyte(data[0:4])
|
||||
dl = multibyte(data[4:8])
|
||||
|
||||
#this is what the section data says the size should be
|
||||
# this is what the section data says the size should be
|
||||
hdrsize = 8 + 16 * il + dl
|
||||
|
||||
# hdrsize rounded up to nearest 8 bytes
|
||||
|
|
@ -624,7 +624,7 @@ class RawHeader(object):
|
|||
self._index()
|
||||
|
||||
def version(self):
|
||||
#fourth byte is the version
|
||||
# fourth byte is the version
|
||||
return _ord(self.header[3])
|
||||
|
||||
def _index(self):
|
||||
|
|
@ -635,7 +635,7 @@ class RawHeader(object):
|
|||
il = multibyte(data[:4])
|
||||
dl = multibyte(data[4:8])
|
||||
|
||||
#read the index (starts at offset 16)
|
||||
# read the index (starts at offset 16)
|
||||
index = {}
|
||||
for i in range(il):
|
||||
entry = []
|
||||
|
|
@ -643,30 +643,31 @@ class RawHeader(object):
|
|||
ofs = 16 + i*16 + j*4
|
||||
data = [_ord(x) for x in self.header[ofs:ofs+4]]
|
||||
entry.append(multibyte(data))
|
||||
#print("Tag: %d, Type: %d, Offset: %x, Count: %d" % tuple(entry))
|
||||
|
||||
# print("Tag: %d, Type: %d, Offset: %x, Count: %d" % tuple(entry))
|
||||
index[entry[0]] = entry
|
||||
self.datalen = dl
|
||||
self.index = index
|
||||
|
||||
def dump(self):
|
||||
print("HEADER DUMP:")
|
||||
#calculate start of store
|
||||
# calculate start of store
|
||||
il = len(self.index)
|
||||
store = 16 + il * 16
|
||||
#print("start is: %d" % start)
|
||||
#print("index length: %d" % il)
|
||||
# print("start is: %d" % start)
|
||||
# print("index length: %d" % il)
|
||||
print("Store at offset %d (%0x)" % (store, store))
|
||||
#sort entries by offset, dtype
|
||||
#also rearrange: tag, dtype, offset, count -> offset, dtype, tag, count
|
||||
# sort entries by offset, dtype
|
||||
# also rearrange: tag, dtype, offset, count -> offset, dtype, tag, count
|
||||
order = sorted([(x[2], x[1], x[0], x[3]) for x in six.itervalues(self.index)])
|
||||
next = store
|
||||
#map some rpmtag codes
|
||||
# map some rpmtag codes
|
||||
tags = {}
|
||||
for name, code in six.iteritems(rpm.__dict__):
|
||||
if name.startswith('RPMTAG_') and isinstance(code, int):
|
||||
tags[code] = name[7:].lower()
|
||||
for entry in order:
|
||||
#tag, dtype, offset, count = entry
|
||||
# tag, dtype, offset, count = entry
|
||||
offset, dtype, tag, count = entry
|
||||
pos = store + offset
|
||||
if next is not None:
|
||||
|
|
@ -679,17 +680,17 @@ class RawHeader(object):
|
|||
print("Tag: %d [%s], Type: %d, Offset: %x, Count: %d" \
|
||||
% (tag, tags.get(tag, '?'), dtype, offset, count))
|
||||
if dtype == 0:
|
||||
#null
|
||||
# null
|
||||
print("[NULL entry]")
|
||||
next = pos
|
||||
elif dtype == 1:
|
||||
#char
|
||||
# char
|
||||
for i in range(count):
|
||||
print("Char: %r" % self.header[pos])
|
||||
pos += 1
|
||||
next = pos
|
||||
elif dtype >= 2 and dtype <= 5:
|
||||
#integer
|
||||
# integer
|
||||
n = 1 << (dtype - 2)
|
||||
for i in range(count):
|
||||
data = [_ord(x) for x in self.header[pos:pos+n]]
|
||||
|
|
@ -738,7 +739,7 @@ class RawHeader(object):
|
|||
return self._getitem(dtype, offset, count)
|
||||
|
||||
def _getitem(self, dtype, offset, count):
|
||||
#calculate start of store
|
||||
# calculate start of store
|
||||
il = len(self.index)
|
||||
store = 16 + il * 16
|
||||
pos = store + offset
|
||||
|
|
@ -752,10 +753,10 @@ class RawHeader(object):
|
|||
end = self.header.find('\0', pos)
|
||||
return self.header[pos:end]
|
||||
elif dtype == 7:
|
||||
#raw data
|
||||
# raw data
|
||||
return self.header[pos:pos+count]
|
||||
else:
|
||||
#XXX - not all valid data types are handled
|
||||
# XXX - not all valid data types are handled
|
||||
raise GenericError("Unable to read header data type: %x" % dtype)
|
||||
|
||||
def get(self, key, default=None):
|
||||
|
|
@ -1108,7 +1109,7 @@ def is_debuginfo(name):
|
|||
|
||||
def canonArch(arch):
|
||||
"""Given an arch, return the "canonical" arch"""
|
||||
#XXX - this could stand to be smarter, and we should probably
|
||||
# XXX - this could stand to be smarter, and we should probably
|
||||
# have some other related arch-mangling functions.
|
||||
if fnmatch(arch, 'i?86') or arch == 'athlon':
|
||||
return 'i386'
|
||||
|
|
@ -1295,12 +1296,12 @@ BuildArch: noarch
|
|||
|
||||
#package requirements
|
||||
"""]
|
||||
#add a requires entry for all the packages in buildgroup, and in
|
||||
#groups required by buildgroup
|
||||
# add a requires entry for all the packages in buildgroup, and in
|
||||
# groups required by buildgroup
|
||||
need = [buildgroup]
|
||||
seen_grp = {}
|
||||
seen_pkg = {}
|
||||
#index groups
|
||||
# index groups
|
||||
groups = dict([(g['name'], g) for g in grplist])
|
||||
for group_name in need:
|
||||
if group_name in seen_grp:
|
||||
|
|
@ -1375,7 +1376,7 @@ def generate_comps(groups, expand_groups=False):
|
|||
""" <biarchonly>%s</biarchonly>
|
||||
""" % boolean_text(True))
|
||||
|
||||
#print grouplist, if any
|
||||
# print grouplist, if any
|
||||
if g['grouplist'] and not expand_groups:
|
||||
data.append(
|
||||
""" <grouplist>
|
||||
|
|
@ -1383,7 +1384,7 @@ def generate_comps(groups, expand_groups=False):
|
|||
grouplist = list(g['grouplist'])
|
||||
grouplist.sort(key=lambda x: x['name'])
|
||||
for x in grouplist:
|
||||
#['req_id','type','is_metapkg','name']
|
||||
# ['req_id','type','is_metapkg','name']
|
||||
name = x['name']
|
||||
thetype = x['type']
|
||||
tag = "groupreq"
|
||||
|
|
@ -1401,9 +1402,9 @@ def generate_comps(groups, expand_groups=False):
|
|||
""" </grouplist>
|
||||
""")
|
||||
|
||||
#print packagelist, if any
|
||||
# print packagelist, if any
|
||||
def package_entry(pkg):
|
||||
#p['package_id','type','basearchonly','requires','name']
|
||||
# p['package_id','type','basearchonly','requires','name']
|
||||
name = pkg['package']
|
||||
opts = 'type="%s"' % pkg['type']
|
||||
if pkg['basearchonly']:
|
||||
|
|
@ -1424,7 +1425,7 @@ def generate_comps(groups, expand_groups=False):
|
|||
""" % package_entry(p))
|
||||
# also include expanded list, if needed
|
||||
if expand_groups and g['grouplist']:
|
||||
#add a requires entry for all packages in groups required by buildgroup
|
||||
# add a requires entry for all packages in groups required by buildgroup
|
||||
need = [req['name'] for req in g['grouplist']]
|
||||
seen_grp = {g['name'] : 1}
|
||||
seen_pkg = {}
|
||||
|
|
@ -1484,12 +1485,12 @@ def genMockConfig(name, arch, managed=False, repoid=None, tag_name=None, **opts)
|
|||
raise GenericError("please provide a repo and tag")
|
||||
topurls = opts.get('topurls')
|
||||
if not topurls:
|
||||
#cli command still passes plain topurl
|
||||
# cli command still passes plain topurl
|
||||
topurl = opts.get('topurl')
|
||||
if topurl:
|
||||
topurls = [topurl]
|
||||
if topurls:
|
||||
#XXX - PathInfo isn't quite right for this, but it will do for now
|
||||
# XXX - PathInfo isn't quite right for this, but it will do for now
|
||||
pathinfos = [PathInfo(topdir=_u) for _u in topurls]
|
||||
urls = ["%s/%s" % (_p.repo(repoid, tag_name), arch) for _p in pathinfos]
|
||||
else:
|
||||
|
|
@ -1539,7 +1540,7 @@ def genMockConfig(name, arch, managed=False, repoid=None, tag_name=None, **opts)
|
|||
if mavenrc:
|
||||
files['etc/mavenrc'] = mavenrc
|
||||
|
||||
#generate yum.conf
|
||||
# generate yum.conf
|
||||
yc_parts = ["[main]\n"]
|
||||
# HTTP proxy for yum
|
||||
if opts.get('yum_proxy'):
|
||||
|
|
@ -1780,7 +1781,7 @@ def read_config(profile_name, user_config=None):
|
|||
|
||||
result = config_defaults.copy()
|
||||
|
||||
#note: later config files override earlier ones
|
||||
# note: later config files override earlier ones
|
||||
|
||||
# /etc/koji.conf.d
|
||||
configs = ['/etc/koji.conf.d']
|
||||
|
|
@ -1807,9 +1808,9 @@ def read_config(profile_name, user_config=None):
|
|||
got_conf = True
|
||||
result['profile'] = profile_name
|
||||
for name, value in config.items(profile_name):
|
||||
#note the config_defaults dictionary also serves to indicate which
|
||||
#options *can* be set via the config file. Such options should
|
||||
#not have a default value set in the option parser.
|
||||
# note the config_defaults dictionary also serves to indicate which
|
||||
# options *can* be set via the config file. Such options should
|
||||
# not have a default value set in the option parser.
|
||||
if name in result:
|
||||
if name in ('anon_retry', 'offline_retry',
|
||||
'use_fast_upload', 'krb_rdns', 'debug',
|
||||
|
|
@ -1984,7 +1985,7 @@ class PathInfo(object):
|
|||
def volumedir(self, volume):
|
||||
if volume == 'DEFAULT' or volume is None:
|
||||
return self.topdir
|
||||
#else
|
||||
# else
|
||||
return self.topdir + ("/vol/%s" % volume)
|
||||
|
||||
def build(self, build):
|
||||
|
|
@ -2141,7 +2142,7 @@ def is_cert_error(e):
|
|||
'certificate expired' in ssl_reason):
|
||||
return True
|
||||
|
||||
#otherwise
|
||||
# otherwise
|
||||
return False
|
||||
|
||||
|
||||
|
|
@ -2553,7 +2554,7 @@ class ClientSession(object):
|
|||
handler, headers, request = self._prepCall('logout', ())
|
||||
self._sendCall(handler, headers, request)
|
||||
except AuthExpired:
|
||||
#this can happen when an exclusive session is forced
|
||||
# this can happen when an exclusive session is forced
|
||||
pass
|
||||
self.setSession(None)
|
||||
|
||||
|
|
@ -2578,10 +2579,10 @@ class ClientSession(object):
|
|||
return
|
||||
self.setSession(None)
|
||||
|
||||
#we've had some trouble with this method causing strange problems
|
||||
#(like infinite recursion). Possibly triggered by initialization failure,
|
||||
#and possibly due to some interaction with __getattr__.
|
||||
#Re-enabling with a small improvement
|
||||
# we've had some trouble with this method causing strange problems
|
||||
# (like infinite recursion). Possibly triggered by initialization failure,
|
||||
# and possibly due to some interaction with __getattr__.
|
||||
# Re-enabling with a small improvement
|
||||
def __del__(self):
|
||||
if self.__dict__:
|
||||
try:
|
||||
|
|
@ -2594,7 +2595,7 @@ class ClientSession(object):
|
|||
return self._callMethod(name, args, opts)
|
||||
|
||||
def _prepCall(self, name, args, kwargs=None):
|
||||
#pass named opts in a way the server can understand
|
||||
# pass named opts in a way the server can understand
|
||||
if kwargs is None:
|
||||
kwargs = {}
|
||||
if name == 'rawUpload':
|
||||
|
|
@ -2713,27 +2714,27 @@ class ClientSession(object):
|
|||
self.retries += 1
|
||||
try:
|
||||
return self._sendCall(handler, headers, request)
|
||||
#basically, we want to retry on most errors, with a few exceptions
|
||||
# basically, we want to retry on most errors, with a few exceptions
|
||||
# - faults (this means the call completed and failed)
|
||||
# - SystemExit, KeyboardInterrupt
|
||||
# note that, for logged-in sessions the server should tell us (via a RetryError fault)
|
||||
# if the call cannot be retried. For non-logged-in sessions, all calls should be read-only
|
||||
# and hence retryable.
|
||||
except Fault as fault:
|
||||
#try to convert the fault to a known exception
|
||||
# try to convert the fault to a known exception
|
||||
err = convertFault(fault)
|
||||
if isinstance(err, ServerOffline):
|
||||
if self.opts.get('offline_retry', False):
|
||||
secs = self.opts.get('offline_retry_interval', interval)
|
||||
self.logger.debug("Server offline. Retrying in %i seconds", secs)
|
||||
time.sleep(secs)
|
||||
#reset try count - this isn't a typical error, this is a running server
|
||||
#correctly reporting an outage
|
||||
# reset try count - this isn't a typical error, this is a running server
|
||||
# correctly reporting an outage
|
||||
tries = 0
|
||||
continue
|
||||
raise err
|
||||
except (SystemExit, KeyboardInterrupt):
|
||||
#(depending on the python version, these may or may not be subclasses of Exception)
|
||||
# (depending on the python version, these may or may not be subclasses of Exception)
|
||||
raise
|
||||
except Exception as e:
|
||||
tb_str = ''.join(traceback.format_exception(*sys.exc_info()))
|
||||
|
|
@ -2744,8 +2745,8 @@ class ClientSession(object):
|
|||
raise
|
||||
|
||||
if not self.logged_in:
|
||||
#in the past, non-logged-in sessions did not retry. For compatibility purposes
|
||||
#this behavior is governed by the anon_retry opt.
|
||||
# in the past, non-logged-in sessions did not retry. For compatibility purposes
|
||||
# this behavior is governed by the anon_retry opt.
|
||||
if not self.opts.get('anon_retry', False):
|
||||
raise
|
||||
|
||||
|
|
@ -2754,14 +2755,14 @@ class ClientSession(object):
|
|||
|
||||
if tries > max_retries:
|
||||
raise
|
||||
#otherwise keep retrying
|
||||
# otherwise keep retrying
|
||||
if self.logger.isEnabledFor(logging.DEBUG):
|
||||
self.logger.debug(tb_str)
|
||||
self.logger.info("Try #%s for call %s (%s) failed: %s", tries, self.callnum, name, e)
|
||||
if tries > 1:
|
||||
# first retry is immediate, after that we honor retry_interval
|
||||
time.sleep(interval)
|
||||
#not reached
|
||||
# not reached
|
||||
|
||||
def multiCall(self, strict=False, batch=None):
|
||||
"""Execute a prepared multicall
|
||||
|
|
@ -2816,7 +2817,7 @@ class ClientSession(object):
|
|||
else:
|
||||
ret = self._callMethod('multiCall', (calls,), {})
|
||||
if strict:
|
||||
#check for faults and raise first one
|
||||
# check for faults and raise first one
|
||||
for entry in ret:
|
||||
if isinstance(entry, dict):
|
||||
fault = Fault(entry['faultCode'], entry['faultString'])
|
||||
|
|
@ -2825,7 +2826,7 @@ class ClientSession(object):
|
|||
return ret
|
||||
|
||||
def __getattr__(self, name):
|
||||
#if name[:1] == '_':
|
||||
# if name[:1] == '_':
|
||||
# raise AttributeError("no attribute %r" % name)
|
||||
if name == '_apidoc':
|
||||
return self.__dict__['_apidoc']
|
||||
|
|
@ -2953,7 +2954,7 @@ class ClientSession(object):
|
|||
start = time.time()
|
||||
# XXX - stick in a config or something
|
||||
retries = 3
|
||||
fo = open(localfile, "rb") #specify bufsize?
|
||||
fo = open(localfile, "rb") # specify bufsize?
|
||||
totalsize = os.path.getsize(localfile)
|
||||
ofs = 0
|
||||
md5sum = hashlib.md5()
|
||||
|
|
@ -3207,15 +3208,15 @@ class DBHandler(logging.Handler):
|
|||
columns.append(key)
|
||||
values.append("%%(%s)s" % key)
|
||||
data[key] = value % record.__dict__
|
||||
#values.append(_quote(value % record.__dict__))
|
||||
# values.append(_quote(value % record.__dict__))
|
||||
columns = ",".join(columns)
|
||||
values = ",".join(values)
|
||||
command = "INSERT INTO %s (%s) VALUES (%s)" % (self.table, columns, values)
|
||||
#note we're letting cursor.execute do the escaping
|
||||
# note we're letting cursor.execute do the escaping
|
||||
cursor.execute(command, data)
|
||||
cursor.close()
|
||||
#self.cnx.commit()
|
||||
#XXX - committing here is most likely wrong, but we need to set commit_pending or something
|
||||
# self.cnx.commit()
|
||||
# XXX - committing here is most likely wrong, but we need to set commit_pending or something
|
||||
# ...and this is really the wrong place for that
|
||||
except:
|
||||
self.handleError(record)
|
||||
|
|
@ -3328,7 +3329,7 @@ def _taskLabel(taskInfo):
|
|||
extra = build_target['name']
|
||||
elif method == 'winbuild':
|
||||
if 'request' in taskInfo:
|
||||
#vm = taskInfo['request'][0]
|
||||
# vm = taskInfo['request'][0]
|
||||
url = taskInfo['request'][1]
|
||||
target = taskInfo['request'][2]
|
||||
module_info = _module_info(url)
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ arches = {
|
|||
"amd64": "x86_64",
|
||||
"ia32e": "x86_64",
|
||||
|
||||
#ppc64le
|
||||
# ppc64le
|
||||
"ppc64le": "noarch",
|
||||
|
||||
# ppc
|
||||
|
|
@ -73,7 +73,7 @@ arches = {
|
|||
"armv5tejl": "armv5tel",
|
||||
"armv5tel": "noarch",
|
||||
|
||||
#arm hardware floating point
|
||||
# arm hardware floating point
|
||||
"armv7hnl": "armv7hl",
|
||||
"armv7hl": "armv6hl",
|
||||
"armv6hl": "noarch",
|
||||
|
|
@ -86,7 +86,7 @@ arches = {
|
|||
"sh4": "noarch",
|
||||
"sh3": "noarch",
|
||||
|
||||
#itanium
|
||||
# itanium
|
||||
"ia64": "noarch",
|
||||
}
|
||||
|
||||
|
|
|
|||
78
koji/auth.py
78
koji/auth.py
|
|
@ -79,7 +79,7 @@ class Session(object):
|
|||
self._perms = None
|
||||
self._groups = None
|
||||
self._host_id = ''
|
||||
#get session data from request
|
||||
# get session data from request
|
||||
if args is None:
|
||||
environ = getattr(context, 'environ', {})
|
||||
args = environ.get('QUERY_STRING', '')
|
||||
|
|
@ -97,7 +97,7 @@ class Session(object):
|
|||
callnum = args['callnum'][0]
|
||||
except:
|
||||
callnum = None
|
||||
#lookup the session
|
||||
# lookup the session
|
||||
c = context.cnx.cursor()
|
||||
fields = {
|
||||
'authtype': 'authtype',
|
||||
|
|
@ -125,10 +125,10 @@ class Session(object):
|
|||
if not row:
|
||||
raise koji.AuthError('Invalid session or bad credentials')
|
||||
session_data = dict(zip(aliases, row))
|
||||
#check for expiration
|
||||
# check for expiration
|
||||
if session_data['expired']:
|
||||
raise koji.AuthExpired('session "%i" has expired' % id)
|
||||
#check for callnum sanity
|
||||
# check for callnum sanity
|
||||
if callnum is not None:
|
||||
try:
|
||||
callnum = int(callnum)
|
||||
|
|
@ -140,14 +140,14 @@ class Session(object):
|
|||
raise koji.SequenceError("%d > %d (session %d)" \
|
||||
% (lastcall, callnum, id))
|
||||
elif lastcall == callnum:
|
||||
#Some explanation:
|
||||
#This function is one of the few that performs its own commit.
|
||||
#However, our storage of the current callnum is /after/ that
|
||||
#commit. This means the the current callnum only gets committed if
|
||||
#a commit happens afterward.
|
||||
#We only schedule a commit for dml operations, so if we find the
|
||||
#callnum in the db then a previous attempt succeeded but failed to
|
||||
#return. Data was changed, so we cannot simply try the call again.
|
||||
# Some explanation:
|
||||
# This function is one of the few that performs its own commit.
|
||||
# However, our storage of the current callnum is /after/ that
|
||||
# commit. This means the the current callnum only gets committed if
|
||||
# a commit happens afterward.
|
||||
# We only schedule a commit for dml operations, so if we find the
|
||||
# callnum in the db then a previous attempt succeeded but failed to
|
||||
# return. Data was changed, so we cannot simply try the call again.
|
||||
method = getattr(context, 'method', 'UNKNOWN')
|
||||
if method not in RetryWhitelist:
|
||||
raise koji.RetryError(
|
||||
|
|
@ -155,7 +155,7 @@ class Session(object):
|
|||
% (callnum, method, id))
|
||||
|
||||
# read user data
|
||||
#historical note:
|
||||
# historical note:
|
||||
# we used to get a row lock here as an attempt to maintain sanity of exclusive
|
||||
# sessions, but it was an imperfect approach and the lock could cause some
|
||||
# performance issues.
|
||||
|
|
@ -166,25 +166,25 @@ class Session(object):
|
|||
|
||||
if user_data['status'] != koji.USER_STATUS['NORMAL']:
|
||||
raise koji.AuthError('logins by %s are not allowed' % user_data['name'])
|
||||
#check for exclusive sessions
|
||||
# check for exclusive sessions
|
||||
if session_data['exclusive']:
|
||||
#we are the exclusive session for this user
|
||||
# we are the exclusive session for this user
|
||||
self.exclusive = True
|
||||
else:
|
||||
#see if an exclusive session exists
|
||||
# see if an exclusive session exists
|
||||
q = """SELECT id FROM sessions WHERE user_id=%(user_id)s
|
||||
AND "exclusive" = TRUE AND expired = FALSE"""
|
||||
#should not return multiple rows (unique constraint)
|
||||
# should not return multiple rows (unique constraint)
|
||||
c.execute(q, session_data)
|
||||
row = c.fetchone()
|
||||
if row:
|
||||
(excl_id,) = row
|
||||
if excl_id == session_data['master']:
|
||||
#(note excl_id cannot be None)
|
||||
#our master session has the lock
|
||||
# (note excl_id cannot be None)
|
||||
# our master session has the lock
|
||||
self.exclusive = True
|
||||
else:
|
||||
#a session unrelated to us has the lock
|
||||
# a session unrelated to us has the lock
|
||||
self.lockerror = "User locked by another session"
|
||||
# we don't enforce here, but rely on the dispatcher to enforce
|
||||
# if appropriate (otherwise it would be impossible to steal
|
||||
|
|
@ -193,11 +193,11 @@ class Session(object):
|
|||
# update timestamp
|
||||
q = """UPDATE sessions SET update_time=NOW() WHERE id = %(id)i"""
|
||||
c.execute(q, locals())
|
||||
#save update time
|
||||
# save update time
|
||||
context.cnx.commit()
|
||||
|
||||
#update callnum (this is deliberately after the commit)
|
||||
#see earlier note near RetryError
|
||||
# update callnum (this is deliberately after the commit)
|
||||
# see earlier note near RetryError
|
||||
if callnum is not None:
|
||||
q = """UPDATE sessions SET callnum=%(callnum)i WHERE id = %(id)i"""
|
||||
c.execute(q, locals())
|
||||
|
|
@ -218,7 +218,7 @@ class Session(object):
|
|||
# grab perm and groups data on the fly
|
||||
if name == 'perms':
|
||||
if self._perms is None:
|
||||
#in a dict for quicker lookup
|
||||
# in a dict for quicker lookup
|
||||
self._perms = dict([[name, 1] for name in get_user_perms(self.user_id)])
|
||||
return self._perms
|
||||
elif name == 'groups':
|
||||
|
|
@ -254,7 +254,7 @@ class Session(object):
|
|||
return override
|
||||
else:
|
||||
hostip = context.environ['REMOTE_ADDR']
|
||||
#XXX - REMOTE_ADDR not promised by wsgi spec
|
||||
# XXX - REMOTE_ADDR not promised by wsgi spec
|
||||
if hostip == '127.0.0.1':
|
||||
hostip = socket.gethostbyname(socket.gethostname())
|
||||
return hostip
|
||||
|
|
@ -294,7 +294,7 @@ class Session(object):
|
|||
|
||||
self.checkLoginAllowed(user_id)
|
||||
|
||||
#create session and return
|
||||
# create session and return
|
||||
sinfo = self.createSession(user_id, hostip, koji.AUTHTYPE_NORMAL)
|
||||
session_id = sinfo['session-id']
|
||||
context.cnx.commit()
|
||||
|
|
@ -386,7 +386,7 @@ class Session(object):
|
|||
# so get the local ip via a different method
|
||||
local_ip = socket.gethostbyname(context.environ['SERVER_NAME'])
|
||||
remote_ip = context.environ['REMOTE_ADDR']
|
||||
#XXX - REMOTE_ADDR not promised by wsgi spec
|
||||
# XXX - REMOTE_ADDR not promised by wsgi spec
|
||||
|
||||
# it appears that calling setports() with *any* value results in authentication
|
||||
# failing with "Incorrect net address", so return 0 (which prevents
|
||||
|
|
@ -466,11 +466,11 @@ class Session(object):
|
|||
if self.master is not None:
|
||||
raise koji.GenericError("subsessions cannot become exclusive")
|
||||
if self.exclusive:
|
||||
#shouldn't happen
|
||||
# shouldn't happen
|
||||
raise koji.GenericError("session is already exclusive")
|
||||
user_id = self.user_id
|
||||
session_id = self.id
|
||||
#acquire a row lock on the user entry
|
||||
# acquire a row lock on the user entry
|
||||
q = """SELECT id FROM users WHERE id=%(user_id)s FOR UPDATE"""
|
||||
c.execute(q, locals())
|
||||
# check that no other sessions for this user are exclusive
|
||||
|
|
@ -481,13 +481,13 @@ class Session(object):
|
|||
row = c.fetchone()
|
||||
if row:
|
||||
if force:
|
||||
#expire the previous exclusive session and try again
|
||||
# expire the previous exclusive session and try again
|
||||
(excl_id,) = row
|
||||
q = """UPDATE sessions SET expired=TRUE,"exclusive"=NULL WHERE id=%(excl_id)s"""
|
||||
c.execute(q, locals())
|
||||
else:
|
||||
raise koji.AuthLockError("Cannot get exclusive session")
|
||||
#mark this session exclusive
|
||||
# mark this session exclusive
|
||||
q = """UPDATE sessions SET "exclusive"=TRUE WHERE id=%(session_id)s"""
|
||||
c.execute(q, locals())
|
||||
context.cnx.commit()
|
||||
|
|
@ -503,12 +503,12 @@ class Session(object):
|
|||
def logout(self):
|
||||
"""expire a login session"""
|
||||
if not self.logged_in:
|
||||
#XXX raise an error?
|
||||
# XXX raise an error?
|
||||
raise koji.AuthError("Not logged in")
|
||||
update = """UPDATE sessions
|
||||
SET expired=TRUE,exclusive=NULL
|
||||
WHERE id = %(id)i OR master = %(id)i"""
|
||||
#note we expire subsessions as well
|
||||
# note we expire subsessions as well
|
||||
c = context.cnx.cursor()
|
||||
c.execute(update, {'id': self.id})
|
||||
context.cnx.commit()
|
||||
|
|
@ -517,7 +517,7 @@ class Session(object):
|
|||
def logoutChild(self, session_id):
|
||||
"""expire a subsession"""
|
||||
if not self.logged_in:
|
||||
#XXX raise an error?
|
||||
# XXX raise an error?
|
||||
raise koji.AuthError("Not logged in")
|
||||
update = """UPDATE sessions
|
||||
SET expired=TRUE,exclusive=NULL
|
||||
|
|
@ -547,7 +547,7 @@ class Session(object):
|
|||
(session_id,) = c.fetchone()
|
||||
|
||||
|
||||
#add session id to database
|
||||
# add session id to database
|
||||
q = """
|
||||
INSERT INTO sessions (id, user_id, key, hostip, authtype, master)
|
||||
VALUES (%(session_id)i, %(user_id)i, %(key)s, %(hostip)s, %(authtype)i, %(master)s)
|
||||
|
|
@ -555,7 +555,7 @@ class Session(object):
|
|||
c.execute(q, locals())
|
||||
context.cnx.commit()
|
||||
|
||||
#return session info
|
||||
# return session info
|
||||
return {'session-id' : session_id, 'session-key' : key}
|
||||
|
||||
def subsession(self):
|
||||
|
|
@ -589,7 +589,7 @@ class Session(object):
|
|||
def hasGroup(self, group_id):
|
||||
if not self.logged_in:
|
||||
return False
|
||||
#groups indexed by id
|
||||
# groups indexed by id
|
||||
return group_id in self.groups
|
||||
|
||||
def isUser(self, user_id):
|
||||
|
|
@ -616,7 +616,7 @@ class Session(object):
|
|||
return None
|
||||
|
||||
def getHostId(self):
|
||||
#for compatibility
|
||||
# for compatibility
|
||||
return self.host_id
|
||||
|
||||
def getUserId(self, username):
|
||||
|
|
@ -805,7 +805,7 @@ def get_user_perms(user_id):
|
|||
FROM user_perms JOIN permissions ON perm_id = permissions.id
|
||||
WHERE active = TRUE AND user_id=%(user_id)s"""
|
||||
c.execute(q, locals())
|
||||
#return a list of permissions by name
|
||||
# return a list of permissions by name
|
||||
return [row[0] for row in c.fetchall()]
|
||||
|
||||
def get_user_data(user_id):
|
||||
|
|
|
|||
|
|
@ -171,7 +171,7 @@ def log_output(session, path, args, outfile, uploadpath, cwd=None, logerror=0, a
|
|||
return status[1]
|
||||
|
||||
|
||||
## BEGIN kojikamid dup
|
||||
# BEGIN kojikamid dup #
|
||||
|
||||
class SCM(object):
|
||||
"SCM abstraction class"
|
||||
|
|
@ -397,7 +397,7 @@ class SCM(object):
|
|||
env = None
|
||||
def _run(cmd, chdir=None, fatal=False, log=True, _count=[0]):
|
||||
if globals().get('KOJIKAMID'):
|
||||
#we've been inserted into kojikamid, use its run()
|
||||
# we've been inserted into kojikamid, use its run()
|
||||
return run(cmd, chdir=chdir, fatal=fatal, log=log) # noqa: F821
|
||||
else:
|
||||
append = (_count[0] > 0)
|
||||
|
|
@ -546,7 +546,7 @@ class SCM(object):
|
|||
# just use the same url
|
||||
r['source'] = self.url
|
||||
return r
|
||||
## END kojikamid dup
|
||||
# END kojikamid dup #
|
||||
|
||||
|
||||
class TaskManager(object):
|
||||
|
|
@ -613,7 +613,7 @@ class TaskManager(object):
|
|||
|
||||
If nolocal is True, do not try to scan local buildroots.
|
||||
"""
|
||||
#query buildroots in db that are not expired
|
||||
# query buildroots in db that are not expired
|
||||
states = [koji.BR_STATES[x] for x in ('INIT', 'WAITING', 'BUILDING')]
|
||||
db_br = self.session.listBuildroots(hostID=self.host_id, state=tuple(states))
|
||||
# index by id
|
||||
|
|
@ -627,8 +627,8 @@ class TaskManager(object):
|
|||
self.logger.warn("Expiring taskless buildroot: %(id)i/%(tag_name)s/%(arch)s" % br)
|
||||
self.session.host.setBuildRootState(id, st_expired)
|
||||
elif task_id not in self.tasks:
|
||||
#task not running - expire the buildroot
|
||||
#TODO - consider recycling hooks here (with strong sanity checks)
|
||||
# task not running - expire the buildroot
|
||||
# TODO - consider recycling hooks here (with strong sanity checks)
|
||||
self.logger.info("Expiring buildroot: %(id)i/%(tag_name)s/%(arch)s" % br)
|
||||
self.logger.debug("Buildroot task: %r, Current tasks: %r" % (task_id, to_list(self.tasks.keys())))
|
||||
self.session.host.setBuildRootState(id, st_expired)
|
||||
|
|
@ -640,13 +640,13 @@ class TaskManager(object):
|
|||
local_only = [id for id in local_br if id not in db_br]
|
||||
if local_only:
|
||||
missed_br = self.session.listBuildroots(buildrootID=tuple(local_only))
|
||||
#get all the task info in one call
|
||||
# get all the task info in one call
|
||||
tasks = []
|
||||
for br in missed_br:
|
||||
task_id = br['task_id']
|
||||
if task_id:
|
||||
tasks.append(task_id)
|
||||
#index
|
||||
# index
|
||||
missed_br = dict([(row['id'], row) for row in missed_br])
|
||||
tasks = dict([(row['id'], row) for row in self.session.getTaskInfo(tasks)])
|
||||
for id in local_only:
|
||||
|
|
@ -671,7 +671,7 @@ class TaskManager(object):
|
|||
self.logger.warn("%s: invalid task %s" % (desc, br['task_id']))
|
||||
continue
|
||||
if (task['state'] == koji.TASK_STATES['FAILED'] and age < self.options.failed_buildroot_lifetime):
|
||||
#XXX - this could be smarter
|
||||
# XXX - this could be smarter
|
||||
# keep buildroots for failed tasks around for a little while
|
||||
self.logger.debug("Keeping failed buildroot: %s" % desc)
|
||||
continue
|
||||
|
|
@ -689,17 +689,17 @@ class TaskManager(object):
|
|||
continue
|
||||
else:
|
||||
age = min(age, time.time() - st.st_mtime)
|
||||
#note: https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=192153)
|
||||
#If rpmlib is installing in this chroot, removing it entirely
|
||||
#can lead to a world of hurt.
|
||||
#We remove the rootdir contents but leave the rootdir unless it
|
||||
#is really old
|
||||
# note: https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=192153)
|
||||
# If rpmlib is installing in this chroot, removing it entirely
|
||||
# can lead to a world of hurt.
|
||||
# We remove the rootdir contents but leave the rootdir unless it
|
||||
# is really old
|
||||
if age > 3600*24:
|
||||
#dir untouched for a day
|
||||
# dir untouched for a day
|
||||
self.logger.info("Removing buildroot: %s" % desc)
|
||||
if topdir and safe_rmtree(topdir, unmount=True, strict=False) != 0:
|
||||
continue
|
||||
#also remove the config
|
||||
# also remove the config
|
||||
try:
|
||||
os.unlink(data['cfg'])
|
||||
except OSError as e:
|
||||
|
|
@ -726,7 +726,7 @@ class TaskManager(object):
|
|||
self.logger.debug("Expired/stray buildroots: %d" % len(local_only))
|
||||
|
||||
def _scanLocalBuildroots(self):
|
||||
#XXX
|
||||
# XXX
|
||||
configdir = '/etc/mock/koji'
|
||||
buildroots = {}
|
||||
for f in os.listdir(configdir):
|
||||
|
|
@ -785,13 +785,13 @@ class TaskManager(object):
|
|||
# by this host.
|
||||
id = task['id']
|
||||
if id not in self.pids:
|
||||
#We don't have a process for this
|
||||
#Expected to happen after a restart, otherwise this is an error
|
||||
# We don't have a process for this
|
||||
# Expected to happen after a restart, otherwise this is an error
|
||||
stale.append(id)
|
||||
continue
|
||||
tasks[id] = task
|
||||
if task.get('alert', False):
|
||||
#wake up the process
|
||||
# wake up the process
|
||||
self.logger.info("Waking up task: %r" % task)
|
||||
os.kill(self.pids[id], signal.SIGUSR2)
|
||||
if not task['waiting']:
|
||||
|
|
@ -801,8 +801,8 @@ class TaskManager(object):
|
|||
self.tasks = tasks
|
||||
self.logger.debug("Current tasks: %r" % self.tasks)
|
||||
if len(stale) > 0:
|
||||
#A stale task is one which is opened to us, but we know nothing
|
||||
#about). This will happen after a daemon restart, for example.
|
||||
# A stale task is one which is opened to us, but we know nothing
|
||||
# about). This will happen after a daemon restart, for example.
|
||||
self.logger.info("freeing stale tasks: %r" % stale)
|
||||
self.session.host.freeTasks(stale)
|
||||
for id, pid in list(self.pids.items()):
|
||||
|
|
@ -844,15 +844,15 @@ class TaskManager(object):
|
|||
self.logger.debug("Load Data:")
|
||||
self.logger.debug(" hosts: %r" % hosts)
|
||||
self.logger.debug(" tasks: %r" % tasks)
|
||||
#now we organize this data into channel-arch bins
|
||||
# now we organize this data into channel-arch bins
|
||||
bin_hosts = {} #hosts indexed by bin
|
||||
bins = {} #bins for this host
|
||||
our_avail = None
|
||||
for host in hosts:
|
||||
host['bins'] = []
|
||||
if host['id'] == self.host_id:
|
||||
#note: task_load reported by server might differ from what we
|
||||
#sent due to precision variation
|
||||
# note: task_load reported by server might differ from what we
|
||||
# sent due to precision variation
|
||||
our_avail = host['capacity'] - host['task_load']
|
||||
for chan in host['channels']:
|
||||
for arch in host['arches'].split() + ['noarch']:
|
||||
|
|
@ -867,7 +867,7 @@ class TaskManager(object):
|
|||
elif not bins:
|
||||
self.logger.info("No bins for this host. Missing channel/arch config?")
|
||||
# Note: we may still take an assigned task below
|
||||
#sort available capacities for each of our bins
|
||||
# sort available capacities for each of our bins
|
||||
avail = {}
|
||||
for bin in bins:
|
||||
avail[bin] = [host['capacity'] - host['task_load'] for host in bin_hosts[bin]]
|
||||
|
|
@ -889,7 +889,7 @@ class TaskManager(object):
|
|||
if task['state'] == koji.TASK_STATES['ASSIGNED']:
|
||||
self.logger.debug("task is assigned")
|
||||
if self.host_id == task['host_id']:
|
||||
#assigned to us, we can take it regardless
|
||||
# assigned to us, we can take it regardless
|
||||
if self.takeTask(task):
|
||||
return True
|
||||
elif task['state'] == koji.TASK_STATES['FREE']:
|
||||
|
|
@ -897,18 +897,18 @@ class TaskManager(object):
|
|||
self.logger.debug("task is free, bin=%r" % bin)
|
||||
if bin not in bins:
|
||||
continue
|
||||
#see where our available capacity is compared to other hosts for this bin
|
||||
#(note: the hosts in this bin are exactly those that could
|
||||
#accept this task)
|
||||
# see where our available capacity is compared to other hosts for this bin
|
||||
# (note: the hosts in this bin are exactly those that could
|
||||
# accept this task)
|
||||
bin_avail = avail.get(bin, [0])
|
||||
if self.checkAvailDelay(task, bin_avail, our_avail):
|
||||
# decline for now and give the upper half a chance
|
||||
continue
|
||||
#otherwise, we attempt to open the task
|
||||
# otherwise, we attempt to open the task
|
||||
if self.takeTask(task):
|
||||
return True
|
||||
else:
|
||||
#should not happen
|
||||
# should not happen
|
||||
raise Exception("Invalid task state reported by server")
|
||||
return False
|
||||
|
||||
|
|
@ -968,11 +968,11 @@ class TaskManager(object):
|
|||
try:
|
||||
(childpid, status) = os.waitpid(pid, os.WNOHANG)
|
||||
except OSError as e:
|
||||
#check errno
|
||||
# check errno
|
||||
if e.errno != errno.ECHILD:
|
||||
#should not happen
|
||||
# should not happen
|
||||
raise
|
||||
#otherwise assume the process is gone
|
||||
# otherwise assume the process is gone
|
||||
self.logger.info("%s: %s" % (prefix, e))
|
||||
return True
|
||||
if childpid != 0:
|
||||
|
|
@ -1118,7 +1118,7 @@ class TaskManager(object):
|
|||
if children:
|
||||
self._killChildren(task_id, children, sig=signal.SIGKILL, timeout=3.0)
|
||||
|
||||
#expire the task's subsession
|
||||
# expire the task's subsession
|
||||
session_id = self.subsessions.get(task_id)
|
||||
if session_id:
|
||||
self.logger.info("Expiring subsession %i (task %i)" % (session_id, task_id))
|
||||
|
|
@ -1126,7 +1126,7 @@ class TaskManager(object):
|
|||
self.session.logoutChild(session_id)
|
||||
del self.subsessions[task_id]
|
||||
except:
|
||||
#not much we can do about it
|
||||
# not much we can do about it
|
||||
pass
|
||||
if wait:
|
||||
return self._waitTask(task_id, pid)
|
||||
|
|
@ -1200,7 +1200,7 @@ class TaskManager(object):
|
|||
self.status = "Load average %.2f > %.2f" % (loadavgs[0], maxload)
|
||||
self.logger.info(self.status)
|
||||
return False
|
||||
#XXX - add more checks
|
||||
# XXX - add more checks
|
||||
return True
|
||||
|
||||
def takeTask(self, task):
|
||||
|
|
@ -1250,7 +1250,7 @@ class TaskManager(object):
|
|||
if state != 'OPEN':
|
||||
self.logger.warn("Task %i changed is %s", task_id, state)
|
||||
return False
|
||||
#otherwise...
|
||||
# otherwise...
|
||||
raise
|
||||
if handler.Foreground:
|
||||
self.logger.info("running task in foreground")
|
||||
|
|
@ -1263,27 +1263,27 @@ class TaskManager(object):
|
|||
return True
|
||||
|
||||
def forkTask(self, handler):
|
||||
#get the subsession before we fork
|
||||
# get the subsession before we fork
|
||||
newhub = self.session.subsession()
|
||||
session_id = newhub.sinfo['session-id']
|
||||
pid = os.fork()
|
||||
if pid:
|
||||
newhub._forget()
|
||||
return pid, session_id
|
||||
#in no circumstance should we return after the fork
|
||||
#nor should any exceptions propagate past here
|
||||
# in no circumstance should we return after the fork
|
||||
# nor should any exceptions propagate past here
|
||||
try:
|
||||
self.session._forget()
|
||||
#set process group
|
||||
# set process group
|
||||
os.setpgrp()
|
||||
#use the subsession
|
||||
# use the subsession
|
||||
self.session = newhub
|
||||
handler.session = self.session
|
||||
#set a do-nothing handler for sigusr2
|
||||
# set a do-nothing handler for sigusr2
|
||||
signal.signal(signal.SIGUSR2, lambda *args: None)
|
||||
self.runTask(handler)
|
||||
finally:
|
||||
#diediedie
|
||||
# diediedie
|
||||
try:
|
||||
self.session.logout()
|
||||
finally:
|
||||
|
|
@ -1302,10 +1302,10 @@ class TaskManager(object):
|
|||
tb = ''.join(traceback.format_exception(*sys.exc_info())).replace(r"\n", "\n")
|
||||
self.logger.warn("FAULT:\n%s" % tb)
|
||||
except (SystemExit, koji.tasks.ServerExit, KeyboardInterrupt):
|
||||
#we do not trap these
|
||||
# we do not trap these
|
||||
raise
|
||||
except koji.tasks.ServerRestart:
|
||||
#freeing this task will allow the pending restart to take effect
|
||||
# freeing this task will allow the pending restart to take effect
|
||||
self.session.host.freeTasks([handler.id])
|
||||
return
|
||||
except:
|
||||
|
|
@ -1315,7 +1315,7 @@ class TaskManager(object):
|
|||
e_class, e = sys.exc_info()[:2]
|
||||
faultCode = getattr(e_class, 'faultCode', 1)
|
||||
if issubclass(e_class, koji.GenericError):
|
||||
#just pass it through
|
||||
# just pass it through
|
||||
tb = str(e)
|
||||
response = koji.xmlrpcplus.dumps(koji.xmlrpcplus.Fault(faultCode, tb))
|
||||
|
||||
|
|
|
|||
|
|
@ -75,8 +75,8 @@ class DBWrapper:
|
|||
if not self.cnx:
|
||||
raise Exception('connection is closed')
|
||||
self.cnx.cursor().execute('ROLLBACK')
|
||||
#We do this rather than cnx.rollback to avoid opening a new transaction
|
||||
#If our connection gets recycled cnx.rollback will be called then.
|
||||
# We do this rather than cnx.rollback to avoid opening a new transaction
|
||||
# If our connection gets recycled cnx.rollback will be called then.
|
||||
self.cnx = None
|
||||
|
||||
|
||||
|
|
@ -177,7 +177,7 @@ def connect():
|
|||
return DBWrapper(conn)
|
||||
except psycopg2.Error:
|
||||
del _DBconn.conn
|
||||
#create a fresh connection
|
||||
# create a fresh connection
|
||||
opts = _DBopts
|
||||
if opts is None:
|
||||
opts = {}
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ class PluginTracker(object):
|
|||
|
||||
def __init__(self, path=None, prefix='_koji_plugin__'):
|
||||
self.searchpath = path
|
||||
#prefix should not have a '.' in it, this can cause problems.
|
||||
# prefix should not have a '.' in it, this can cause problems.
|
||||
self.prefix = prefix
|
||||
self.plugins = {}
|
||||
|
||||
|
|
@ -71,9 +71,9 @@ class PluginTracker(object):
|
|||
return self.plugins[name]
|
||||
mod_name = name
|
||||
if self.prefix:
|
||||
#mod_name determines how the module is named in sys.modules
|
||||
#Using a prefix helps prevent overlap with other modules
|
||||
#(no '.' -- it causes problems)
|
||||
# mod_name determines how the module is named in sys.modules
|
||||
# Using a prefix helps prevent overlap with other modules
|
||||
# (no '.' -- it causes problems)
|
||||
mod_name = self.prefix + name
|
||||
if mod_name in sys.modules and not reload:
|
||||
raise koji.PluginError('module name conflict: %s' % mod_name)
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ from koji.util import to_list
|
|||
class BaseSimpleTest(object):
|
||||
"""Abstract base class for simple tests"""
|
||||
|
||||
#Provide the name of the test
|
||||
# Provide the name of the test
|
||||
name = None
|
||||
|
||||
def __init__(self, str):
|
||||
|
|
@ -62,12 +62,12 @@ class FalseTest(BaseSimpleTest):
|
|||
|
||||
class AllTest(TrueTest):
|
||||
name = 'all'
|
||||
#alias for true
|
||||
# alias for true
|
||||
|
||||
|
||||
class NoneTest(FalseTest):
|
||||
name = 'none'
|
||||
#alias for false
|
||||
# alias for false
|
||||
|
||||
|
||||
class HasTest(BaseSimpleTest):
|
||||
|
|
@ -233,11 +233,11 @@ class SimpleRuleSet(object):
|
|||
for line in lines:
|
||||
rule = self.parse_line(line)
|
||||
if rule is None:
|
||||
#blank/etc
|
||||
# blank/etc
|
||||
continue
|
||||
tests, negate, action = rule
|
||||
if action == '{':
|
||||
#nested rules
|
||||
# nested rules
|
||||
child = []
|
||||
cursor.append([tests, negate, child])
|
||||
stack.append(cursor)
|
||||
|
|
@ -275,11 +275,11 @@ class SimpleRuleSet(object):
|
|||
"""
|
||||
line = line.split('#', 1)[0].strip()
|
||||
if not line:
|
||||
#blank or all comment
|
||||
# blank or all comment
|
||||
return None
|
||||
if line == '}':
|
||||
return None, False, '}'
|
||||
#?? allow }} ??
|
||||
# ?? allow }} ??
|
||||
negate = False
|
||||
pos = line.rfind('::')
|
||||
if pos == -1:
|
||||
|
|
@ -328,7 +328,7 @@ class SimpleRuleSet(object):
|
|||
if not check:
|
||||
break
|
||||
else:
|
||||
#all tests in current rule passed
|
||||
# all tests in current rule passed
|
||||
value = True
|
||||
if negate:
|
||||
value = not value
|
||||
|
|
@ -393,11 +393,11 @@ def findSimpleTests(namespace):
|
|||
if isinstance(value, type(BaseSimpleTest)) and issubclass(value, BaseSimpleTest):
|
||||
name = getattr(value, 'name', None)
|
||||
if not name:
|
||||
#use the class name
|
||||
# use the class name
|
||||
name = key
|
||||
#but trim 'Test' from the end
|
||||
# but trim 'Test' from the end
|
||||
if name.endswith('Test') and len(name) > 4:
|
||||
name = name[:-4]
|
||||
ret.setdefault(name, value)
|
||||
#...so first test wins in case of name overlap
|
||||
# ...so first test wins in case of name overlap
|
||||
return ret
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ class Rpmdiff:
|
|||
|
||||
PRCO = ( 'REQUIRES', 'PROVIDES', 'CONFLICTS', 'OBSOLETES')
|
||||
|
||||
#{fname : (size, mode, mtime, flags, dev, inode,
|
||||
# {fname : (size, mode, mtime, flags, dev, inode,
|
||||
# nlink, state, vflags, user, group, digest)}
|
||||
__FILEIDX = [ ['S', 0],
|
||||
['M', 1],
|
||||
|
|
@ -71,7 +71,7 @@ class Rpmdiff:
|
|||
try:
|
||||
PREREQ_FLAG=rpm.RPMSENSE_PREREQ
|
||||
except:
|
||||
#(proyvind): This seems ugly, but then again so does
|
||||
# (proyvind): This seems ugly, but then again so does
|
||||
# this whole check as well.
|
||||
PREREQ_FLAG=False
|
||||
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ def scan_mounts(topdir):
|
|||
logger.warning('Found deleted mountpoint: %s' % path)
|
||||
mplist.append(path)
|
||||
fo.close()
|
||||
#reverse sort so deeper dirs come first
|
||||
# reverse sort so deeper dirs come first
|
||||
mplist.sort(reverse=True)
|
||||
return mplist
|
||||
|
||||
|
|
@ -64,7 +64,7 @@ def umount_all(topdir):
|
|||
rv = os.spawnvp(os.P_WAIT, cmd[0], cmd)
|
||||
if rv != 0:
|
||||
raise koji.GenericError('umount failed (exit code %r) for %s' % (rv, path))
|
||||
#check mounts again
|
||||
# check mounts again
|
||||
remain = scan_mounts(topdir)
|
||||
if remain:
|
||||
raise koji.GenericError("Unmounting incomplete: %r" % remain)
|
||||
|
|
@ -340,7 +340,7 @@ class BaseTaskHandler(object):
|
|||
if self.workdir is None:
|
||||
return
|
||||
safe_rmtree(self.workdir, unmount=False, strict=True)
|
||||
#os.spawnvp(os.P_WAIT, 'rm', ['rm', '-rf', self.workdir])
|
||||
# os.spawnvp(os.P_WAIT, 'rm', ['rm', '-rf', self.workdir])
|
||||
|
||||
def wait(self, subtasks=None, all=False, failany=False, canfail=None,
|
||||
timeout=None):
|
||||
|
|
@ -385,7 +385,7 @@ class BaseTaskHandler(object):
|
|||
while True:
|
||||
finished, unfinished = self.session.host.taskWait(self.id)
|
||||
if len(unfinished) == 0:
|
||||
#all done
|
||||
# all done
|
||||
break
|
||||
elif len(finished) > 0:
|
||||
if all:
|
||||
|
|
@ -561,7 +561,7 @@ class BaseTaskHandler(object):
|
|||
repo_info = self.session.getRepo(tag)
|
||||
taginfo = self.session.getTag(tag, strict=True)
|
||||
if not repo_info:
|
||||
#make sure there is a target
|
||||
# make sure there is a target
|
||||
targets = self.session.getBuildTargets(buildTagID=taginfo['id'])
|
||||
if not targets:
|
||||
raise koji.BuildError('no repo (and no target) for tag %s' % taginfo['name'])
|
||||
|
|
@ -666,7 +666,7 @@ class ShutdownTask(BaseTaskHandler):
|
|||
_taskWeight = 0.0
|
||||
Foreground = True
|
||||
def handler(self):
|
||||
#note: this is a foreground task
|
||||
# note: this is a foreground task
|
||||
raise ServerExit
|
||||
|
||||
|
||||
|
|
@ -677,7 +677,7 @@ class RestartTask(BaseTaskHandler):
|
|||
_taskWeight = 0.1
|
||||
Foreground = True
|
||||
def handler(self, host):
|
||||
#note: this is a foreground task
|
||||
# note: this is a foreground task
|
||||
if host['id'] != self.session.host.getID():
|
||||
raise koji.GenericError("Host mismatch")
|
||||
self.manager.restart_pending = True
|
||||
|
|
@ -691,7 +691,7 @@ class RestartVerifyTask(BaseTaskHandler):
|
|||
_taskWeight = 0.1
|
||||
Foreground = True
|
||||
def handler(self, task_id, host):
|
||||
#note: this is a foreground task
|
||||
# note: this is a foreground task
|
||||
tinfo = self.session.getTaskInfo(task_id)
|
||||
state = koji.TASK_STATES[tinfo['state']]
|
||||
if state != 'CLOSED':
|
||||
|
|
@ -754,7 +754,7 @@ class RestartHostsTask(BaseTaskHandler):
|
|||
class DependantTask(BaseTaskHandler):
|
||||
|
||||
Methods = ['dependantTask']
|
||||
#mostly just waiting on other tasks
|
||||
# mostly just waiting on other tasks
|
||||
_taskWeight = 0.2
|
||||
|
||||
def handler(self, wait_list, task_list):
|
||||
|
|
|
|||
|
|
@ -189,7 +189,7 @@ def dslice(dict_, keys, strict=True):
|
|||
ret = {}
|
||||
for key in keys:
|
||||
if strict or key in dict_:
|
||||
#for strict we skip the has_key check and let the dict generate the KeyError
|
||||
# for strict we skip the has_key check and let the dict generate the KeyError
|
||||
ret[key] = dict_[key]
|
||||
return ret
|
||||
|
||||
|
|
@ -639,13 +639,13 @@ def setup_rlimits(opts, logger=None):
|
|||
|
||||
class adler32_constructor(object):
|
||||
|
||||
#mimicing the hashlib constructors
|
||||
# mimicing the hashlib constructors
|
||||
def __init__(self, arg=''):
|
||||
if six.PY3 and isinstance(arg, str):
|
||||
arg = bytes(arg, 'utf-8')
|
||||
self._value = adler32(arg) & 0xffffffff
|
||||
#the bitwise and works around a bug in some versions of python
|
||||
#see: https://bugs.python.org/issue1202
|
||||
# the bitwise and works around a bug in some versions of python
|
||||
# see: https://bugs.python.org/issue1202
|
||||
|
||||
def update(self, arg):
|
||||
if six.PY3 and isinstance(arg, str):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue