aboutsummaryrefslogtreecommitdiffstats
path: root/gsxws/parts.py
diff options
context:
space:
mode:
authorFilipp Lepalaan <filipp@mac.com>2018-04-02 14:48:18 +0300
committerFilipp Lepalaan <filipp@mac.com>2018-04-02 14:48:18 +0300
commit001bdd8068d70504f08546e137d8200cbe276c08 (patch)
tree8d6678385a83d93b64303a84dd8cf514efee58f1 /gsxws/parts.py
parentfd0eba9bacbe586004aeb131427178bc550cca06 (diff)
downloadpy-gsxws-001bdd8068d70504f08546e137d8200cbe276c08.tar.gz
py-gsxws-001bdd8068d70504f08546e137d8200cbe276c08.tar.bz2
py-gsxws-001bdd8068d70504f08546e137d8200cbe276c08.zip
Use fetch_url for image data
Diffstat (limited to 'gsxws/parts.py')
-rw-r--r--gsxws/parts.py14
1 files changed, 5 insertions, 9 deletions
diff --git a/gsxws/parts.py b/gsxws/parts.py
index 6f9fb02..0f3691b 100644
--- a/gsxws/parts.py
+++ b/gsxws/parts.py
@@ -1,10 +1,8 @@
# -*- coding: utf-8 -*-
-import urllib
-import tempfile
-
-from lookups import Lookup
-from core import GsxObject, GsxError
+from .lookups import Lookup
+from .utils import fetch_url
+from .core import GsxObject, GsxError
REASON_CODES = (
('A', 'Part not needed'),
@@ -35,11 +33,9 @@ class Part(GsxObject):
raise GsxError("Cannot fetch part image without part number")
image = "%s_350_350.gif" % self.partNumber
- url = IMAGE_URL % image
- tmpfile = tempfile.mkstemp(suffix=image)
try:
- return urllib.urlretrieve(url, tmpfile[1])[0]
+ return fetch_url(IMAGE_URL % image)
except Exception as e:
raise GsxError("Failed to fetch part image: %s" % e)
@@ -48,7 +44,7 @@ if __name__ == '__main__':
import sys
import doctest
import logging
- from core import connect
+ from .core import connect
logging.basicConfig(level=logging.DEBUG)
connect(*sys.argv[1:])
doctest.testmod()