aboutsummaryrefslogtreecommitdiffstats
path: root/gsx.py
diff options
context:
space:
mode:
authorFilipp Lepalaan <f@0x00.co>2013-01-10 12:12:40 +0200
committerFilipp Lepalaan <f@0x00.co>2013-01-10 12:12:40 +0200
commit5ae6abdd194193744670e7684e9ce3ad63c3a619 (patch)
tree16c3a429e9ff08066acc45103f584cdc65d0d100 /gsx.py
parent74eb6d7b25fab193a1645fb1645a08c9aded62dd (diff)
downloadpy-gsxws-5ae6abdd194193744670e7684e9ce3ad63c3a619.tar.gz
py-gsxws-5ae6abdd194193744670e7684e9ce3ad63c3a619.tar.bz2
py-gsxws-5ae6abdd194193744670e7684e9ce3ad63c3a619.zip
Added locale
Diffstat (limited to 'gsx.py')
-rwxr-xr-xgsx.py28
1 files changed, 24 insertions, 4 deletions
diff --git a/gsx.py b/gsx.py
index fc14513..3a418ca 100755
--- a/gsx.py
+++ b/gsx.py
@@ -13,8 +13,10 @@ logging.basicConfig(level=logging.INFO)
logging.getLogger('suds.client').setLevel(logging.DEBUG)
+# Must use a few module-level global variables
CLIENT = None
-SESSION = dict() # module-level variable
+SESSION = dict()
+LOCALE = 'en_XXX'
def validate(value, what=None):
"""
@@ -60,6 +62,11 @@ class GsxObject(object):
def set_method(self, new_method):
self.method = new_method
+ def get_format(self):
+ df = open(os.path.join(os.path.dirname(__file__), 'langs.json'), 'r')
+ data = json.load(df)
+ return data[LOCALE]
+
def set_type(self, new_dt):
"""
Sets the object's primary data type to new_dt
@@ -244,6 +251,16 @@ class Repair(GsxObject):
def __init__(self, *args, **kwargs):
super(Repair, self).__init__()
+
+ formats = self.get_format()
+
+ # native date types are not welcome here :)
+ for k, v in kwargs.items():
+ if isinstance(v, date):
+ kwargs[k] = v.strftime(formats['df'])
+ if isinstance(v, time):
+ kwargs[k] = v.strftime(formats['tf'])
+
self.data = kwargs
def create_carryin(self):
@@ -256,7 +273,8 @@ class Repair(GsxObject):
self.dt.customerAddress = self.data['customerAddress']
self.set_request('ns2:carryInRequestType', 'repairData')
result = self.submit('CreateCarryInRepair')
- print result
+
+ return result.repairConfirmation
def create_cnd(self):
"""
@@ -408,10 +426,12 @@ def init(env='ut', region='emea'):
CLIENT = Client(url)
def connect(user_id, password, sold_to, lang='en', tz='CEST',
- env='ut', region='emea'):
+ env='ut', region='emea', locale=LOCALE):
global SESSION
-
+ global LOCALE
+
SESSION = {}
+ LOCALE = LOCALE
init(env, region)