Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sha
- from time import gmtime, strftime
- def getTPSTimeString():
- return strftime("%Y%m%d%H%M",gmtime())[0:11]
- def voucher_catalogue(str_timestamp = None):
- voucherServer = 'http://tct-testing-tps.hk.kitesystems.com:8080/voucher-testing2/api/catalogue'
- data = {}
- if str_timestamp is not None:
- data['timestamp'] = str_timestamp
- data['app_name'] = 'WALLET_TO_VOUCHER'
- sha1 = sha.new()
- if str_timestamp is not None:
- sha1.update(str(str_timestamp))
- else:
- sha1.update(str(""))
- sha1.update('WALLET_TO_VOUCHER')
- sha1.update('492DDE365315631F')
- sha1.update(str(getTPSTimeString()))
- data['session_control'] = str(sha1.hexdigest())
- try:
- urllib_request = urllib2.Request(voucherServer,urllib.urlencode(data))
- response = urllib2.urlopen(urllib_request).read()
- catalogue = Catalogue()
- catalogue.ParseFromString(response)
- if not catalogue.success:
- return False
- else:
- return catalogue
- except Exception as e:
- return False
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement