From d2947fdefabfb3e3c2f0341a85463b2cdc574d00 Mon Sep 17 00:00:00 2001 From: Filipp Lepalaan Date: Wed, 18 Sep 2013 10:22:16 +0300 Subject: Fixed instantiating products with IMEI code --- gsxws/products.py | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/gsxws/products.py b/gsxws/products.py index 54169d0..ae9e23a 100644 --- a/gsxws/products.py +++ b/gsxws/products.py @@ -7,7 +7,7 @@ import urllib from lookups import Lookup from diagnostics import Diagnostics -from core import GsxObject, GsxError +from core import GsxObject, GsxError, validate def models(): @@ -26,8 +26,13 @@ class Product(object): Something serviceable made by Apple """ def __init__(self, sn): - self.serialNumber = sn - self._gsx = GsxObject(serialNumber=sn) + if validate(sn, 'alternateDeviceId'): + self.alternateDeviceId = sn + self._gsx = GsxObject(alternateDeviceId=sn) + else: + self.serialNumber = sn + self._gsx = GsxObject(serialNumber=sn) + self._gsx._namespace = "glob:" def model(self): @@ -62,9 +67,8 @@ class Product(object): >>> Product('WQ8094DW0P1').warranty([(u'661-5070', u'Z26',)]).warrantyStatus 'Out Of Warranty (No Coverage)' """ - if hasattr(self, "alternateDeviceId"): - if not hasattr(self, "serialNumber"): - self.activation() + if self.should_check_activation: + self.activation() try: self._gsx.partNumbers = [] @@ -142,6 +146,7 @@ class Product(object): "FetchIOSActivationDetails", "activationDetailsInfo") self.serialNumber = ad.serialNumber + self._gsx.serialNumber = self.serialNumber return ad def is_unlocked(self, ad=None): @@ -150,6 +155,10 @@ class Product(object): """ return ad.unlocked or ("unlock" in ad.nextTetherPolicyDetails) + @property + def should_check_activation(self): + return hasattr(self, "alternateDeviceId") and not hasattr(self, "serialNumber") + @property def is_iphone(self): return self.description.startswith('iPhone') -- cgit v1.2.3