fix(amazon-mws): python3 compatibility changes (#19209)
Signed-off-by: Chinmay D. Pai <chinmaydpai@gmail.com>
This commit is contained in:
parent
20194c4cc5
commit
9d26c69c4a
@ -4,10 +4,7 @@
|
|||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import frappe, time, dateutil, math, csv
|
import frappe, time, dateutil, math, csv
|
||||||
try:
|
from six import StringIO
|
||||||
from StringIO import StringIO
|
|
||||||
except ImportError:
|
|
||||||
from io import StringIO
|
|
||||||
import erpnext.erpnext_integrations.doctype.amazon_mws_settings.amazon_mws_api as mws
|
import erpnext.erpnext_integrations.doctype.amazon_mws_settings.amazon_mws_api as mws
|
||||||
from frappe import _
|
from frappe import _
|
||||||
|
|
||||||
@ -26,7 +23,7 @@ def get_products_details():
|
|||||||
listings_response = reports.get_report(report_id=report_id)
|
listings_response = reports.get_report(report_id=report_id)
|
||||||
|
|
||||||
#Get ASIN Codes
|
#Get ASIN Codes
|
||||||
string_io = StringIO(listings_response.original)
|
string_io = StringIO(frappe.safe_decode(listings_response.original))
|
||||||
csv_rows = list(csv.reader(string_io, delimiter=str('\t')))
|
csv_rows = list(csv.reader(string_io, delimiter=str('\t')))
|
||||||
asin_list = list(set([row[1] for row in csv_rows[1:]]))
|
asin_list = list(set([row[1] for row in csv_rows[1:]]))
|
||||||
#break into chunks of 10
|
#break into chunks of 10
|
||||||
@ -294,7 +291,8 @@ def create_sales_order(order_json,after_date):
|
|||||||
so.submit()
|
so.submit()
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
frappe.log_error(message=e, title="Create Sales Order")
|
import traceback
|
||||||
|
frappe.log_error(message=traceback.format_exc(), title="Create Sales Order")
|
||||||
|
|
||||||
def create_customer(order_json):
|
def create_customer(order_json):
|
||||||
order_customer_name = ""
|
order_customer_name = ""
|
||||||
@ -451,7 +449,7 @@ def get_charges_and_fees(market_place_order_id):
|
|||||||
shipment_item_list = return_as_list(shipment_event.ShipmentEvent.ShipmentItemList.ShipmentItem)
|
shipment_item_list = return_as_list(shipment_event.ShipmentEvent.ShipmentItemList.ShipmentItem)
|
||||||
|
|
||||||
for shipment_item in shipment_item_list:
|
for shipment_item in shipment_item_list:
|
||||||
charges, fees = []
|
charges, fees = [], []
|
||||||
|
|
||||||
if 'ItemChargeList' in shipment_item.keys():
|
if 'ItemChargeList' in shipment_item.keys():
|
||||||
charges = return_as_list(shipment_item.ItemChargeList.ChargeComponent)
|
charges = return_as_list(shipment_item.ItemChargeList.ChargeComponent)
|
||||||
|
@ -65,7 +65,8 @@ def calc_md5(string):
|
|||||||
"""
|
"""
|
||||||
md = hashlib.md5()
|
md = hashlib.md5()
|
||||||
md.update(string)
|
md.update(string)
|
||||||
return base64.encodestring(md.digest()).strip('\n')
|
return base64.encodestring(md.digest()).strip('\n') if six.PY2 \
|
||||||
|
else base64.encodebytes(md.digest()).decode().strip()
|
||||||
|
|
||||||
def remove_empty(d):
|
def remove_empty(d):
|
||||||
"""
|
"""
|
||||||
@ -87,8 +88,7 @@ class DictWrapper(object):
|
|||||||
self.original = xml
|
self.original = xml
|
||||||
self._rootkey = rootkey
|
self._rootkey = rootkey
|
||||||
self._mydict = xml_utils.xml2dict().fromstring(remove_namespace(xml))
|
self._mydict = xml_utils.xml2dict().fromstring(remove_namespace(xml))
|
||||||
self._response_dict = self._mydict.get(self._mydict.keys()[0],
|
self._response_dict = self._mydict.get(list(self._mydict)[0], self._mydict)
|
||||||
self._mydict)
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def parsed(self):
|
def parsed(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user