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
Begin porting from Python2/Django 1.11 to Python3/Django 2.0 #70
Conversation
Changes the Dockerfile to use Python 3.6, and requirements.txt to use Django 2.0 Clean up exceptions to Python3 format in dashboard/helpers.py
awesome! a few questions:
|
yep, will do
I need to get the app to a point where it can run the local server successfully before we can test. I'll have a better time estimate after working on it some more today.
hold off for now, once the app is running then I'll need the help |
Changing the requirements.txt file to simply "PyPDF2" may have done the trick here. PyPDF hasn't been actively maintained for years and it appears that PyPDF2 has ported it to Python3 successfully.
DRF needed to be upgraded to be compatible with Django 2.0, and the sitemaps module just needed some basic tweaking to get working.
@owocki the local server is now running successfully on python3/django2. I've tested out the lifecycle of a funded issue on Ropsten and it's working for me (funding, claiming, accepting, rejecting) Tips appear to be broken and so that's what I'll work on next, but if anyone has any insight there I'm all ears. The request.body is empty in send_tip_2 view, not sure why. Now would be a good time to open it up to testing - I'm sure there are plenty of edge cases. |
Dockerfile
Outdated
@@ -1,4 +1,4 @@ | |||
FROM python:2.7-slim | |||
FROM python:3.6 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be possible to switch this to 3.6-slim-jessie
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure thing
just posted about this to #focus-dev-python on slack. also, looks like theres a bunch new merge conflicts. might be because of the isort PR. sorry! |
My apologies! Most, if not all of those conflicts should be fine to resolve if you drop in the |
installing the dependancies so i can test now.. |
1 similar comment
installing the dependancies so i can test now.. |
got it running and most pages seem to work; did not test the flows end to end but i similarly get the tips error |
The failure on |
merging in latest changes
…on:3.6-slim-jessie Docker image Merge branch 'master' of https://github.com/speizerj/web into python3
dockerfile has been updated and merge conflicts resolved manually - working on the tip bug now |
Changed the send/receive tip views to check for response.body rather than comparing equality to an emtpy string
Tips appear to be working now, though I could only test out the sending functionality. The receive page appears to work as well but I couldn't confirm because I don't have the proper setup to test out the email functionality, and I couldn't get a link to test. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a few minor comments.
@@ -1,12 +1,12 @@ | |||
FROM python:2.7-slim | |||
FROM python:3.6-slim-jessie |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason you chose the -slim-jessie
image over the -slim
or just the regular python:3.6
image? I'm wondering if some of the linux packages you are installing below might already be included in one of the other python images. Might speed up the build time a bit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using the slim base cuts this docker image size in half... The slim base for 3.6 defaults to stretch, which is unsupported by a dependency we use due to the openssl version at the moment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right -- I usually use the slim
versions also unless I have some issue installing things on the container. Makes sense then re: openssl version.
app/dashboard/helpers.py
Outdated
@@ -67,7 +67,7 @@ def title(request): | |||
urlVal = URLValidator() | |||
try: | |||
urlVal(url) | |||
except ValidationError, e: | |||
except ValidationError as e: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Total nit pick but if you aren't using any information from the Error Message you shouldn't even need the as e
part.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💯
app/dashboard/helpers.py
Outdated
@@ -77,7 +77,7 @@ def title(request): | |||
|
|||
try: | |||
html_response = requests.get(url) | |||
except ValidationError, e: | |||
except ValidationError as e: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment as above.
app/dashboard/helpers.py
Outdated
@@ -96,7 +96,7 @@ def title(request): | |||
for link in soup.find_all('h1'): | |||
print(link.text) | |||
|
|||
except ValidationError, e: | |||
except ValidationError as e: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment as above.
app/dashboard/helpers.py
Outdated
@@ -119,7 +119,7 @@ def keywords(request): | |||
urlVal = URLValidator() | |||
try: | |||
urlVal(url) | |||
except ValidationError, e: | |||
except ValidationError as e: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment as above.
app/dashboard/helpers.py
Outdated
@@ -138,7 +138,7 @@ def keywords(request): | |||
keywords.append(split_repo_url[-2]) | |||
|
|||
html_response = requests.get(repo_url) | |||
except ValidationError, e: | |||
except ValidationError as e: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment as above.
app/dashboard/helpers.py
Outdated
@@ -149,7 +149,7 @@ def keywords(request): | |||
for ele in eles: | |||
keywords.append(ele.text) | |||
|
|||
except ValidationError, e: | |||
except ValidationError as e: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment as above.
@@ -53,7 +53,7 @@ def send_tip(request): | |||
@ratelimit(key='ip', rate='2/m', method=ratelimit.UNSAFE, block=True) | |||
def receive_tip(request): | |||
|
|||
if request.body != '': | |||
if request.body: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
thanks for pushing this fwd yall. heads down on other stuff today, but hit me up on slack if you want more community involvement |
merging in latest from master
Since byte object doesn't have a format method, use % formatting instead, per: https://stackoverflow.com/a/22701750
FYI here's the error I'm getting when trying to submit the /whitepaper form (looks to be sendgrid related - assuming it's lack of credentials):
|
you can generate a free sendgrid key at sendgrid.com (or just comment out that line for testing) |
…ring generation The whitepaper PDF generation did not work in Python3. The majority of changes were porting from using file() to open(). For bytestring generation - I've changed the format to use string.encode() instead of coercing the string to a bytestring with b"".
Whitepaper generation is now working for me locally, though I had to test with a dummy PDF (I don't have the whitepaper source). The watermark is being generated but does appear to be cut off a bit on the right hand side - not sure if that's a new bug or existing. |
allow_tags has been deprecated (see https://docs.djangoproject.com/en/dev/internals/deprecation/#deprecation-removed-in-2-0) Using format_html and mark_safe instead.
looks like theres a few merge conflicts on this PR now. we should go ahead and get this merged so that the overhead of keeping it current is less :P |
@ speizerj thanks for your help on this so far. i can do a final round of QA and hopefully we can get this out by mid week |
no worries @owocki I don't mind keeping it current - I'll take care of those merge conflicts tonight. Sounds good re: QA/merge - let me know how I can help |
I'm going to be raising a PR for GH integration and bounty model changes this evening, so I should be able to run through this again at some point shortly. Anything specific that I should hit or just run down the views and hit some of the common methods? I was hoping to get in some general tests to help you out, but didn't get that far yet! Maybe after the GH/bounty changes! Also, sorry for the conflicts! 😛 |
derp. looks like theres some merge conflcits now.. i could likely carve out some time to nail this down on weds if anyone else wants to do that with me |
sure thing - I'll take care of the conflicts tonight and then happy to join you on Wed |
We should be good with GH/express interest before then, so I should be free to help you both test/resolve whatever is needed as well (and you'll probably have more merge conflicts ) Let me know if either of you need any help with this before then! |
The tinyurl library is not python3 compatible, so I've migrated to the pyshortener library.
hows it going on the move from Python 2 --> 3? |
its... fallen to the backburner unforgtunately... :( |
Nope I think we should be good, the only outstanding items were keeping it current with regards to merge conflicts and testing out all the flows to ensure there were no issues. I'll follow up on the new PR |
This issue now has a funding of 0.03 ETH (33.65 USD) attached to it.
|
whoops.. meant to post this to another issue.. cleaning this up now |
The funding of 0.03 ETH (33.36 USD) attached to this issue has been killed by the bounty submitter
|
leaderboard clientside jscript version that just needs thegraph fetch
Changes the Dockerfile to use Python 3.6, and requirements.txt to use Django 2.0
Clean up exceptions to Python3 format in dashboard/helpers.py