LeftyBC / weebullet

Weechat script to push notifications to Pushbullet
BSD 2-Clause "Simplified" License
28 stars 14 forks source link

Error in functions #16

Open shirgoldbird opened 8 years ago

shirgoldbird commented 8 years ago

When a new highlight comes through I get this error:

15:03:57 https://[api key removed]@api.pushbullet.com/v2/pushes [pushover] Debug: msg -> `[#jekyll-rp_logs] <Gael> thamaniya test' HTTP POST -> type=note device_iden=[device iden removed] title=weechat body=%5B%23jekyll-rp_logs%5D%20%3CGael%3E%20thamaniya%20test
15:03:57 python: stdout/stderr: Traceback (most recent call last):
15:03:57 python: stdout/stderr:   File "/home/sheva/.weechat/python/weebullet.py", line 161, in process_pushbullet_cb
15:03:57 python: stdout/stderr:     status_code = int(lines.pop(0).split()[1])
15:03:57 python: stdout/stderr: IndexError: pop from empty list
15:03:57 =!= python: error in function "process_pushbullet_cb"

When running /weebullet listdevices:

15:51:45 python: stdout/stderr: Traceback (most recent call last):
15:51:45 python: stdout/stderr:   File "/home/sheva/.weechat/python/weebullet.py", line 82, in process_devicelist_cb
15:51:45 python: stdout/stderr:     devices = json.loads(response)["devices"]
15:51:45 python: stdout/stderr:   File "/usr/lib/python2.7/json/__init__.py", line 338, in loads
15:51:45 python: stdout/stderr:     return _default_decoder.decode(s)
15:51:45 python: stdout/stderr:   File "/usr/lib/python2.7/json/decoder.py", line 366, in decode
15:51:45 python: stdout/stderr:     obj, end = self.raw_decode(s, idx=_w(s, 0).end())
15:51:45 python: stdout/stderr:   File "/usr/lib/python2.7/json/decoder.py", line 384, in raw_decode
15:51:45 python: stdout/stderr:     raise ValueError("No JSON object could be decoded")
15:51:45 python: stdout/stderr: ValueError: No JSON object could be decoded
15:51:45 =!= python: error in function "process_devicelist_cb"

Any idea what's causing this? My API key and device ID are both correct.

LeftyBC commented 8 years ago

Hi Sheva - I've seen this once before when hitting a ratelimit in the Pushbullet API - it returns an X-Ratelimited header and no data. It's unfortunately a bit difficult to reproduce as the ratelimit is on the Pushbullet side.

guyhughes commented 8 years ago

@LeftyBC Thanks for the great script. Hmm, just wondering, would you be open to a patch parsing the ratelimit headers? https://docs.pushbullet.com/#ratelimiting

LeftyBC commented 8 years ago

Sure, @guyhughes if you're willing to submit patches I'd be happy to merge them up.