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

Atlanta Location Not Working #3

Closed
SummitPatel opened this issue Jul 26, 2022 · 5 comments
Closed

Atlanta Location Not Working #3

SummitPatel opened this issue Jul 26, 2022 · 5 comments

Comments

@SummitPatel
Copy link
Contributor

Hi there,

First off, thanks for making this tool! I'm currently trying to use this to get an appointment at the Enrollment Center in the Atlanta airport. I've downloaded the project, followed your instructions in the README, and it seems to be working for the JFK and LAX (the script seems to be running but I will confess I haven't seen anything come through so I'm not 100% sure).

However, when I try to run the script against the ATL location with python3 global_entry.py 5182, I receive this error and the script terminates.

Global Entry Appt @ 2023-03-07T08:15
Traceback (most recent call last):
  File "/Users/summit/Projects/global_entry/venv/lib/python3.9/site-packages/plyer/utils.py", line 93, in _ensure_obj
    mod = __import__(module, fromlist='.')
  File "/Users/summit/Projects/global_entry/venv/lib/python3.9/site-packages/plyer/platforms/macosx/notification.py", line 7, in <module>
    from pyobjus import (
ModuleNotFoundError: No module named 'pyobjus'
Traceback (most recent call last):
  File "/Users/summit/Projects/global_entry/global_entry.py", line 57, in <module>
    main(default)
  File "/Users/summit/Projects/global_entry/global_entry.py", line 47, in main
    notification.notify(title='global_entry.py', message=message, timeout=3)
  File "/Users/summit/Projects/global_entry/venv/lib/python3.9/site-packages/plyer/facades/notification.py", line 79, in notify
    self._notify(
  File "/Users/summit/Projects/global_entry/venv/lib/python3.9/site-packages/plyer/facades/notification.py", line 88, in _notify
    raise NotImplementedError("No usable implementation found!")
NotImplementedError: No usable implementation found!

I'm not a python dev so I'm not sure what to make of this, but let me know if you need more information and I can help troubleshoot this with you

@billy-doyle
Copy link
Owner

billy-doyle commented Jul 26, 2022

Hi @SummitPatel

This looks like its an issue with the plyer package. A simple quick and dirty fix would be to comment out the notification.notify line and just use a print statement like print(message)

I've found another issue which says it may just be a wrong import or an unknown platform, see here kivy/plyer#485

And yes, it would indeed run for JFK and LAX, but as they are super busy it is skipping the notification line since there are no openings... at least when you ran the script.

I would say first do the print statement, see that it returns, and then work on the issue with the unknown platform. If you create a PR I can happily merge it if you find out what the resolution is.

@billy-doyle
Copy link
Owner

Maybe this would work? CedArctic/Chimera@5b73b61

@SummitPatel
Copy link
Contributor Author

Hi @billy-doyle

So I commented out the line you suggested and it's printing to terminal without issue now! I think the locationId is correct, I had just misidentified what was happening. When running against JFK/LAX, the script was just hanging for a long time (to me this looked like it was working). Not sure why when I ran against ATL that it immediately crashed and gave me that error log, but JFK/LAX eventually timed out with the same error. So I'm able to get this working locally now without the notifications.

I think it might be important to call out that I am using the fish shell, so when I ran the source venv/bin/activate suggested in the Download section of the README, I instead ran source venv/bin/activate.fish. After that, I ran pip3 install -r requirements.txt and it seemed to install without issue. Here is the output after already doing the initial install:

Requirement already satisfied: requests in ./venv/lib/python3.9/site-packages (from -r requirements.txt (line 1)) (2.28.1)
Requirement already satisfied: plyer in ./venv/lib/python3.9/site-packages (from -r requirements.txt (line 2)) (2.0.0)
Requirement already satisfied: idna<4,>=2.5 in ./venv/lib/python3.9/site-packages (from requests->-r requirements.txt (line 1)) (3.3)
Requirement already satisfied: charset-normalizer<3,>=2 in ./venv/lib/python3.9/site-packages (from requests->-r requirements.txt (line 1)) (2.1.0)
Requirement already satisfied: certifi>=2017.4.17 in ./venv/lib/python3.9/site-packages (from requests->-r requirements.txt (line 1)) (2022.6.15)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in ./venv/lib/python3.9/site-packages (from requests->-r requirements.txt (line 1)) (1.26.11)
WARNING: There was an error checking the latest version of pip.

So everything seems good from what I can tell and you can see that I have plyer installed, but for whatever reason the script is unable to locate the module during runtime.

@billy-doyle
Copy link
Owner

So I would first create a new file, maybe call it test.py and copy paste the below code and execute it. You should get the stack trace you have identified in your first comment.

from plyer import notification

print(notification.notify(title='TEST', message='Testing plyer', timeout=3))

Hence, this has narrowed down the issue to a problem with the plyer package installed on your system (unsure if related to fish to be honest). It is just a convenience function to display a notification on your operating system (think like if you get an email or a slack, it pops up in a corner of your screen) and is not required for the script to properly operate.

What I would try to get plyer working is what I have linked above, namely add import os and add os.system("osascript -e 'display notification \"{}\"\'".format(txt)). I do not have a mac so therefore cannot reproduce but that is what I think would work? Try this in test.py now:

import os
from plyer import notification

os.system("osascript -e 'display notification \"{}\"\'".format(txt))

print(notification.notify(title='TEST', message='Testing plyer', timeout=3))

If this works, then change in global_entry.py

import sys
import time
import requests
from plyer import notification

# def fetch().....

to this

import os
import sys
import time
import requests
from plyer import notification

os.system("osascript -e 'display notification \"{}\"\'".format(txt))

# def fetch().....

As for this comment "When running against JFK/LAX, the script was just hanging for a long time (to me this looked like it was working). Not sure why when I ran against ATL that it immediately crashed and gave me that error log, but JFK/LAX eventually timed out with the same error."

This is expected, mainly because JFK and LAX are very busy and thus typically no appointments are available, and new appointments become available if people cancel their appointment. But at a less busy airport such as ATL, an appointment may already be available and therefore immediately throw the error because it tries to notify.

Hope this helps narrow down the issue for you.

@SummitPatel
Copy link
Contributor Author

This is expected, mainly because JFK and LAX are very busy and thus typically no appointments are available, and new appointments become available if people cancel their appointment. But at a less busy airport such as ATL, an appointment may already be available and therefore immediately throw the error because it tries to notify.

That makes sense, appreciate the clarification on this.

So I followed your other steps and can confirm it's the plyer package. I was able to get a system notification to pop up using s.system("osascript -e 'display notification \"{}\"\'".format(message) in global_entry.py.

Thanks for your help on this! I'll submit a PR shortly for you to review if you'd like to incorporate this change into your repo.

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

2 participants