Port to Python3, canonicalize JSON, retain Umlauts

This commit is contained in:
Georg Sauthoff 2019-07-14 15:31:03 +02:00
parent fe0e30f173
commit ed139e5b59
1 changed files with 12 additions and 3 deletions

View File

@ -1,10 +1,17 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
from __future__ import print_function
import logging
from inema import ProductInformation
import json
import sys
if sys.version_info.major >= 3:
unicode = str
# you have to fill the below with your login details for the ProdWS Service
USER = "xxx"
PASS = "yyyyyy"
@ -33,7 +40,9 @@ if data['success']:
'max_weight': unicode(weight['maxValue'])
}
print json.dumps(products)
json.dump(products, sys.stdout,
sort_keys=True, indent=4, ensure_ascii=False)
print('')
else:
print 'ERROR: %s' % data['Exception']
print('ERROR: %s' % data['Exception'], file=sys.stderr)
sys.exit(1)