Commit af34e6af authored by Tristan Van Berkom's avatar Tristan Van Berkom
Browse files

_frontend/widget.py: Render core messages more like other messages

In order to test when core activities occur by parsing the stderr
in tests, we should make the messages conform more.

At the same time, this restores alignment of columns in core
messages with the element processing related messages.

Also, _scheduler/scheduler.py is updated to make it's activity names
conform to the (current) 5 character limit for the sake of alignment.

The tests/frontend/logging.py test gets it's regexes updated for
the log lines it checks for in stderr.
parent 7a3f6cbc
Loading
Loading
Loading
Loading
+13 −14
Original line number Diff line number Diff line
@@ -178,26 +178,22 @@ class ElementName(Widget):
    def __init__(self, context, content_profile, format_profile):
        super(ElementName, self).__init__(context, content_profile, format_profile)

        # Pre initialization format string, before we know the length of
        # element names in the pipeline
        self._fmt_string = '{: <30}'

    def render(self, message):
        action_name = message.action_name
        element_id = message.task_id or message.unique_id
        if element_id is None:
            return ""

        if element_id is not None:
            plugin = _plugin_lookup(element_id)
            name = plugin._get_full_name()
            name = '{: <30}'.format(name)
        else:
            name = 'core activity'
            name = '{: <30}'.format(name)

        # Sneak the action name in with the element name
        action_name = message.action_name
        if not action_name:
            action_name = "Main"

        return self.content_profile.fmt("{: >5}".format(action_name.lower())) + \
            self.format_profile.fmt(':') + \
            self.content_profile.fmt(self._fmt_string.format(name))
            self.format_profile.fmt(':') + self.content_profile.fmt(name)


# A widget for displaying the primary message text
@@ -219,9 +215,12 @@ class CacheKey(Widget):
    def render(self, message):

        element_id = message.task_id or message.unique_id
        if element_id is None or not self._key_length:
        if not self._key_length:
            return ""

        if element_id is None:
            return ' ' * self._key_length

        missing = False
        key = ' ' * self._key_length
        plugin = _plugin_lookup(element_id)
+2 −2
Original line number Diff line number Diff line
@@ -40,8 +40,8 @@ class SchedStatus():

# Some action names for the internal jobs we launch
#
_ACTION_NAME_CLEANUP = 'cleanup'
_ACTION_NAME_CACHE_SIZE = 'cache_size'
_ACTION_NAME_CLEANUP = 'clean'
_ACTION_NAME_CACHE_SIZE = 'size'


# Scheduler()
+2 −2
Original line number Diff line number Diff line
@@ -41,7 +41,7 @@ def test_default_logging(cli, tmpdir, datafiles):
    result = cli.run(project=project, args=['source', 'fetch', element_name])
    result.assert_success()

    m = re.search(r"\[\d\d:\d\d:\d\d\]\[\]\[\] SUCCESS Checking sources", result.stderr)
    m = re.search(r"\[\d\d:\d\d:\d\d\]\[\s*\]\[.*\] SUCCESS Checking sources", result.stderr)
    assert(m is not None)


@@ -77,7 +77,7 @@ def test_custom_logging(cli, tmpdir, datafiles):
    result = cli.run(project=project, args=['source', 'fetch', element_name])
    result.assert_success()

    m = re.search(r"\d\d:\d\d:\d\d,\d\d:\d\d:\d\d.\d{6},\d\d:\d\d:\d\d,,,SUCCESS,Checking sources", result.stderr)
    m = re.search(r"\d\d:\d\d:\d\d,\d\d:\d\d:\d\d.\d{6},\d\d:\d\d:\d\d,\s*,.*,SUCCESS,Checking sources", result.stderr)
    assert(m is not None)