-
-
Notifications
You must be signed in to change notification settings - Fork 70
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 updates #280
Python 3 updates #280
Conversation
Difference between py2 and py3: __lt__ etc should be defined.
Update `raw_input` in models.py to `input` (py3 style)
My first solution wasn't working.
Python 3 is UTF-8 by default. Als update on shebang.
The Travis failure is only a |
:) yes, so the normal testing passes, so I guess it is something with my setup that the one test fails on my machine. I haven't yet had much time to work on the docker issue, but otherwise I would say we are almost there. |
Weird... I would expect Agree: we should be able to drop |
From code review by @justb4: 6 - Auth info Decoding/Encoding Failure with Postgres Only occurs when using Postgres, not with SQLite. Background: GHC encodes/encrypts a generic auth dict info structure via JSON string to be stored as textfield in DB. It decodes/decrypts when reading. This way we can support multiple auth types with a single auth column in resource table. So this is another encoding than in 4 for HTTP auth headers, but think similar problem. We also need to deal with existing PG DBs that have auth columns already present in resource table. - install psycopg2 : pip install psycopg2 - used existing PG DB, only changed in config_site.py: SQLALCHEMY_DATABASE_URI = 'postgresql://name:passw@localhost:5432/ghc', but may create new - add URL Resource with Basic Auth (even does not have to have basic auth) - in Edit add Basic Auth Username and Password - click Save Fixed by ensuring encode/decode takes `string` as input and gives `string` as output. These methodes now use static typing. The origin of the problem was the difference of how SQLite and Postgres store the encoded string (either as text or in some binary form). This solution makes the encoded authentication a string object and *not* bytes.
We're not there yet: I noticed some |
@borrob good to see you synced with The Postgres-char-issue: my bad! For security reasons the |
I fixed one paver issue and did some testing (also with docker). I think we're good to go and I'm curious what the results of the demo environment will be. |
I removed the draft tag from this pull request (that was there for the automated testing with travis). Please review and let's hope we can move to py3 soon! |
Yes, good, I only want to release 0.7.0 from current NB solved a nasty concurrency bug (two lines) with #301 #302 today. |
GeoHealthCheck/healthcheck.py
Outdated
@@ -61,7 +61,7 @@ def db_commit(): | |||
err = None | |||
try: | |||
DB.session.commit() | |||
except Exception as err: | |||
except Exception: |
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.
While we are here, for consistency, can we log the error,
except Exception as err:
LOGGER.warning("Cannot commit to database %s".format(err))
GeoHealthCheck/notifications.py
Outdated
@@ -1,5 +1,4 @@ | |||
#!/usr/bin/env python | |||
# -*- coding: utf-8 -*- | |||
#!/usr/bin/env python3 |
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 prefer to remove this shebang line entirely.
GeoHealthCheck/util.py
Outdated
@@ -228,22 +227,24 @@ def read(filename, encoding='utf-8'): | |||
|
|||
|
|||
# https://gist.github.com/gowhari/fea9c559f08a310e5cfd62978bc86a1a | |||
def encode(key, string): | |||
# with alterations to get return type of string, not bytes | |||
def encode(key: str, string: str) -> str: |
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.
Is this annotation specific to Python 3.7+ or safe for 3.4+, say?
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.
Did verifications with latest from borrob's branch:
- SQLite and Postgres backends: tests all run ok.
- Running from commandline ok
- build/run with Docker ok.
So we're good to go! Let's all check on demo.geohealthcheck.org to further verify.
A great thank-you @borrob! This was no easy PR to do. |
Thanks for the awesome contribution @borrob! |
Please do NOT approve this pull request. This is Work In Progress for the python3 conversion. I have an issue with one specific test and we want to see if Travis gets the same error or if it passes without problems.