Bug 1102140 - [mozversion] Support the ADB server running on an alternate host/port. r=wlachance

This commit is contained in:
Dave Hunt 2014-11-28 09:59:23 +00:00
parent 30643d405b
commit 088c44f09a
2 changed files with 25 additions and 9 deletions

View File

@ -181,11 +181,14 @@ class LocalB2GVersion(B2GVersion):
class RemoteB2GVersion(B2GVersion):
def __init__(self, sources=None, dm_type='adb', host=None,
device_serial=None, **kwargs):
device_serial=None, adb_host=None, adb_port=None,
**kwargs):
B2GVersion.__init__(self, sources, **kwargs)
if dm_type == 'adb':
dm = mozdevice.DeviceManagerADB(deviceSerial=device_serial)
dm = mozdevice.DeviceManagerADB(deviceSerial=device_serial,
serverHost=adb_host,
serverPort=adb_port)
elif dm_type == 'sut':
if not host:
raise errors.RemoteAppNotFoundError(
@ -241,7 +244,7 @@ class RemoteB2GVersion(B2GVersion):
def get_version(binary=None, sources=None, dm_type=None, host=None,
device_serial=None):
device_serial=None, adb_host=None, adb_port=None):
"""
Returns the application version information as a dict. You can specify
a path to the binary of the application or an Android APK file (to get
@ -255,6 +258,8 @@ def get_version(binary=None, sources=None, dm_type=None, host=None,
:param dm_type: Device manager type. Must be 'adb' or 'sut' (Firefox OS)
:param host: Host address of remote Firefox OS instance (SUT)
:param device_serial: Serial identifier of Firefox OS device (ADB)
:param adb_host: Host address of ADB server
:param adb_port: Port of ADB server
"""
try:
if binary and zipfile.is_zipfile(binary) and 'AndroidManifest.xml' in \
@ -271,6 +276,8 @@ def get_version(binary=None, sources=None, dm_type=None, host=None,
version = RemoteB2GVersion(sources=sources,
dm_type=dm_type,
host=host,
adb_host=adb_host,
adb_port=adb_port,
device_serial=device_serial)
for (key, value) in sorted(version._info.items()):
@ -286,12 +293,19 @@ def cli(args=sys.argv[1:]):
parser.add_argument(
'--binary',
help='path to application binary or apk')
parser.add_argument(
fxos = parser.add_argument_group('Firefox OS')
fxos.add_argument(
'--sources',
help='path to sources.xml (Firefox OS only)')
parser.add_argument(
help='path to sources.xml')
fxos.add_argument(
'--device',
help='serial identifier of device to target (Firefox OS only)')
help='serial identifier of device to target')
fxos.add_argument(
'--adb-host',
help='host running adb')
fxos.add_argument(
'--adb-port',
help='port running adb')
structured.commandline.add_logging_group(parser)
args = parser.parse_args()
@ -305,7 +319,9 @@ def cli(args=sys.argv[1:]):
sources=args.sources,
dm_type=dm_type,
host=host,
device_serial=args.device)
device_serial=args.device,
adb_host=args.adb_host,
adb_port=args.adb_port)
if __name__ == '__main__':
cli()

View File

@ -6,7 +6,7 @@ from setuptools import setup
PACKAGE_VERSION = '1.0'
dependencies = ['mozdevice >= 0.29',
dependencies = ['mozdevice >= 0.44',
'mozfile >= 1.0',
'mozlog >= 2.0']