summaryrefslogtreecommitdiff
path: root/pebble
diff options
context:
space:
mode:
authorGulsah Kose <gulsah.1004@gmail.com>2015-01-13 13:25:31 +0200
committerGulsah Kose <gulsah.1004@gmail.com>2015-01-13 13:25:31 +0200
commit2521e0380f0b25346d368f68cdd42e50d29c9e47 (patch)
tree87b02fdaf4c18717c4fc51f93cd7e49805908c34 /pebble
parent05a6a55226776f0f8aba3eb41dd6455ab4c00848 (diff)
Added error handling for PebbleError and LightBlueError exceptions
Diffstat (limited to 'pebble')
-rwxr-xr-xpebble/libpebble/p.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/pebble/libpebble/p.py b/pebble/libpebble/p.py
index 6967cae..2293d88 100755
--- a/pebble/libpebble/p.py
+++ b/pebble/libpebble/p.py
@@ -6,11 +6,21 @@ import pebble as libpebble
import time
import pexpect
import i18n
+import tkMessageBox
+
+from Tkinter import *
_ = i18n.language.gettext
MAX_ATTEMPTS = 5
+window = Tk()
+window.wm_withdraw()
+window.geometry("1x1+200+200") #remember its .geometry("WidthxHeight(+or-)X(+or-)Y")
+
+LightBluePebbleError = libpebble.LightBluePebble.LightBluePebbleError
+PebbleError = libpebble.pebble.PebbleError
+
def cmd_remote(pebble, args):
path=args.odp_file_path
runodp = args.app_name+" --impress "+path
@@ -70,6 +80,14 @@ def cmd_remote(pebble, args):
try:
pebble.register_endpoint("MUSIC_CONTROL", music_control_handler)
time.sleep(5)
+ except LightBluePebbleError as e:
+ tkMessageBox.showerror(title="Error", message=e._message, parent=window)
+ raise e
+ raise KeyboardInterrupt
+ except PebbleError as e:
+ tkMessageBox.showerror(title="Error", message=e._message, parent=window)
+ raise e
+ raise KeyboardInterrupt
except KeyboardInterrupt:
return
@@ -102,12 +120,27 @@ def main():
pebble_id = os.environ["PEBBLE_ID"]
pebble = libpebble.Pebble(pebble_id, args.lightblue, args.pair)
break
+ except LightBluePebbleError as e:
+ tkMessageBox.showerror(title="Error", message=_("Bluetooth connection error"), parent=window)
+ raise KeyboardInterrupt
+ except PebbleError as e:
+ tkMessageBox.showerror(title="Error", message=e._message, parent=window)
+ raise e
+ raise KeyboardInterrupt
except:
time.sleep(5)
attempts += 1
try:
args.func(pebble, args)
+ except LightBluePebbleError as e:
+ tkMessageBox.showerror(title="Error", message=e._message, parent=window)
+ raise e
+ raise KeyboardInterrupt
+ except PebbleError as e:
+ tkMessageBox.showerror(title="Error", message=e._message, parent=window)
+ raise e
+ raise KeyboardInterrupt
except Exception as e:
pebble.disconnect()
raise e