mirror of
https://pagure.io/fm-orchestrator.git
synced 2026-04-05 11:48:33 +08:00
Fix deprecation warnings from log.warn and inspect.getargspec
Signed-off-by: Chenxiong Qi <cqi@redhat.com>
This commit is contained in:
@@ -46,7 +46,7 @@ from module_build_service import app, log, conf
|
||||
try:
|
||||
import ldap3
|
||||
except ImportError:
|
||||
log.warn("ldap3 import not found. ldap/krb disabled.")
|
||||
log.warning("ldap3 import not found. ldap/krb disabled.")
|
||||
|
||||
|
||||
client_secrets = None
|
||||
|
||||
@@ -400,7 +400,7 @@ class KojiContentGenerator(object):
|
||||
# using the yaml without SCM URL. This should never happen
|
||||
# when building production-ready modules using Koji, but in
|
||||
# theory it is possible.
|
||||
log.warn("No modulemd.src.txt found.")
|
||||
log.warning("No modulemd.src.txt found.")
|
||||
return
|
||||
else:
|
||||
raise
|
||||
@@ -710,7 +710,8 @@ class KojiContentGenerator(object):
|
||||
commit = xmd.get("mbs", {}).get("commit")
|
||||
scmurl = xmd.get("mbs", {}).get("scmurl")
|
||||
if not commit or not scmurl:
|
||||
log.warn("%r: xmd['mbs'] does not contain 'commit' or 'scmurl'.", self.module)
|
||||
log.warning("%r: xmd['mbs'] does not contain 'commit' or 'scmurl'.",
|
||||
self.module)
|
||||
return
|
||||
|
||||
td = None
|
||||
@@ -728,7 +729,7 @@ class KojiContentGenerator(object):
|
||||
if td is not None:
|
||||
shutil.rmtree(td)
|
||||
except Exception as e:
|
||||
log.warn(
|
||||
log.warning(
|
||||
"Failed to remove temporary directory {!r}: {}".format(
|
||||
td, str(e)))
|
||||
|
||||
@@ -812,9 +813,9 @@ class KojiContentGenerator(object):
|
||||
self.module, tag)
|
||||
|
||||
if not tag_info:
|
||||
log.warn("%r:, Not tagging Content Generator build, no "
|
||||
"available tag found, tried %r", self.module,
|
||||
tag_names_to_try)
|
||||
log.warning(
|
||||
"%r:, Not tagging Content Generator build, no available tag"
|
||||
" found, tried %r", self.module, tag_names_to_try)
|
||||
return
|
||||
|
||||
build = self._get_build()
|
||||
|
||||
@@ -1105,7 +1105,7 @@ chmod 644 %buildroot/etc/rpm/macros.zz-modules
|
||||
# Get our own userID, so we can limit the builds to only modular builds
|
||||
user_info = koji_session.getLoggedInUser()
|
||||
if not user_info or "id" not in user_info:
|
||||
log.warn("Koji.getLoggedInUser() failed while getting build weight.")
|
||||
log.warning("Koji.getLoggedInUser() failed while getting build weight.")
|
||||
return cls.compute_weights_from_build_time(components)
|
||||
mbs_user_id = user_info["id"]
|
||||
|
||||
|
||||
@@ -415,8 +415,8 @@ class GenericBuilder(six.with_metaclass(ABCMeta)):
|
||||
continue
|
||||
|
||||
if average_time_to_build < 0:
|
||||
log.warn("Negative average build duration for component %s: %s",
|
||||
component, str(average_time_to_build))
|
||||
log.warning("Negative average build duration for component %s: %s",
|
||||
component, str(average_time_to_build))
|
||||
weights[component] = weight
|
||||
continue
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ import logging
|
||||
|
||||
logging.debug("Phasers are set to stun.")
|
||||
logging.info("%s tried to build something", username)
|
||||
logging.warn("%s failed to build", task_id)
|
||||
logging.warning("%s failed to build", task_id)
|
||||
|
||||
"""
|
||||
|
||||
|
||||
@@ -294,12 +294,12 @@ def _in_memory_publish(topic, msg, conf, service):
|
||||
try:
|
||||
work_queue_put(wrapped_msg)
|
||||
except ValueError as e:
|
||||
log.warn("No MBSConsumer found. Shutting down? %r" % e)
|
||||
log.warning("No MBSConsumer found. Shutting down? %r" % e)
|
||||
except AttributeError as e:
|
||||
# In the event that `moksha.hub._hub` hasn't yet been initialized, we
|
||||
# need to store messages on the side until it becomes available.
|
||||
# As a last-ditch effort, try to hang initial messages in the config.
|
||||
log.warn("Hub not initialized. Queueing on the side.")
|
||||
log.warning("Hub not initialized. Queueing on the side.")
|
||||
_initial_messages.append(wrapped_msg)
|
||||
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@ except ImportError:
|
||||
import koji
|
||||
import fedmsg.consumers
|
||||
import moksha.hub
|
||||
import six
|
||||
|
||||
from module_build_service.utils import module_build_state_from_msg
|
||||
import module_build_service.messaging
|
||||
@@ -190,7 +191,10 @@ class MBSConsumer(fedmsg.consumers.FedmsgConsumer):
|
||||
list(self.on_module_change.items()))
|
||||
for key, callback in all_fns:
|
||||
expected = ['config', 'session', 'msg']
|
||||
argspec = inspect.getargspec(callback)[0]
|
||||
if six.PY2:
|
||||
argspec = inspect.getargspec(callback)[0]
|
||||
else:
|
||||
argspec = inspect.getfullargspec(callback)[0]
|
||||
if argspec != expected:
|
||||
raise ValueError("Callback %r, state %r has argspec %r!=%r" % (
|
||||
callback, key, argspec, expected))
|
||||
|
||||
@@ -63,9 +63,9 @@ def failed(config, session, msg):
|
||||
|
||||
module_info = build.json()
|
||||
if module_info['state'] != msg.module_build_state:
|
||||
log.warn("Note that retrieved module state %r "
|
||||
"doesn't match message module state %r" % (
|
||||
module_info['state'], msg.module_build_state))
|
||||
log.warning(
|
||||
"Note that retrieved module state %r doesn't match message module"
|
||||
" state %r", module_info['state'], msg.module_build_state)
|
||||
# This is ok.. it's a race condition we can ignore.
|
||||
pass
|
||||
|
||||
@@ -120,9 +120,9 @@ def done(config, session, msg):
|
||||
build = models.ModuleBuild.from_module_event(session, msg)
|
||||
module_info = build.json()
|
||||
if module_info['state'] != msg.module_build_state:
|
||||
log.warn("Note that retrieved module state %r "
|
||||
"doesn't match message module state %r" % (
|
||||
module_info['state'], msg.module_build_state))
|
||||
log.warning(
|
||||
"Note that retrieved module state %r doesn't match message module"
|
||||
" state %r", module_info['state'], msg.module_build_state)
|
||||
# This is ok.. it's a race condition we can ignore.
|
||||
pass
|
||||
|
||||
@@ -271,9 +271,8 @@ def wait(config, session, msg):
|
||||
log.info("%r", build.modulemd)
|
||||
|
||||
if build.state != msg.module_build_state:
|
||||
log.warn("Note that retrieved module state %r "
|
||||
"doesn't match message module state %r" % (
|
||||
build.state, msg.module_build_state))
|
||||
log.warning("Note that retrieved module state %r doesn't match message"
|
||||
" module state %r", build.state, msg.module_build_state)
|
||||
# This is ok.. it's a race condition we can ignore.
|
||||
pass
|
||||
|
||||
|
||||
@@ -96,7 +96,7 @@ def done(config, session, msg):
|
||||
module_build.transition(config, models.BUILD_STATES['failed'],
|
||||
"Some components failed to build.")
|
||||
session.commit()
|
||||
log.warn("Odd! All components in batch failed for %r." % module_build)
|
||||
log.warning("Odd! All components in batch failed for %r." % module_build)
|
||||
return
|
||||
|
||||
groups = module_build_service.builder.GenericBuilder.default_buildroot_groups(
|
||||
|
||||
@@ -108,11 +108,11 @@ class MBSProducer(PollingProducer):
|
||||
if task_info['state'] == koji.TASK_STATES['CLOSED']:
|
||||
builds = koji_session.listBuilds(taskID=task_id)
|
||||
if not builds:
|
||||
log.warn("Task ID %r is closed, but we found no "
|
||||
"builds in koji." % task_id)
|
||||
log.warning("Task ID %r is closed, but we found no "
|
||||
"builds in koji." % task_id)
|
||||
elif len(builds) > 1:
|
||||
log.warn("Task ID %r is closed, but more than one "
|
||||
"build is present!" % task_id)
|
||||
log.warning("Task ID %r is closed, but more than one "
|
||||
"build is present!" % task_id)
|
||||
else:
|
||||
build_version = builds[0]['version']
|
||||
build_release = builds[0]['release']
|
||||
|
||||
@@ -76,7 +76,7 @@ def retry(timeout=conf.net_timeout, interval=conf.net_retry_interval, wait_on=Ex
|
||||
try:
|
||||
return function(*args, **kwargs)
|
||||
except wait_on as e:
|
||||
log.warn("Exception %r raised from %r. Retry in %rs" % (
|
||||
log.warning("Exception %r raised from %r. Retry in %rs" % (
|
||||
e, function, interval))
|
||||
time.sleep(interval)
|
||||
if (time.time() - start) >= timeout:
|
||||
@@ -215,7 +215,8 @@ def get_rpm_release(module_build):
|
||||
try:
|
||||
buildrequires = module_build.mmd().get_xmd()['mbs']['buildrequires']
|
||||
except (ValueError, KeyError):
|
||||
log.warn('Module build {0} does not have buildrequires in its xmd'.format(module_build.id))
|
||||
log.warning('Module build {0} does not have buildrequires in its xmd'
|
||||
.format(module_build.id))
|
||||
buildrequires = None
|
||||
|
||||
base_module_stream = ''
|
||||
@@ -226,8 +227,8 @@ def get_rpm_release(module_build):
|
||||
base_module_stream += '+'
|
||||
break
|
||||
else:
|
||||
log.warn('Module build {0} does not buildrequire a base module ({1})'
|
||||
.format(module_build.id, ' or '.join(conf.base_module_names)))
|
||||
log.warning('Module build {0} does not buildrequire a base module ({1})'
|
||||
.format(module_build.id, ' or '.join(conf.base_module_names)))
|
||||
|
||||
return '{prefix}{base_module_stream}{index}+{dist_hash}'.format(
|
||||
prefix=conf.default_dist_tag_prefix,
|
||||
|
||||
@@ -77,7 +77,7 @@ class TestLogger:
|
||||
# No log file should be created.
|
||||
log.debug("ignore this test msg")
|
||||
log.info("ignore this test msg")
|
||||
log.warn("ignore this test msg")
|
||||
log.warning("ignore this test msg")
|
||||
log.error("ignore this test msg")
|
||||
self.build_log.stop(build)
|
||||
assert not os.path.exists(path)
|
||||
@@ -89,13 +89,13 @@ class TestLogger:
|
||||
MBSConsumer.current_module_build_id = 1
|
||||
log.debug("ignore this test msg1")
|
||||
log.info("ignore this test msg1")
|
||||
log.warn("ignore this test msg1")
|
||||
log.warning("ignore this test msg1")
|
||||
log.error("ignore this test msg1")
|
||||
|
||||
MBSConsumer.current_module_build_id = 2
|
||||
log.debug("ignore this test msg2")
|
||||
log.info("ignore this test msg2")
|
||||
log.warn("ignore this test msg2")
|
||||
log.warning("ignore this test msg2")
|
||||
log.error("ignore this test msg2")
|
||||
|
||||
self.build_log.stop(build)
|
||||
@@ -111,7 +111,7 @@ class TestLogger:
|
||||
MBSConsumer.current_module_build_id = 2
|
||||
log.debug("ignore this test msg3")
|
||||
log.info("ignore this test msg3")
|
||||
log.warn("ignore this test msg3")
|
||||
log.warning("ignore this test msg3")
|
||||
log.error("ignore this test msg3")
|
||||
self.build_log.stop(build)
|
||||
with open(path, "r") as f:
|
||||
|
||||
Reference in New Issue
Block a user