diff --git a/requirements.txt b/requirements.txt index 1959443b..d0fc5f7a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -11,3 +11,4 @@ Flask-Script Flask-SQLAlchemy Flask-Migrate python-fedora +funcsigs # Python2 only diff --git a/rida/messaging.py b/rida/messaging.py index fa45ee93..f07dc309 100644 --- a/rida/messaging.py +++ b/rida/messaging.py @@ -25,6 +25,11 @@ """Generic messaging functions.""" import re +try: + from inspect import signature +except ImportError: + from funcsigs import signature + from rida import logger @@ -36,6 +41,17 @@ class BaseMessage(object): """ self.msg_id = msg_id + def __repr__(self): + init_sig = signature(self.__init__) + + args_strs = ( + "{}={!r}".format(name, getattr(self, name)) + if param.default != param.empty + else repr(getattr(self, name)) + for name, param in init_sig.parameters.items()) + + return "{}({})".format(type(self).__name__, ', '.join(args_strs)) + @staticmethod def from_fedmsg(topic, msg): """ diff --git a/rida/scheduler/main.py b/rida/scheduler/main.py index 171a9463..47e6558e 100644 --- a/rida/scheduler/main.py +++ b/rida/scheduler/main.py @@ -32,7 +32,6 @@ proper scheduling component builds in the supported build systems. import inspect import operator import os -import pprint import threading import time import six.moves.queue as queue @@ -133,7 +132,7 @@ class MessageWorker(threading.Thread): self.process_message(msg) except Exception: log.exception("Failed while handling %r" % msg.msg_id) - log.info(pprint.pformat(msg)) + log.info(msg) def process_message(self, msg): log.debug('Received a message with an ID of "{0}" and of type "{1}"'