Giter VIP home page Giter VIP logo

Comments (28)

jdholtz avatar jdholtz commented on August 9, 2024 1

Apprise looks like a very good option. That’ll cover almost every option a user could want, so I’ll definitely go that route. Thanks!

from auto-southwest-check-in.

jdholtz avatar jdholtz commented on August 9, 2024 1

I have implemented this feature on the notifications branch. Let me know if you have any issues if you choose to use it.

from auto-southwest-check-in.

jdholtz avatar jdholtz commented on August 9, 2024 1

Oh, there are two places it could raise that error and I only handled it for the actual check in part, not getting the flight times. That’s an easy fix.

Would it be useful to get a notification when it succeeds in scheduling a flight or only when it fails?

Also, that custom Exception class works fine. I only implemented it to have a custom error name for now.

from auto-southwest-check-in.

jdholtz avatar jdholtz commented on August 9, 2024 1

I added notifications to be sent when scheduling flights on both success and failure. I like the idea of having different levels to sending the notifications. I'll add that in the future as well.

from auto-southwest-check-in.

molmedo1 avatar molmedo1 commented on August 9, 2024 1

Hey @molmedo1. Are you on the notifications branch in your repository? You can check by executing the command ‘git branch’ and seeing which branch is highlighted.

If you are, can you check the southwest.py file and see if there is a statement ‘if arguments[1] == “—test-notifications”’ on line 7?

ugh..i wasnt in notifications branch. Switched over and voila.....

$ python3 southwest.py --test-notifications
Sending test notifications...

Thanks JD!

from auto-southwest-check-in.

helpdeskdan avatar helpdeskdan commented on August 9, 2024 1

Worked great for me, but I'd expect you would want to test it yourself.

As for separation, I mean something like this:

Person A Got B-1
Person B Got B-2
Person C Got B-3
Person D Got B-4
Person E Got B-5

Person A got B-10
Person B got B-11
Person C got B-12
Person D got B-13
Person E got B-14

Now, if you wanted to separate each section with "Flight Number XXXX" instead of \n, that would be even better, but a simple carriage return would make it more readable.

from auto-southwest-check-in.

jdholtz avatar jdholtz commented on August 9, 2024

Yes, there are a few ways. I was planning on implementing that soon. Would you prefer a specific way of communication? Email, text message, webhooks, etc?

from auto-southwest-check-in.

austinliuu avatar austinliuu commented on August 9, 2024

Would recommend integrating with https://github.com/caronc/apprise or similar framework so you don't need to reinvent the wheel, but I think simple email should work too

from auto-southwest-check-in.

austinliuu avatar austinliuu commented on August 9, 2024

Awesome. I tested the branch and the test message works good, but notifications seem not to be triggered when there is a 400 Bad Request error.
(I don't have an upcoming trip for now[next flight in Aug😞] so I typed some random confirmation code and name, would that be considered as one of the "Error cases"? Can you try?)

Tested on my Raspberry pi 4 (Python 3.9.2, maybe it works on Python 3.10?)

user@raspberrypi:~/Desktop/auto-southwest-check-in $ python southwest.py ABSDW AW LD
https://github.com/electron/electron/releases/download/v17.0.0-beta.4/chromedriver-v17.0.0-beta.4-linux-arm64.zip
/home/user/.local/share/undetected_chromedriver/chromedriver
Traceback (most recent call last):
  File "/home/user/Desktop/auto-southwest-check-in/southwest.py", line 32, in <module>
    set_up(arguments)
  File "/home/user/Desktop/auto-southwest-check-in/southwest.py", line 23, in set_up
    account.get_checkin_info(confirmation_number)
  File "/home/user/Desktop/auto-southwest-check-in/lib/account.py", line 52, in get_checkin_info
    self._get_reservation_info(confirmation_number)
  File "/home/user/Desktop/auto-southwest-check-in/lib/account.py", line 62, in _get_reservation_info
    response = make_request("GET", site, self.headers, info)
  File "/home/user/Desktop/auto-southwest-check-in/lib/general.py", line 29, in make_request
    raise CheckInError(response.reason + " " + str(response.status_code))
lib.general.CheckInError: Bad Request 400

from auto-southwest-check-in.

austinliuu avatar austinliuu commented on August 9, 2024

Might because of

class CheckInError(Exception):

has not been implemented

from auto-southwest-check-in.

austinliuu avatar austinliuu commented on August 9, 2024

👍
I would say for me notifications on both succeed and failed check-ins are useful, so user could understand what's going on. (More like how would you choose log level between INFO or ERROR)

from auto-southwest-check-in.

molmedo1 avatar molmedo1 commented on August 9, 2024

script works but i cant figure out " python3 southwest.py --test-notifications" I get Invalid Arguments. Below is my config.json which i saved in "auto-southwest-check-in" folder:

{
"notification_urls": "pbul://o.MYTOKENOFCOURSE",
"notification_level": 1
}

I tested apprise and receive a pushbullet notification just fine. What am I missing here??

thanks,
mario

from auto-southwest-check-in.

jdholtz avatar jdholtz commented on August 9, 2024

Hey @molmedo1. Are you on the notifications branch in your repository? You can check by executing the command ‘git branch’ and seeing which branch is highlighted.

If you are, can you check the southwest.py file and see if there is a statement ‘if arguments[1] == “—test-notifications”’ on line 7?

from auto-southwest-check-in.

helpdeskdan avatar helpdeskdan commented on August 9, 2024
$ cp config.example.json config.json
$ python3 southwest.py --test-notifications
Error in configuration file:
unsupported operand type(s) for |: 'type' and 'type'

That doesn't make sense

from auto-southwest-check-in.

helpdeskdan avatar helpdeskdan commented on August 9, 2024
>>> from enum import IntEnum
>>> class NotificationLevel(IntEnum):
...     INFO = 1
...     ERROR = 2
... 
>>>
>>> notification_level = NotificationLevel.INFO
>>> notification_level
<NotificationLevel.INFO: 1>
>>> notification_level == 1
True
>>> notification_level == 2
False
>>> import json
>>> with open ("/home/dan/config.json") as file:
...      config = json.load(file)
... 
>>> config["notification_level"]
1
>>> isinstance(config["notification_level"], int)
True

It parses the info, why's it throw the darn exception? Drivin' me nuts!

from auto-southwest-check-in.

helpdeskdan avatar helpdeskdan commented on August 9, 2024

Gah! It was staring me right in the face! If I weren't ill, I'd have gotten it earlier. Should be:

            #if not isinstance(self.notification_urls, list | str):
            if not isinstance(self.notification_urls, (list, str)):

from auto-southwest-check-in.

jdholtz avatar jdholtz commented on August 9, 2024

Hey @helpdeskdan. Are you using Python 3.10+? If you look at the note in the documentation for the isinstance function (https://docs.python.org/3/library/functions.html#isinstance), it says the function now supports Union types.

from auto-southwest-check-in.

helpdeskdan avatar helpdeskdan commented on August 9, 2024

I figured it had to be something like that. Ubuntu 20.04 is still on 3.8.10. I'm baffled as to why Gmail striped the \n's (one big paragraph!), but your Python itself appears to work flawlessly with Apprise. Thanks a bunch!

from auto-southwest-check-in.

jdholtz avatar jdholtz commented on August 9, 2024

@helpdeskdan Thanks for mentioning that. I just looked into it and I found out that I can set a default formatting for Apprise to use which would correctly escape the newline characters. Unfortunately, there is a bug in Apprise which makes it not format correctly. It is already fixed, but not in the newest release, so I will wait for that to fix the formatting.

In the meantime, you can explicitly add &format=text to your Gmail URL for it to work correctly. Reference

from auto-southwest-check-in.

helpdeskdan avatar helpdeskdan commented on August 9, 2024

That work around works well, thanks for that! I might recommend that minor change to isinstance for backward compatibility, as a many people do not run python 3.10 yet. Minor suggestion: Might be nice to have a separator - if somebody had 4 flights and 8 people, it might be a bit hard to read. Anyway, thanks again for your work!

from auto-southwest-check-in.

jdholtz avatar jdholtz commented on August 9, 2024

That would make sense to make it backwards compatible. I’ll adjust it and test to make sure everything runs correctly.

For the suggestion - Are you suggesting something like a blank line after each success/error message? That seems like a good thing to add for the user. Thanks!

from auto-southwest-check-in.

jdholtz avatar jdholtz commented on August 9, 2024

Hey @helpdeskdan. I looked into making a separator when displaying the check-in results. I noticed that on success messages with multiple flights, they seem to be separated correctly already. When I'm testing, this is what I'm seeing with multiple flights:

Checking in to flight from <departure-airport> to <destination-airport> for <name>

Checking in to flight from <departure-airport> to <destination-airport> for <name> <--- flight 2, the same flight just a different reservation

Successfully checked in to flight from <departure-airport> to <destination-airport> for <name>!
Person A got B10
Person B got B11
Person C got B12

Successfully checked in to flight from <departure-airport> to <destination-airport> for <name>!
Person A got B18
Person B got B19

Is this what you mean when you want it to separate each section? I did notice it not separating correctly for error messages, but I'll fix that.

from auto-southwest-check-in.

austinliuu avatar austinliuu commented on August 9, 2024

Hi @jdholtz just would let you know the notification works good. Thanks for all the work!
1267E8F8-C46B-48BF-A23F-36C1289B90E2

from auto-southwest-check-in.

jdholtz avatar jdholtz commented on August 9, 2024

@austinliuu Glad to hear! Thanks for requesting this feature.

from auto-southwest-check-in.

helpdeskdan avatar helpdeskdan commented on August 9, 2024

Hey @helpdeskdan. I looked into making a separator when displaying the check-in results. I noticed that on success messages with multiple flights, they seem to be separated correctly already. When I'm testing, this is what I'm seeing with multiple flights:

I don't see that at all, I see:

Successfully checked in to flight yada yada
Person A got yada
Person B got yada
yada yada big family
Person X got yaya
Person A got yada
Person B got yada
ect

Curious why you don't see the same. Oh well, not a huge problem. (I'm not exactly a frequent flier) Thanks again for the awesome project, was really handy when I they cancelled my flight three times in a row.

from auto-southwest-check-in.

jdholtz avatar jdholtz commented on August 9, 2024

Interesting. This is what is printed in the terminal, right?

from auto-southwest-check-in.

helpdeskdan avatar helpdeskdan commented on August 9, 2024

Not sure, I just know that is how it was in the email

from auto-southwest-check-in.

jdholtz avatar jdholtz commented on August 9, 2024

Okay. I only tested what was printed to the console. You should be receiving only one notification per flight. I’ll look into that

from auto-southwest-check-in.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.