Skip to content
New issue

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

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

Already on GitHub? # to your account

TypeError: 'float' object cannot be interpreted as an integer (for all commands) #46

Closed
jpazer opened this issue Nov 24, 2023 · 6 comments
Labels
bug Something isn't working

Comments

@jpazer
Copy link

jpazer commented Nov 24, 2023

Describe the bug

When trying to run any command I get this TypeError. I had it working on an older intel MacBook, but I recently upgraded to an M3 MacBook Pro and have not been able to get the program to run because of this error. I am using Python 3.12.0 with jncep installed via pip3 in a venv.

(jncep-venv) Cactus-Laptop:~ XXXXXXXXX$ jncep config set EMAIL "XXXXXXXX@gmail.com"
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.12/bin/jncep", line 5, in
from jncep.jncep import main
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/jncep/jncep.py", line 6, in
from .cli.config import config_manage
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/jncep/cli/config.py", line 5, in
from .. import config, track, utils
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/jncep/track.py", line 11, in
from . import config, core, jncweb, spec, utils
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/jncep/core.py", line 17, in
from . import epub, jnclabs, jncweb, spec, utils
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/jncep/jnclabs.py", line 6, in
import asks
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/asks/init.py", line 5, in
from .base_funcs import *
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/asks/base_funcs.py", line 8, in
from .sessions import Session
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/asks/sessions.py", line 16, in
from .request_object import RequestProcessor
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/asks/request_object.py", line 31, in
_BOUNDARY = "8banana133744910kmmr13a56!102!" + str(randint(1e3, 9e3))
^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/random.py", line 336, in randint
return self.randrange(a, b+1)
^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/random.py", line 301, in randrange
istart = _index(start)
^^^^^^^^^^^^^
TypeError: 'float' object cannot be interpreted as an integer

Expected behavior

I should be able to run the commands to set the email and password and make epub files.

To Reproduce

Any commands. Specially I've tried these two and a couple of others.

jncep -d epub -o /Users/XXXXXXX/Desktop/jncbooks https://j-novel.club/read/ascendance-of-a-bookworm-part-5-volume-8-part-5
jncep config set EMAIL "XXXXXXXX@gmail.com"

Debug trace

(jncep-venv) Cactus-Laptop:~ XXXXXXX$ jncep -d epub -o /Users/XXXXXXX/Desktop/jncbooks https://j-novel.club/read/ascendance-of-a-bookworm-part-5-volume-8-part-5
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.12/bin/jncep", line 5, in
from jncep.jncep import main
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/jncep/jncep.py", line 6, in
from .cli.config import config_manage
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/jncep/cli/config.py", line 5, in
from .. import config, track, utils
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/jncep/track.py", line 11, in
from . import config, core, jncweb, spec, utils
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/jncep/core.py", line 17, in
from . import epub, jnclabs, jncweb, spec, utils
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/jncep/jnclabs.py", line 6, in
import asks
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/asks/init.py", line 5, in
from .base_funcs import *
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/asks/base_funcs.py", line 8, in
from .sessions import Session
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/asks/sessions.py", line 16, in
from .request_object import RequestProcessor
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/asks/request_object.py", line 31, in
_BOUNDARY = "8banana133744910kmmr13a56!102!" + str(randint(1e3, 9e3))
^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/random.py", line 336, in randint
return self.randrange(a, b+1)
^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/random.py", line 301, in randrange
istart = _index(start)
^^^^^^^^^^^^^
TypeError: 'float' object cannot be interpreted as an integer

Environment (please complete the following information):

  • OS: [macOS Sonoma 14.1.1]
  • Python version: [3.12.0]
  • JNCEP version: [v46]
@jpazer jpazer added the bug Something isn't working label Nov 24, 2023
@gvellut
Copy link
Owner

gvellut commented Nov 25, 2023

Thank you for your feedback.

There has already been a report #45 of issues with Python 3.12. I have added the suggested fix in the code but not tested much. Possibly it also fixes the issue you have. I intend to do a release at some point (I wanted to add some other changes but maybe I will release just for that). In the meantime, some options:

@jpazer
Copy link
Author

jpazer commented Nov 25, 2023

Upgrading asks to v3.0.0 worked! Thanks!

@jpazer
Copy link
Author

jpazer commented Nov 27, 2023

I got the config command to work, but when I try to export an ePub I get an ssl certificate error.

(jncep-venv) Cactus-Laptop:~ XXXXXXX$ jncep epub -o /Users/XXXXXXX/Desktop/jncbooks http://j-novel.club/read/ascendance-of-a-bookworm-part-5-volume-8-part-5
2023-11-25 10:43:04,714 jncep.utils WARNING Login with email '[highlight]l**************@g****.com[/]'...
2023-11-25 10:43:04,771 jncep.utils ERROR *** An unrecoverable error occured ***
2023-11-25 10:43:04,771 jncep.utils ERROR [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1000)
2023-11-25 10:43:04,772 jncep.cli DEBUG Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/jncep/cli/base.py", line 17, in invoke
return super().invoke(ctx)
^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/click/core.py", line 1434, in invoke
return ctx.invoke(self.callback, **ctx.params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/click/core.py", line 783, in invoke
return __callback(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/jncep/trio_utils.py", line 31, in wrapper
return trio.run(partial(f, *args, **kwargs))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/trio/_core/_run.py", line 1932, in run
raise runner.main_task_outcome.error
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/jncep/cli/epub.py", line 79, in generate_epub
async with core.JNCEPSession(email, password) as session:
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/jncep/core.py", line 70, in aenter
await self.login(self.email, self.password)
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/jncep/core.py", line 102, in login
token = await self.api.login(email, password)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/jncep/jnclabs.py", line 144, in login
r = await self.labs_api_session.post(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/asks/sessions.py", line 206, in request
sock = await timeout_manager(
^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/asks/utils.py", line 15, in timeout_manager
return await coro(*args)
^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/asks/sessions.py", line 431, in _grab_connection
sock = await self._make_connection(host_loc)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/asks/sessions.py", line 405, in _make_connection
sock, port = await self._connect(host_loc)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/asks/sessions.py", line 105, in _connect
return await self._open_connection_https((host, int(port))), port
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/asks/sessions.py", line 76, in _open_connection_https
sock = await connect_tcp(
^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/anyio/_core/_sockets.py", line 229, in connect_tcp
return await TLSStream.wrap(
^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/anyio/streams/tls.py", line 123, in wrap
await wrapper._call_sslobject_method(ssl_object.do_handshake)
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/anyio/streams/tls.py", line 131, in _call_sslobject_method
result = func(*args)
^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/ssl.py", line 917, in do_handshake
self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1000)

@gvellut
Copy link
Owner

gvellut commented Nov 28, 2023

@jpazer
Copy link
Author

jpazer commented Nov 29, 2023

Awesome, that was it. Thank you! Also thanks for building such a cool tool, I'm so happy it exists!

@gvellut
Copy link
Owner

gvellut commented Feb 5, 2024

I have updated to the later versions for Trio and asks and the commands seem to work fine on Python 3.8 to 3.12. So this issue should be fixed in the next jncep version.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants