Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] #15

Open
faldo58260 opened this issue Oct 17, 2024 · 0 comments
Open

[Bug] #15

faldo58260 opened this issue Oct 17, 2024 · 0 comments

Comments

@faldo58260
Copy link

Your environment

  • Pyepc version: 2.27.1
  • Python: 3.3
  • Operating System: Windows 10 PRO

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 (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"]

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; }
    img {
        border: 0 none;
    }

    #content {
        margin-left: auto;
        margin-right: auto
    }

    #message h2 {
        font-size: 20px;
        font-weight: normal;
        color: #000000;
        margin: 34px 0px 0px 0px
    }

    #message p {
        font-size: 13px;
        color: #000000;
        margin: 7px 0px 0px0px
    }

    #errorref {
        font-size: 11px;
        color: #737373;
        margin-top: 41px
    }
</style>
<title>Service unavailable</title>

The request is blocked.

20241017T033200Z-r1dcb6d7d7cw9v2bqc1y7fucb400000006n0000000003345
: 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant