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

Python 3 support #10

Open
JuanjoSalvador opened this issue Nov 4, 2017 · 20 comments
Open

Python 3 support #10

JuanjoSalvador opened this issue Nov 4, 2017 · 20 comments

Comments

@JuanjoSalvador
Copy link

I noticed that python-mega doesn't works on Python 3.x.

I'm checking the code and I think we can add support for Python 3.x, with few bugfixes.

@madchucky
Copy link

How far are you with that @JuanjoSalvador ?

@JuanjoSalvador
Copy link
Author

I need to rewrite a lot of code. WIP, but I'm a bit bussy those days

@madchucky
Copy link

madchucky commented Nov 22, 2017

@JuanjoSalvador Will you solve issue 6 and the error handling of issue 9 too?

@JuanjoSalvador
Copy link
Author

JuanjoSalvador commented Nov 22, 2017

Maybe I should start fixing those issues. I will fork the project as soon as possible and start to work with that. It seems like @juanriaza has abandoned his own project :(

Update.

#6 seems fixed on #8 (maybe #9 too!). But my priority here is to add Python 3 support.

@madchucky
Copy link

The issue 6 seems to be solved although not integrated in the files. Issue 9 is linked to following errors coming back from the mega API:
API_EAGAIN (-3) (always at the request level): A temporary congestion or server malfunction prevented your request from being processed. No data was altered. Retry. Retries must be spaced with exponential backoff.

To fix the TypeError bug, I tested as follow in Python 2:

	if isinstance(req.json(), (int, long)):
		return req.json()
	else:
	        return req.json()[0]

@JuanjoSalvador
Copy link
Author

I need to check travis's logs, but seems good.

@juanriaza
Copy link
Owner

@JuanjoSalvador busy as well. PRs are always welcome

@jeroenmeulenaar
Copy link

@JuanjoSalvador 👍 I'd like python3 support as well. Let me know if I can help somewhere.

@juanriaza I have a PR open :)

@JuanjoSalvador
Copy link
Author

@jeroenmeulenaar we need to rewrite a lot of code, I guess. To be honest, I never migrated a project from Python 2.x to 3.x, so it will be nice if we can coordinate for this task.

@jeroenmeulenaar
Copy link

I never did as well, but by now it should be well known how to do it :), e.g. transforming strings to bytes now have to specify an encoding, etc.

How do you want to coordinate? You could push your (unfinished) changes to your repo and I can pick up some issues. Or you can tell me which function I should investigate.

My time is also fragmented so in either case don't wait for me :)

@madchucky
Copy link

madchucky commented Dec 3, 2017

utils.py
-> 12 functions, 84 lines
crypto.py using utils.py functions
-> 10 functions, 71 lines
mega.py
-> 12 functions, 269 lines

I will try to work in that order on my side. I keep you posted.

@JuanjoSalvador
Copy link
Author

JuanjoSalvador commented Dec 3, 2017

@madchucky @jeroenmeulenaar i'm using Python's 2to3 lib to make the translations, but we need to improve the tests, and a looot of testing, I guess.

Check the lib here

https://docs.python.org/3.6/library/2to3.html

Tomorrow I will upload my code ready-to-test, but it will be fine if everyone of us take a file (or files) to translate and fix.

@JuanjoSalvador
Copy link
Author

JuanjoSalvador commented Dec 10, 2017

My fork is updated with my work for Python3 support [WIP]. There is a lot of issues yet, so we need to re-write the tests and work with them.

https://github.com/JuanjoSalvador/python-mega

@jeroenmeulenaar
Copy link

I now setup my code-base to work with your changes + my earlier pull request #8.

The first error I hit is

File "~/github/python-mega/mega/utils.py", line 25, in str_to_a32
return struct.unpack('>%dI' % (len(b) / 4), b)
TypeError: 'str' does not support the buffer interface

Did anybody already figure out how to update this? It something like python3 doesn't convert from String to Bytes without specifying an encoding (python2 then uses UTF-8 by default?), but I don't understand all details yet.

@JuanjoSalvador
Copy link
Author

I'm working on it.

@jeroenmeulenaar
Copy link

Nice. I have a version now which does seem to upload correctly, but I have to implement downloads to test it better. It will be interesting to compare our solutions :).

Would it help you if I pushed my local hacking branch?

@JuanjoSalvador
Copy link
Author

@jeroenmeulenaar of course! Publish whatever you have, we can test both libs and find solutions together.

@jeroenmeulenaar
Copy link

@jeroenmeulenaar
Copy link

I have a testcase now also for downloading, and it looks like everything works.

@juanriaza: do you still want to maintain this project? If so, I'll make a pull request to add python3 support (and fix other bugs).

@jeroenmeulenaar
Copy link

@JuanjoSalvador : I've published my new project at https://github.com/jeroenmeulenaar/python3-mega. It's python 3 only for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants