You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I used to be able to generate the GTIN EPC. Now, it seemed that GS1 has some changes that now we cannot generate EPC anymore.
It has the JSON encoding issue as the below.
for i in range(0,Qty):
sgtin = SGTIN.from_sgtin(GTIN, serial_number= Start + i)
print(sgtin.encode())
Result:
JSONDecodeError Traceback (most recent call last)
File ~\Anaconda3\lib\site-packages\requests\models.py:910, in Response.json(self, **kwargs)
909 try:
--> 910 return complexjson.loads(self.text, **kwargs)
911 except JSONDecodeError as e:
912 # Catch JSON-related errors and raise as requests.JSONDecodeError
913 # This aliases json.JSONDecodeError and simplejson.JSONDecodeError
File ~\Anaconda3\lib\json_init_.py:346, in loads(s, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, **kw)
343 if (cls is None and object_hook is None and
344 parse_int is None and parse_float is None and
345 parse_constant is None and object_pairs_hook is None and not kw):
--> 346 return _default_decoder.decode(s)
347 if cls is None:
File ~\Anaconda3\lib\json\decoder.py:337, in JSONDecoder.decode(self, s, _w)
333 """Return the Python representation of s (a str instance
334 containing a JSON document).
335
336 """
--> 337 obj, end = self.raw_decode(s, idx=_w(s, 0).end())
338 end = _w(s, end).end()
File ~\Anaconda3\lib\json\decoder.py:355, in JSONDecoder.raw_decode(self, s, idx)
354 except StopIteration as err:
--> 355 raise JSONDecodeError("Expecting value", s, err.value) from None
356 return obj, end
JSONDecodeError: Expecting value: line 1 column 1 (char 0)
During handling of the above exception, another exception occurred:
JSONDecodeError Traceback (most recent call last)
Input In [5], in <cell line: 6>()
4 Start = 0
6 for i in range(0,Qty):
----> 7 sgtin = SGTIN.from_sgtin(GTIN, serial_number= Start + i)
8 print(sgtin.encode())
File ~\Anaconda3\lib\site-packages\pyepc\sgtin.py:406, in SGTIN.from_sgtin(cls, gtin, serial_number, company_prefix_len)
401 assert len(gtin) == 14, "GTIN must be 14 digits"
403 if company_prefix_len is None:
404 # Lookup the company prefix len if not provided.
405 # This is expensive the first time
--> 406 company_prefix_len = utils.get_gcp_length(gtin)
408 return cls(
409 # First digit of GTIN
410 indicator=gtin[0],
(...)
415 serial_number=serial_number,
416 )
File ~\Anaconda3\lib\site-packages\pyepc\utils.py:170, in get_gcp_length(gs1_identification_key)
168 # If the table has not been loaded yet, load it
169 if not GCP_LENGTHS:
--> 170 response = requests.get(
171 "https://www.gs1.org/sites/default/files/docs/gcp_length/gcpprefixformatlist.json" # noqa
172 ).json()
173 for entry in response["GCPPrefixFormatList"]["entry"]:
174 GCP_LENGTHS[entry["prefix"]] = entry["gcpLength"]
Your environment
Description
I used to be able to generate the GTIN EPC. Now, it seemed that GS1 has some changes that now we cannot generate EPC anymore.
It has the JSON encoding issue as the below.
May I know if you can help take a look?
My code:
#Insert GTIN here
GTIN = '07321732072121'
Qty = 100
Start = 0
for i in range(0,Qty):
sgtin = SGTIN.from_sgtin(GTIN, serial_number= Start + i)
print(sgtin.encode())
Result:
JSONDecodeError Traceback (most recent call last)
File ~\Anaconda3\lib\site-packages\requests\models.py:910, in Response.json(self, **kwargs)
909 try:
--> 910 return complexjson.loads(self.text, **kwargs)
911 except JSONDecodeError as e:
912 # Catch JSON-related errors and raise as requests.JSONDecodeError
913 # This aliases json.JSONDecodeError and simplejson.JSONDecodeError
File ~\Anaconda3\lib\json_init_.py:346, in loads(s, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, **kw)
343 if (cls is None and object_hook is None and
344 parse_int is None and parse_float is None and
345 parse_constant is None and object_pairs_hook is None and not kw):
--> 346 return _default_decoder.decode(s)
347 if cls is None:
File ~\Anaconda3\lib\json\decoder.py:337, in JSONDecoder.decode(self, s, _w)
333 """Return the Python representation of
s
(astr
instance334 containing a JSON document).
335
336 """
--> 337 obj, end = self.raw_decode(s, idx=_w(s, 0).end())
338 end = _w(s, end).end()
File ~\Anaconda3\lib\json\decoder.py:355, in JSONDecoder.raw_decode(self, s, idx)
354 except StopIteration as err:
--> 355 raise JSONDecodeError("Expecting value", s, err.value) from None
356 return obj, end
JSONDecodeError: Expecting value: line 1 column 1 (char 0)
During handling of the above exception, another exception occurred:
JSONDecodeError Traceback (most recent call last)
Input In [5], in <cell line: 6>()
4 Start = 0
6 for i in range(0,Qty):
----> 7 sgtin = SGTIN.from_sgtin(GTIN, serial_number= Start + i)
8 print(sgtin.encode())
File ~\Anaconda3\lib\site-packages\pyepc\sgtin.py:406, in SGTIN.from_sgtin(cls, gtin, serial_number, company_prefix_len)
401 assert len(gtin) == 14, "GTIN must be 14 digits"
403 if company_prefix_len is None:
404 # Lookup the company prefix len if not provided.
405 # This is expensive the first time
--> 406 company_prefix_len = utils.get_gcp_length(gtin)
408 return cls(
409 # First digit of GTIN
410 indicator=gtin[0],
(...)
415 serial_number=serial_number,
416 )
File ~\Anaconda3\lib\site-packages\pyepc\utils.py:170, in get_gcp_length(gs1_identification_key)
168 # If the table has not been loaded yet, load it
169 if not GCP_LENGTHS:
--> 170 response = requests.get(
171 "https://www.gs1.org/sites/default/files/docs/gcp_length/gcpprefixformatlist.json" # noqa
172 ).json()
173 for entry in response["GCPPrefixFormatList"]["entry"]:
174 GCP_LENGTHS[entry["prefix"]] = entry["gcpLength"]
File ~\Anaconda3\lib\site-packages\requests\models.py:917, in Response.json(self, **kwargs)
915 raise RequestsJSONDecodeError(e.message)
916 else:
--> 917 raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
JSONDecodeError: [Errno Expecting value]
<style type='text/css'> body { font-family: Arial; margin-left: 40px; }The request is blocked.
The text was updated successfully, but these errors were encountered: