From c6fd260e9592d4a035ee5ad592a9ca303ca1bdd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Pag=C3=A8s?= Date: Mon, 4 Jan 2016 16:29:36 +0100 Subject: [PATCH] Bug 1236467 - [mozdevice] raise exception when missing devices access permissions. r=ahal Also bump the version to 0.48. --HG-- extra : rebase_source : a79be8684a51a529a6b163c9bac378a199ab6961 --- testing/mozbase/mozdevice/mozdevice/adb.py | 19 +++++++++++++++++++ testing/mozbase/mozdevice/setup.py | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/testing/mozbase/mozdevice/mozdevice/adb.py b/testing/mozbase/mozdevice/mozdevice/adb.py index a437f51b5286..5d5ca8eaccee 100644 --- a/testing/mozbase/mozdevice/mozdevice/adb.py +++ b/testing/mozbase/mozdevice/mozdevice/adb.py @@ -67,6 +67,16 @@ class ADBError(Exception): """ pass +class ADBListDevicesError(ADBError): + """ADBListDevicesError is raised when errors are found listing the + devices, typically not any permissions. + + The devices information is stocked with the *devices* member. + """ + def __init__(self, msg, devices): + ADBError.__init__(self, msg) + self.devices = devices + class ADBRootError(Exception): """ADBRootError is raised when a shell command is to be executed as root but the device does not support it. This error is fatal since @@ -432,6 +442,7 @@ class ADBHost(ADBCommand): :type timeout: integer or None :returns: an object contain :raises: * ADBTimeoutError + * ADBListDevicesError * ADBError The output of adb devices -l :: @@ -468,6 +479,14 @@ class ADBHost(ADBCommand): self._logger.warning('devices: Unable to parse ' 'remainder for device %s' % line) devices.append(device) + for device in devices: + if device['state'] == 'no permissions': + raise ADBListDevicesError( + "No permissions to detect devices. You should restart the" + " adb server as root:\n" + "\n# adb kill-server\n# adb start-server\n" + "\nor maybe configure your udev rules.", + devices) return devices diff --git a/testing/mozbase/mozdevice/setup.py b/testing/mozbase/mozdevice/setup.py index 6cfe12507403..6c241d043209 100644 --- a/testing/mozbase/mozdevice/setup.py +++ b/testing/mozbase/mozdevice/setup.py @@ -5,7 +5,7 @@ from setuptools import setup PACKAGE_NAME = 'mozdevice' -PACKAGE_VERSION = '0.47' +PACKAGE_VERSION = '0.48' deps = ['mozfile >= 1.0', 'mozlog >= 3.0',