From 5634e17a2e5913b636b92e95d31d18ffba137702 Mon Sep 17 00:00:00 2001 From: rembo10 Date: Mon, 6 Jul 2015 01:28:48 -0700 Subject: [PATCH] Fix for #2155, local variable response referenced before assignment utorrent --- headphones/utorrent.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/headphones/utorrent.py b/headphones/utorrent.py index c0e4f264..352ac72b 100644 --- a/headphones/utorrent.py +++ b/headphones/utorrent.py @@ -73,6 +73,7 @@ class utorrentclient(object): except urllib2.HTTPError as err: logger.debug('URL: ' + str(url)) logger.debug('Error getting Token. uTorrent responded with error: ' + str(err)) + return match = re.search(utorrentclient.TOKEN_REGEX, response.read()) return match.group(1) @@ -147,6 +148,10 @@ class utorrentclient(object): return self._action(params) def _action(self, params, body=None, content_type=None): + + if not self.token: + return + url = self.base_url + '/gui/' + '?token=' + self.token + '&' + urllib.urlencode(params) request = urllib2.Request(url)