X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fpython-systemd%2Fjournal.py;h=6e82a460b57d81712918d2a7c35700997b0e8db4;hp=533a8754a4f8ca6b09d7fb5fcc6322b222415af4;hb=bf1ced5503bf02fa8c18f0089f4cf74a5456c3c9;hpb=6a71de70e5f5a244b656d9ccb373cc7241033e15 diff --git a/src/python-systemd/journal.py b/src/python-systemd/journal.py index 533a8754a..6e82a460b 100644 --- a/src/python-systemd/journal.py +++ b/src/python-systemd/journal.py @@ -26,6 +26,8 @@ import uuid import traceback as _traceback import os as _os import logging as _logging +if sys.version_info >= (3,): + from collections import ChainMap from syslog import (LOG_EMERG, LOG_ALERT, LOG_CRIT, LOG_ERR, LOG_WARNING, LOG_NOTICE, LOG_INFO, LOG_DEBUG) from ._journal import sendv, stream_fd @@ -90,7 +92,7 @@ class Journal(_Journal): def _convert_field(self, key, value): try: result = self.converters[key](value) - except KeyError: + except: # Default conversion in unicode try: result = _convert_unicode(value) @@ -101,13 +103,18 @@ class Journal(_Journal): def _convert_entry(self, entry): result = {} - for key, value in entry.iteritems(): + for key, value in entry.items(): if isinstance(value, list): result[key] = [self._convert_field(key, val) for val in value] else: result[key] = self._convert_field(key, value) return result + def add_match(self, *args, **kwargs): + args = list(args) + args.extend(_make_line(key, val) for key, val in kwargs.items()) + super(Journal, self).add_match(*args) + def get_next(self, *args, **kwargs): return self._convert_entry( super(Journal, self).get_next(*args, **kwargs))