diff options
| author | David Pursehouse <david.pursehouse@sonymobile.com> | 2013-08-05 14:42:30 +0900 |
|---|---|---|
| committer | David Pursehouse <david.pursehouse@sonymobile.com> | 2013-08-05 14:44:30 +0900 |
| commit | ce01e40a6f653a8862456ef735411084bc992b3b (patch) | |
| tree | 408afaceb63027e9a13ca4ef7718f0725513d0a0 /pygerrit | |
| parent | 3bcab572e30115ab42e5b96e6054f9b60b44a75c (diff) | |
| download | pygerrit-ce01e40a6f653a8862456ef735411084bc992b3b.tar.gz | |
Fix UnboundLocalError when stream-event connection fails
When the stream-event command fails, for example due to bad
host name, the result is not initialised. However the code
was accessing the result variable which caused an exception.
Change-Id: I6c649dba447e33733dfaea6e742152277fa7374f
Diffstat (limited to 'pygerrit')
| -rw-r--r-- | pygerrit/stream.py | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/pygerrit/stream.py b/pygerrit/stream.py index 3ca324b..86ae5b7 100644 --- a/pygerrit/stream.py +++ b/pygerrit/stream.py @@ -73,19 +73,19 @@ class GerritStream(Thread): result = self._ssh_client.run_gerrit_command("stream-events") except GerritError as e: self._error_event(e) - - poller = poll() - stdout = result.stdout - poller.register(stdout.channel) - while not self._stop.is_set(): - data = poller.poll() - for (handle, event) in data: - if handle == stdout.channel.fileno() and event == POLLIN: - try: - line = stdout.readline() - json_data = json.loads(line) - self._gerrit.put_event(json_data) - except (ValueError, IOError) as err: - self._error_event(err) - except GerritError as err: - logging.error("Failed to put event: %s", err) + else: + poller = poll() + stdout = result.stdout + poller.register(stdout.channel) + while not self._stop.is_set(): + data = poller.poll() + for (handle, event) in data: + if handle == stdout.channel.fileno() and event == POLLIN: + try: + line = stdout.readline() + json_data = json.loads(line) + self._gerrit.put_event(json_data) + except (ValueError, IOError) as err: + self._error_event(err) + except GerritError as err: + logging.error("Failed to put event: %s", err) |
