Merge lp:~sergiusens/phablet-tools/1228129 into lp:phablet-tools

Proposed by Sergio Schvezov
Status: Merged
Approved by: Alan Pope 🍺🐧🐱 πŸ¦„
Approved revision: 212
Merged at revision: 214
Proposed branch: lp:~sergiusens/phablet-tools/1228129
Merge into: lp:phablet-tools
Diff against target: 29 lines (+15/-0)
1 file modified
phabletutils/environment.py (+15/-0)
To merge this branch: bzr merge lp:~sergiusens/phablet-tools/1228129
Reviewer Review Type Date Requested Status
Alan Pope 🍺🐧🐱 πŸ¦„ (community) Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+192229@code.launchpad.net

Commit message

phablet-flash: Adding a friendly error message when device detection fails

Description of the change

Adding a friendly error message when device detection fails

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Alan Pope 🍺🐧🐱 πŸ¦„ (popey) wrote :

It doesn't seem to use the formatting you have in your lines 19-22, but just one long string, which is quite hard to read when words like "operating" split over two lines on a standard size gnome terminal

alan@deep-thought:/tmp/1228129$ ./phablet-flash cdimage-touch
error: device not found
ERROR:phablet-flash:Device either not connected, doesn't have adb enabled or the property system cannot be accessed. Make sure the device is booted into the operating system and that adb is working correctly.

Revision history for this message
Alan Pope 🍺🐧🐱 πŸ¦„ (popey) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'phabletutils/environment.py'
2--- phabletutils/environment.py 2013-10-15 19:30:43 +0000
3+++ phabletutils/environment.py 2013-10-22 19:43:07 +0000
4@@ -29,10 +29,25 @@
5 from phabletutils import projects
6 from phabletutils import settings
7 from phabletutils import ubuntuimage
8+from subprocess import CalledProcessError
9
10 log = logging.getLogger()
11
12
13+def device_friendly_error_message(f):
14+ def wrapper(*args, **kwargs):
15+ try:
16+ return f(*args, **kwargs)
17+ except CalledProcessError:
18+ raise EnvironmentError(
19+ 'Device either not connected, doesn\'t have adb enabled '
20+ 'or the property system cannot be accessed. Make sure the '
21+ 'device is booted into the operating system and that adb '
22+ 'is working correctly.')
23+ return wrapper
24+
25+
26+@device_friendly_error_message
27 def detect_device(serial, device=None):
28 '''If no argument passed determine them from the connected device.'''
29 # Check CyanogenMod property

Subscribers

People subscribed via source and target branches