diff options
author | Victor Shyba <victor.shyba@gmail.com> | 2015-07-29 13:30:41 -0300 |
---|---|---|
committer | Victor Shyba <victor.shyba@gmail.com> | 2015-07-29 13:30:41 -0300 |
commit | 2e911bd0c949b7f42824ed87c467b1ac0919224a (patch) | |
tree | 8574450309fccccca204042124bbef1a1a25ec99 /src/leap/common/events | |
parent | e47f4bcc0eb9c3d08c649adcb62b0325f439113e (diff) |
[refactor] Extract flags check to caller
Checking was done inside of emit method. Doing on emit function at
a module level makes it cleaner with less lines inside of check.
Diffstat (limited to 'src/leap/common/events')
-rw-r--r-- | src/leap/common/events/client.py | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/leap/common/events/client.py b/src/leap/common/events/client.py index 8d8d522..4790fc3 100644 --- a/src/leap/common/events/client.py +++ b/src/leap/common/events/client.py @@ -170,10 +170,9 @@ class EventsClient(object): :param content: The content of the event. :type content: list """ - if flags.EVENTS_ENABLED: - logger.debug("Emitting event: (%s, %s)" % (event, content)) - payload = str(event) + b'\0' + pickle.dumps(content) - self._send(payload) + logger.debug("Emitting event: (%s, %s)" % (event, content)) + payload = str(event) + b'\0' + pickle.dumps(content) + self._send(payload) def _handle_event(self, event, content): """ @@ -537,7 +536,8 @@ def emit(event, *content): :param content: The content of the event. :type content: list """ - return EventsClientThread.instance().emit(event, *content) + if flags.EVENTS_ENABLED: + return EventsClientThread.instance().emit(event, *content) def instance(): |