From a5e3f13ed4e49755ee0b9895dc0ba29584eb27f4 Mon Sep 17 00:00:00 2001 From: Crupuk Date: Mon, 22 Jul 2013 12:59:21 +0200 Subject: Use true timestamp to avoid "Invalid timestamp" With the original version i got : python /usr/lib/python2.6/site-packages/pushover.py --token "NU2LC5g2G9jgVR9eHVLYAUmkFuPeky" --client "FWhJFb5wgV35bmzmaxeV976K1WqaFE" "Hello" Traceback (most recent call last): File "/usr/lib/python2.6/site-packages/pushover.py", line 227, in url_title=args.url_title, timestamp=True) File "/usr/lib/python2.6/site-packages/pushover.py", line 207, in send_message return MessageRequest(payload) File "/usr/lib/python2.6/site-packages/pushover.py", line 104, in __init__ Request.__init__(self, "post", MESSAGE_URL, payload) File "/usr/lib/python2.6/site-packages/pushover.py", line 86, in __init__ raise RequestError(self.answer["errors"]) __main__.RequestError: ==> timestamp is invalid By casting time.time() the error disappears --- pushover.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pushover.py b/pushover.py index 5f5c61f..f6f8e98 100644 --- a/pushover.py +++ b/pushover.py @@ -193,7 +193,7 @@ class Client: raise ValueError("{0}: invalid message parameter".format(key)) if key == "timestamp" and value: - payload[key] = time.time() + payload[key] = int(time.time()) elif key == "sound": if not SOUNDS: get_sounds() -- cgit v1.2.3-70-g09d2 From c69b2b79b81a12f3d15b6f557d63384ff23f6433 Mon Sep 17 00:00:00 2001 From: Crupuk Date: Mon, 26 Aug 2013 16:03:10 +0200 Subject: Update condition for timestamp We need to test boolean only : >>> key="timestamp" >>> value="123456" >>> >>> if key == "timestamp" and value: ... print "Value <> True but, still true" ... else: ... print "value <> True and false" ... Value <> True but, still true --- pushover.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pushover.py b/pushover.py index f6f8e98..0e3f4e6 100644 --- a/pushover.py +++ b/pushover.py @@ -192,7 +192,7 @@ class Client: if key not in valid_keywords: raise ValueError("{0}: invalid message parameter".format(key)) - if key == "timestamp" and value: + if key == "timestamp" and value == True: payload[key] = int(time.time()) elif key == "sound": if not SOUNDS: -- cgit v1.2.3-70-g09d2