aboutsummaryrefslogtreecommitdiffstats
path: root/gsxws/products.py
diff options
context:
space:
mode:
authorFilipp Lepalaan <f@230.to>2013-09-11 20:54:57 +0300
committerFilipp Lepalaan <f@230.to>2013-09-11 20:54:57 +0300
commitc32c20e90ddcc3c803a7c1ff649259e8a2fe058f (patch)
tree42fe8bfec475c1cd439a55abae6799c33385117d /gsxws/products.py
parente2567235643a6d1c804568fd4051e3705812cded (diff)
downloadpy-gsxws-c32c20e90ddcc3c803a7c1ff649259e8a2fe058f.tar.gz
py-gsxws-c32c20e90ddcc3c803a7c1ff649259e8a2fe058f.tar.bz2
py-gsxws-c32c20e90ddcc3c803a7c1ff649259e8a2fe058f.zip
Fix fetch_image()
Diffstat (limited to 'gsxws/products.py')
-rw-r--r--gsxws/products.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/gsxws/products.py b/gsxws/products.py
index fe31e7f..54169d0 100644
--- a/gsxws/products.py
+++ b/gsxws/products.py
@@ -76,6 +76,7 @@ class Product(object):
self._gsx._submit("unitDetail", "WarrantyStatus", "warrantyDetailInfo")
self.warrantyDetails = self._gsx._req.objects
+ self.imageURL = self.warrantyDetails.imageURL
self.productDescription = self.warrantyDetails.productDescription
self.description = self.productDescription.lstrip('~VIN,')
@@ -107,19 +108,20 @@ class Product(object):
diags = Diagnostics(serialNumber=self.serialNumber)
return diags.fetch()
- def fetch_image(self):
+ def fetch_image(self, url=None):
"""
>>> Product('DGKFL06JDHJP').fetch_image() # doctest: +ELLIPSIS
Traceback (most recent call last):
...
GsxError: No URL to fetch product image
"""
- if not hasattr(self, "imageURL"):
+ url = url or self.imageURL
+
+ if not url:
raise GsxError("No URL to fetch product image")
try:
- result = urllib.urlretrieve(self.imageURL)
- return result[0]
+ return urllib.urlretrieve(url)[0]
except Exception, e:
raise GsxError("Failed to fetch product image: %s" % e)