richard-better / pushbullet.py

A python client for http://pushbullet.com
MIT License
575 stars 110 forks source link

Only one notification at a time when pushing to channel. #131

Closed domgregori closed 3 years ago

domgregori commented 6 years ago

When I run my code, it iterates over a list and if matched it sends a notification. When doing this with just my regular push account, I get all the notifications. But when I try with my channel, I only get one of the alerts. After running the code again, I get the next alert pushed to my channel.

I looked through the API and I didn't see any different rate limits for channels.

simonporter007 commented 6 years ago

Any chance you can share some code you used to cycle the list and push to channel, is it a note push?

domgregori commented 6 years ago
pb = Pushbullet('xxx')
my_channel = pb.channels[0]

Then the next code is all in a for loop that iterates over a list of trips. It works fine like this but when I change to my_channel, I only get these first two notifications, then if I run it again I get the next two notification

        if len(trips_set) <= 10 and push:
            try:
                with open('trips.alert', 'rb') as fp:
                    alerts = pickle.load(fp)
            except EOFError:
                alerts = []
            if trip_info not in alerts:
                push = pb.push_note('Trip: ' + trip_info['id'] + ' ' + title, printer)
                push2 = pb.push_note('', fos_code)
                alerts.append(trip_info)
                with open('trips.alert', 'wb') as fp:
                    pickle.dump(alerts, fp)
simonporter007 commented 6 years ago

I can't reproduce this with a basic pushing from a list loop. The code isn't any different for channel or self pushing (via pb instead of my_channel) as they both go via the same end function. I tried to recreate your scenario but there's too much left out to create an exact copy from what you've given.

from pushbullet import Pushbullet

pb = Pushbullet('xxxxxxxxxxxxxxxxxxxxx')
my_channel = pb.channels[0]

trips_set = [{"title": "Title test 1", "body": "Body test 1", "fos_code": "TEST 1"},
             {"title": "Title test 2", "body": "Body test 2", "fos_code": "TEST 2"},
             {"title": "Title test 3", "body": "Body test 3", "fos_code": "TEST 3"},
             {"title": "Title test 4", "body": "Body test 4", "fos_code": "TEST 4"},
             {"title": "Title test 5", "body": "Body test 5", "fos_code": "TEST 5"}]

if len(trips_set) <= 10:
    for trip in trips_set:
        push = my_channel.push_note('Trip: ' + trip["title"], trip["body"])
        push2 = my_channel.push_note('', trip["fos_code"])

Could you add some debugging to see what you're calling and then try and call it from the command line to see the response from pushbullet itself?

domgregori commented 6 years ago

So this is the response when I do a regular push note: {u'body': u'Seq: 3531/I/P03\nLayover: 22 UIO 34.17\nOrig: 22MAR 0930\nTerm: 24MAR 1150\nAircrafts: 737 757 \nHours: 10.58\nLegs: 3-1\nEmp: xxxxxx 000-000-0000\nJUST TAKE LONG UIO GET THINGS DONE THANKS\nID: ZBZK\n', u'iden': u'ujvIzj4W3C8sjAxx4Xvifc', u'created': 1519912707.0172255, u'sender_name': u'me', u'title': u'Trip: ZBZK UIO , start date: 22MAR', u'direction': u'self', u'modified': 1519912707.0288374, u'dismissed': False, u'sender_email_normalized': u'me@gmail.com', u'receiver_email': u'me@gmail.com', u'sender_email': u'me@gmail.com', u'active': True, u'receiver_iden': u'ujvIzj4W3C8', u'sender_iden': u'ujvIzj4W3C8', u'type': u'note', u'receiver_email_normalized': u'me@gmail.com'}

But then if I change it to my_channel, I still get just one notifications but the response is just an empty dictionary {}

simonporter007 commented 6 years ago

I don't think we'll get much further. The response from push to channel doesn't look like it raised an error but you got an empty response which suggests it should. I've added some extra debugging to pushbullet.py inside pushbullet directory. If you could find that in your local site-packages and replace it - we might be able to see more useful information when you next run a test? pushbullet.zip

domgregori commented 6 years ago

My friend,

Sorry for the delay. I replaced pushbullet.py but did not get any different results when running?

simonporter007 commented 6 years ago

Sorry for my delay! That's strange. When I replaced that file with the debug version, it does print out the json data it is about to send and then if it hits an error, it should print that out also.

Can you double check the file you replaced? If you open up the python prompt from where you are running you application, then import pushbullet and print pushbullet.__file__ that should give you the location of the pushbullet.py file that should be replaced.