diff options
author | Filipp Lepalaan <f@230.to> | 2013-09-18 10:22:16 +0300 |
---|---|---|
committer | Filipp Lepalaan <f@230.to> | 2013-09-18 10:22:16 +0300 |
commit | d2947fdefabfb3e3c2f0341a85463b2cdc574d00 (patch) | |
tree | e8e004d68a388afa007b69b78c384ec866842d33 /gsxws | |
parent | c1566d66fa267f898656ee029baa85d61ba9d852 (diff) | |
download | py-gsxws-d2947fdefabfb3e3c2f0341a85463b2cdc574d00.tar.gz py-gsxws-d2947fdefabfb3e3c2f0341a85463b2cdc574d00.tar.bz2 py-gsxws-d2947fdefabfb3e3c2f0341a85463b2cdc574d00.zip |
Fixed instantiating products with IMEI code
Diffstat (limited to 'gsxws')
-rw-r--r-- | gsxws/products.py | 21 |
1 files 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): @@ -151,6 +156,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') |