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

Update to Python3/modernise project #7

Merged
merged 21 commits into from
Sep 24, 2019

Conversation

notjosh
Copy link
Collaborator

@notjosh notjosh commented Sep 12, 2019

Hiya,

This is a bit of a jumble, so let's call it a WIP for now. Broadly I'm not much of a Python developer, so I might need a little handholding.

I don't think it touches any of the models/DB handling, so it should overall be pretty safe.

My goal here isn't to mess with The Order, but I want a nice, stable space where I can add features (I want to add offline queuing!)

There are a couple of sidenotes to this:

  • I touched the Docker config to include Postgres (mostly for testing, but also helpful for dev) since SQLite doesn't play well with postgresql.ARRAY(sa.String()) in 3a2c72f262b5_add_print_key_usage.py. I didn't want to touch that migration, since it'd break backward compatibility with live server(s). (small TODO: strip out all mentions of SQLite!)
  • The PR contains some files that prettier decided needing cleaning when I bumped them, so there's a bit of noise in the PR. I can revert that if you'd like a cleaner PR (but also: maybe we could add a code formatter for the Python at some point too? Black? That seems like a contentious decision!)
  • Tests are passing, but need to be run manually for now. It's nice and Docker-ised though, so not too bad. We could always do with more tests though.
  • I'm not sure how to tell Heroku to start using Python 3 (I haven't touched Heroku in a long time - I bumped runtime.txt but I'm not actually sure if that's correct or not.

Copy link
Member

@joerick joerick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey Josh! I've had a look over this and it all looks very sensible. Really great to get it onto a modern stack :)

How much testing have you done on this? I'm tempted to push it to our Heroku and see what happens... have you tested printers connecting to it in your docker set up? I'm thinking there might be some nasty str->bytes Python 3 stuff in the protocol code...

@@ -31,7 +31,7 @@ def test_full(self):

image = Image.open(data)
image = image_encoding.crop_384(image)
image = image_encoding.threshold(image)
# image = image_encoding.threshold(image)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any particular reason for removing this test?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uhhh, it was probably causing something to break and I forgot about it 😅 I'll give it a look!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reverted this in bcd45c3

@notjosh
Copy link
Collaborator Author

notjosh commented Sep 14, 2019

have you tested printers connecting to it in your docker set up? I'm thinking there might be some nasty str->bytes Python 3 stuff in the protocol code...

I hadn't at all, was really more at a WIP level of "let's see what happens". I just pushed a couple of commits that seem to fix the core loop, so it...works? I think? Ish? (?!)

I'm not sure if I mentioned at all in a previous issue/PR, but I've been building out a new client lib, so by default it'll just print images to the console (with pluggable adapters for different printers), and here's what it's doing after I pushed those commits:

image

I'm on the confident side of "maybe it works", but I really haven't poked at the corners of the API endpoints very much either, so likely some lurking issues in there.

@joerick
Copy link
Member

joerick commented Sep 14, 2019

Well, I just tried pushing this PR to heroku and nothing seemed to break, so good job! I tested Twitter login, printing test messages and using print keys, all seemed to work great.

Are you happy for this PR to be merged then? Anything else you'd like to do before calling it 'done'?

@notjosh
Copy link
Collaborator Author

notjosh commented Sep 15, 2019

I'm still finding some small issues here and there (as predicted, bytes vs strings) so perhaps hold off for a little longer and I'll nudge a few more corners. Hold that thought!

@notjosh
Copy link
Collaborator Author

notjosh commented Sep 17, 2019

Ok, I haven't found anything else, so let's kick the tyres some more on production? I'm gonna replace some deprecated things next (i.e. phantomjs), but can write tests specifically around those bits going forward.

@notjosh notjosh mentioned this pull request Sep 17, 2019
@joerick joerick merged commit 40755c3 into nordprojects:master Sep 24, 2019
@joerick
Copy link
Member

joerick commented Sep 24, 2019

Merged! Working well so far. I had to adjust the callback URLs on the twitter app, but that seems to be working. Good job!

@notjosh
Copy link
Collaborator Author

notjosh commented Sep 24, 2019

I had to adjust the callback URLs on the twitter app, but that seems to be working.

Doh, I thought I kept them the same, but good to know it was easy to fix!

@notjosh notjosh deleted the feature/python3 branch September 24, 2019 23:41
This pull request was closed.
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

Successfully merging this pull request may close these issues.

2 participants