Bug 755856 - look for adb in path first for mozdevice emulator automation, r=jgriffin

This commit is contained in:
Malini Das 2012-08-23 15:46:48 -04:00
Родитель 991a87a528
Коммит 0cc15146bd
2 изменённых файлов: 21 добавлений и 12 удалений

Просмотреть файл

@ -29,10 +29,17 @@ class B2GEmulator(Emulator):
'B2G_HOME correctly?') % filePath)
def _check_for_adb(self, host_dir):
self.adb = os.path.join(self.homedir, 'out', 'host', host_dir, 'bin', 'adb')
if not os.path.exists(self.adb):
self.adb = os.path.join(self.homedir, 'bin/adb')
super(B2GEmulator, self)._check_for_adb()
if self._default_adb() == 0:
return
adb_paths = [os.path.join(self.homedir,'glue','gonk','out','host',
host_dir ,'bin','adb'),os.path.join(self.homedir, 'out',
'host', host_dir,'bin','adb'),os.path.join(self.homedir,
'bin','adb')]
for option in adb_paths:
if os.path.exists(option):
self.adb = option
return
raise Exception('adb not found!')
def _locate_files(self):
if self.homedir is None:

Просмотреть файл

@ -87,17 +87,19 @@ class Emulator(object):
else:
return self.port is not None
def _default_adb(self):
adb = subprocess.Popen(['which', 'adb'],
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
retcode = adb.wait()
if retcode == 0:
self.adb = adb.stdout.read().strip() # remove trailing newline
return retcode
def _check_for_adb(self):
if not os.path.exists(self.adb):
adb = subprocess.Popen(['which', 'adb'],
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
retcode = adb.wait()
if retcode:
if self._default_adb() != 0:
raise Exception('adb not found!')
out = adb.stdout.read().strip()
if len(out) and out.find('/') > -1:
self.adb = out
def _run_adb(self, args):
args.insert(0, self.adb)