|
@@ -0,0 +1,260 @@
|
|
|
+# HG changeset patch
|
|
|
+# User William Lachance <wlachance@mozilla.com>
|
|
|
+# Date 1541881028 0
|
|
|
+# Node ID e93794d169f164f424c591f248a5aa657b7adfb7
|
|
|
+# Parent c4075a2c6e9f854cd640af0027e43bb11860a8cd
|
|
|
+Summary: Bug 1506385 - Remove b2g support and unnecessary dependencies from mozdevice r=bc
|
|
|
+
|
|
|
+Differential Revision: https://phabricator.services.mozilla.com/D11564
|
|
|
+
|
|
|
+diff --git a/testing/mozbase/docs/mozdevice.rst.1506385.later b/testing/mozbase/docs/mozdevice.rst.1506385.later
|
|
|
+new file mode 100644
|
|
|
+--- /dev/null
|
|
|
++++ b/testing/mozbase/docs/mozdevice.rst.1506385.later
|
|
|
+@@ -0,0 +1,45 @@
|
|
|
++--- mozdevice.rst
|
|
|
+++++ mozdevice.rst
|
|
|
++@@ -1,12 +1,12 @@
|
|
|
++-:mod:`mozdevice` --- Interact with Android or B2G devices
|
|
|
++-=========================================================
|
|
|
+++:mod:`mozdevice` --- Interact with Android devices
|
|
|
+++==================================================
|
|
|
++
|
|
|
++-Mozdevice provides several interfaces to interact with an Android or B2G
|
|
|
+++Mozdevice provides several interfaces to interact with an Android
|
|
|
++ device such as a phone, tablet, or emulator. It allows you to push
|
|
|
++ files to these types of devices, launch processes, and more. There are
|
|
|
++ currently two available interfaces:
|
|
|
++
|
|
|
++ * :ref:`ADB`: Uses the Android Debugger Protocol explicitly
|
|
|
++
|
|
|
++ .. automodule:: mozdevice
|
|
|
++
|
|
|
++@@ -111,26 +111,16 @@ Application management methods
|
|
|
++ .. automethod:: ADBAndroid.is_app_installed
|
|
|
++ .. automethod:: ADBAndroid.launch_application
|
|
|
++ .. automethod:: ADBAndroid.launch_fennec
|
|
|
++ .. automethod:: ADBAndroid.launch_geckoview_example
|
|
|
++ .. automethod:: ADBAndroid.stop_application
|
|
|
++ .. automethod:: ADBAndroid.uninstall_app
|
|
|
++ .. automethod:: ADBAndroid.update_app
|
|
|
++
|
|
|
++-ADBB2G
|
|
|
++-``````
|
|
|
++-.. autoclass:: ADBB2G
|
|
|
++-
|
|
|
++-Informational methods
|
|
|
++-+++++++++++++++++++++
|
|
|
++-.. automethod:: ADBB2G.get_battery_percentage
|
|
|
++-.. automethod:: ADBB2G.get_info
|
|
|
++-.. automethod:: ADBB2G.get_memory_total
|
|
|
++-
|
|
|
++ ADBProcess
|
|
|
++ ``````````
|
|
|
++ .. autoclass:: mozdevice.ADBProcess
|
|
|
++
|
|
|
++ ADBError
|
|
|
++ ````````
|
|
|
++ .. autoexception:: mozdevice.ADBError
|
|
|
++
|
|
|
+diff --git a/testing/mozbase/mozdevice/mozdevice/__init__.py b/testing/mozbase/mozdevice/mozdevice/__init__.py
|
|
|
+--- a/testing/mozbase/mozdevice/mozdevice/__init__.py
|
|
|
++++ b/testing/mozbase/mozdevice/mozdevice/__init__.py
|
|
|
+@@ -2,12 +2,11 @@
|
|
|
+ # License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
|
+ # You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
+
|
|
|
+ from __future__ import absolute_import
|
|
|
+
|
|
|
+ from .adb import ADBError, ADBProcessError, ADBRootError, ADBTimeoutError
|
|
|
+ from .adb import ADBProcess, ADBCommand, ADBHost, ADBDevice
|
|
|
+ from .adb_android import ADBAndroid
|
|
|
+-from .adb_b2g import ADBB2G
|
|
|
+
|
|
|
+ __all__ = ['ADBError', 'ADBProcessError', 'ADBRootError', 'ADBTimeoutError',
|
|
|
+- 'ADBProcess', 'ADBCommand', 'ADBHost', 'ADBDevice', 'ADBAndroid', 'ADBB2G']
|
|
|
++ 'ADBProcess', 'ADBCommand', 'ADBHost', 'ADBDevice', 'ADBAndroid']
|
|
|
+diff --git a/testing/mozbase/mozdevice/mozdevice/adb.py b/testing/mozbase/mozdevice/mozdevice/adb.py
|
|
|
+--- a/testing/mozbase/mozdevice/mozdevice/adb.py
|
|
|
++++ b/testing/mozbase/mozdevice/mozdevice/adb.py
|
|
|
+@@ -503,19 +503,19 @@ class ADBHost(ADBCommand):
|
|
|
+ "\n# adb kill-server\n# adb start-server\n"
|
|
|
+ "\nor maybe configure your udev rules.",
|
|
|
+ devices)
|
|
|
+ return devices
|
|
|
+
|
|
|
+
|
|
|
+ class ADBDevice(ADBCommand):
|
|
|
+ """ADBDevice is an abstract base class which provides methods which
|
|
|
+- can be used to interact with the associated Android or B2G based
|
|
|
+- device. It must be used via one of the concrete implementations in
|
|
|
+- :class:`ADBAndroid` or :class:`ADBB2G`.
|
|
|
++ can be used to interact with the associated Android-based
|
|
|
++ device. It must be used via the concrete implementation in
|
|
|
++ :class:`ADBAndroid`.
|
|
|
+ """
|
|
|
+ __metaclass__ = ABCMeta
|
|
|
+
|
|
|
+ SOCKET_DIRECTON_REVERSE = "reverse"
|
|
|
+ SOCKET_DIRECTON_FORWARD = "forward"
|
|
|
+
|
|
|
+ def __init__(self,
|
|
|
+ device=None,
|
|
|
+diff --git a/testing/mozbase/mozdevice/mozdevice/adb_b2g.py b/testing/mozbase/mozdevice/mozdevice/adb_b2g.py
|
|
|
+deleted file mode 100644
|
|
|
+--- a/testing/mozbase/mozdevice/mozdevice/adb_b2g.py
|
|
|
++++ /dev/null
|
|
|
+@@ -1,124 +0,0 @@
|
|
|
+-# This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
+-# License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
|
+-# You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
+-
|
|
|
+-from __future__ import absolute_import
|
|
|
+-
|
|
|
+-import traceback
|
|
|
+-
|
|
|
+-import mozfile
|
|
|
+-
|
|
|
+-from .adb import ADBDevice, ADBError
|
|
|
+-
|
|
|
+-
|
|
|
+-class ADBB2G(ADBDevice):
|
|
|
+- """ADBB2G implements :class:`ADBDevice` providing B2G-specific
|
|
|
+- functionality.
|
|
|
+-
|
|
|
+- ::
|
|
|
+-
|
|
|
+- from mozdevice import ADBB2G
|
|
|
+-
|
|
|
+- adbdevice = ADBB2G()
|
|
|
+- print adbdevice.list_files("/mnt/sdcard")
|
|
|
+- if adbdevice.process_exist("b2g"):
|
|
|
+- print "B2G is running"
|
|
|
+- """
|
|
|
+-
|
|
|
+- def get_battery_percentage(self, timeout=None):
|
|
|
+- """Returns the battery charge as a percentage.
|
|
|
+-
|
|
|
+- :param timeout: optional integer specifying the maximum time in
|
|
|
+- seconds for any spawned adb process to complete before
|
|
|
+- throwing an ADBTimeoutError.
|
|
|
+- This timeout is per adb call. The total time spent
|
|
|
+- may exceed this value. If it is not specified, the value
|
|
|
+- set in the ADBDevice constructor is used.
|
|
|
+- :returns: battery charge as a percentage.
|
|
|
+- :raises: * ADBTimeoutError
|
|
|
+- * ADBError
|
|
|
+- """
|
|
|
+- with mozfile.NamedTemporaryFile() as tf:
|
|
|
+- self.pull('/sys/class/power_supply/battery/capacity', tf.name,
|
|
|
+- timeout=timeout)
|
|
|
+- try:
|
|
|
+- with open(tf.name) as tf2:
|
|
|
+- return tf2.read().splitlines()[0]
|
|
|
+- except Exception as e:
|
|
|
+- raise ADBError(traceback.format_exception_only(
|
|
|
+- type(e), e)[0].strip())
|
|
|
+-
|
|
|
+- def get_memory_total(self, timeout=None):
|
|
|
+- """Returns the total memory available with units.
|
|
|
+-
|
|
|
+- :param timeout: optional integer specifying the maximum time in
|
|
|
+- seconds for any spawned adb process to complete before
|
|
|
+- throwing an ADBTimeoutError.
|
|
|
+- This timeout is per adb call. The total time spent
|
|
|
+- may exceed this value. If it is not specified, the value
|
|
|
+- set in the ADBDevice constructor is used.
|
|
|
+- :returns: memory total with units.
|
|
|
+- :raises: * ADBTimeoutError
|
|
|
+- * ADBError
|
|
|
+- """
|
|
|
+- meminfo = {}
|
|
|
+- with mozfile.NamedTemporaryFile() as tf:
|
|
|
+- self.pull('/proc/meminfo', tf.name, timeout=timeout)
|
|
|
+- try:
|
|
|
+- with open(tf.name) as tf2:
|
|
|
+- for line in tf2.read().splitlines():
|
|
|
+- key, value = line.split(':')
|
|
|
+- meminfo[key] = value.strip()
|
|
|
+- except Exception as e:
|
|
|
+- raise ADBError(traceback.format_exception_only(
|
|
|
+- type(e), e)[0].strip())
|
|
|
+- return meminfo['MemTotal']
|
|
|
+-
|
|
|
+- def get_info(self, directive=None, timeout=None):
|
|
|
+- """
|
|
|
+- Returns a dictionary of information strings about the device.
|
|
|
+-
|
|
|
+- :param directive: information you want to get. Options are:
|
|
|
+- - `battery` - battery charge as a percentage
|
|
|
+- - `disk` - total, free, available bytes on disk
|
|
|
+- - `id` - unique id of the device
|
|
|
+- - `memtotal` - total memory available on the device
|
|
|
+- - `os` - name of the os
|
|
|
+- - `process` - list of running processes (same as ps)
|
|
|
+- - `systime` - system time of the device
|
|
|
+- - `uptime` - uptime of the device
|
|
|
+-
|
|
|
+- If `directive` is `None`, will return all available information
|
|
|
+- :param timeout: optional integer specifying the maximum time in
|
|
|
+- seconds for any spawned adb process to complete before
|
|
|
+- throwing an ADBTimeoutError.
|
|
|
+- This timeout is per adb call. The total time spent
|
|
|
+- may exceed this value. If it is not specified, the value
|
|
|
+- set in the ADB constructor is used.
|
|
|
+- :raises: * ADBTimeoutError
|
|
|
+- * ADBError
|
|
|
+- """
|
|
|
+- info = super(ADBB2G, self).get_info(directive=directive,
|
|
|
+- timeout=timeout)
|
|
|
+-
|
|
|
+- directives = ['memtotal']
|
|
|
+- if directive in directives:
|
|
|
+- directives = [directive]
|
|
|
+-
|
|
|
+- if 'memtotal' in directives:
|
|
|
+- info['memtotal'] = self.get_memory_total(timeout=timeout)
|
|
|
+- return info
|
|
|
+-
|
|
|
+- def is_device_ready(self, timeout=None):
|
|
|
+- """Returns True if the device is ready.
|
|
|
+-
|
|
|
+- :param timeout: optional integer specifying the maximum time in
|
|
|
+- seconds for any spawned adb process to complete before
|
|
|
+- throwing an ADBTimeoutError.
|
|
|
+- This timeout is per adb call. The total time spent
|
|
|
+- may exceed this value. If it is not specified, the value
|
|
|
+- set in the ADB constructor is used.
|
|
|
+- :raises: * ADBTimeoutError
|
|
|
+- * ADBError
|
|
|
+- """
|
|
|
+- return self.shell_bool('ls /sbin', timeout=timeout)
|
|
|
+diff --git a/testing/mozbase/mozdevice/setup.py b/testing/mozbase/mozdevice/setup.py
|
|
|
+--- a/testing/mozbase/mozdevice/setup.py
|
|
|
++++ b/testing/mozbase/mozdevice/setup.py
|
|
|
+@@ -3,23 +3,19 @@
|
|
|
+ # License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
|
+ # You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
+
|
|
|
+ from __future__ import absolute_import
|
|
|
+
|
|
|
+ from setuptools import setup
|
|
|
+
|
|
|
+ PACKAGE_NAME = 'mozdevice'
|
|
|
+-PACKAGE_VERSION = '1.1.6'
|
|
|
++PACKAGE_VERSION = '2.0'
|
|
|
+
|
|
|
+-deps = ['mozfile >= 1.0',
|
|
|
+- 'mozlog >= 3.0',
|
|
|
+- 'moznetwork >= 0.24',
|
|
|
+- 'mozprocess >= 0.19',
|
|
|
+- ]
|
|
|
++deps = ['mozlog >= 3.0']
|
|
|
+
|
|
|
+ setup(name=PACKAGE_NAME,
|
|
|
+ version=PACKAGE_VERSION,
|
|
|
+ description="Mozilla-authored device management",
|
|
|
+ long_description="see https://firefox-source-docs.mozilla.org/mozbase/index.html",
|
|
|
+ classifiers=['Programming Language :: Python :: 2.7',
|
|
|
+ 'Programming Language :: Python :: 2 :: Only'],
|
|
|
+ # Get strings from http://pypi.python.org/pypi?%3Aaction=list_classifiers
|