From 095b27436e8ff0be5e5fe618abc9e13f89adc7cc Mon Sep 17 00:00:00 2001 From: Tobias Manske Date: Fri, 5 Oct 2018 17:54:43 +0200 Subject: [PATCH] [modules/spaceapi] convert from urllib2 to requests better python2 support Signed-off-by: Tobias Manske --- bumblebee/modules/spaceapi.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/bumblebee/modules/spaceapi.py b/bumblebee/modules/spaceapi.py index 60037a8..f9beb38 100644 --- a/bumblebee/modules/spaceapi.py +++ b/bumblebee/modules/spaceapi.py @@ -3,7 +3,7 @@ """Displays the state of a spaceapi endpoint Requires the following libraries: - * urllib + * requests * json * time @@ -18,7 +18,7 @@ import bumblebee.input import bumblebee.output import bumblebee.engine -import urllib.request +import requests import json import time @@ -61,8 +61,9 @@ class Module(bumblebee.engine.Module): if self._lastQuery + self._sleeptime < int(unixtime): self._lastQuery = int(unixtime) try: - with urllib.request.urlopen(self._url) as u: - data = json.loads(u.read().decode()) + + with requests.get(self._url) as u: + data = u.json() self._state = data["state"]["open"] self._name = self.parameter("name", default=data["space"]) self._error = False