rewrite to use try/except python3 compat
@@ -6,10 +6,14 @@ compatible with python 3.
import os
import json
-import urllib
-import urllib.request
+try:
+ from urllib.request import urlopen, urlretrieve
+except ImportError:
+ from urllib2 import urlopen
+ from urllib import urlretrieve
-f = urllib.request.urlopen("http://fw.ota.homesmart.ikea.net/feed/version_info.json")
+
+f = urlopen("http://fw.ota.homesmart.ikea.net/feed/version_info.json")
data = f.read()
arr = json.loads(data)
@@ -27,7 +31,7 @@ for i in arr:
path = '%s/%s' % (otapath, fname)
if not os.path.isfile(path):
- urllib.request.urlretrieve(url, path)
+ urlretrieve(url, path)
print(path)
else:
print('%s already exists' % fname)
