#1088 Fix deprecation warnings from log.warn and inspect.getargspec
Merged 7 months ago by mprahl. Opened 8 months ago by cqi.
cqi/fm-orchestrator fix-warnings  into  master

file modified
+1 -1

@@ -46,7 +46,7 @@ 

  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 @@ 

                  # 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 @@ 

          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 @@ 

                  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 @@ 

                       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 @@ 

          # 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 @@ 

                  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 @@ 

  

  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 @@ 

      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 @@ 

  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 @@ 

                     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 @@ 

  

      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 @@ 

      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 @@ 

      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 @@ 

          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 @@ 

                  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 @@ 

                  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 @@ 

      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 @@ 

                  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,

file modified
+4 -4

@@ -77,7 +77,7 @@ 

          # 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 @@ 

          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 @@ 

          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:

This looks unrelated to this change. Can it be in its own commit? It might be better to also perform this import at the beginning of file.

rebased onto 0c642a0

7 months ago

This looks unrelated to this change. Can it be in its own commit? It might be better to also perform this import at the beginning of file.

@lucarval It is relative. :) This pr is about fixing warnings from log.warn and inspect.getargspec.

Pull-Request has been merged by mprahl

7 months ago