mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 818080 - Bump mozdevice version to 0.16;r=ahal
This commit is contained in:
parent
0cbb098aeb
commit
2fff568ba4
@ -62,7 +62,7 @@ class DeviceManager:
|
||||
output = str(buf.getvalue()[0:-1]).rstrip()
|
||||
buf.close()
|
||||
if retval != 0:
|
||||
raise DMError("Non-zero return code for command: %s (output: '%s', retval: '%i')" % (cmd, output, retval))
|
||||
raise DMError("Non-zero return code for command: %s (output: '%s', retval: '%s')" % (cmd, output, retval))
|
||||
return output
|
||||
|
||||
@abstractmethod
|
||||
@ -82,14 +82,16 @@ class DeviceManager:
|
||||
Make directory structure on the device
|
||||
WARNING: does not create last part of the path
|
||||
"""
|
||||
parts = filename.split('/')
|
||||
name = ""
|
||||
for part in parts:
|
||||
if (part == parts[-1]):
|
||||
break
|
||||
if (part != ""):
|
||||
name += '/' + part
|
||||
self.mkDir(name) # mkDir will check previous existence
|
||||
dirParts = filename.rsplit('/', 1)
|
||||
if not self.dirExists(dirParts[0]):
|
||||
parts = filename.split('/')
|
||||
name = ""
|
||||
for part in parts:
|
||||
if part == parts[-1]:
|
||||
break
|
||||
if part != "":
|
||||
name += '/' + part
|
||||
self.mkDir(name) # mkDir will check previous existence
|
||||
|
||||
@abstractmethod
|
||||
def pushDir(self, localDir, remoteDir):
|
||||
|
@ -123,7 +123,10 @@ class DeviceManagerADB(DeviceManager):
|
||||
if self._deviceSerial:
|
||||
args.extend(['-s', self._deviceSerial])
|
||||
args.extend(["shell", cmdline])
|
||||
proc = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
|
||||
procOut = tempfile.SpooledTemporaryFile()
|
||||
procErr = tempfile.SpooledTemporaryFile()
|
||||
proc = subprocess.Popen(args, stdout=procOut, stderr=procErr)
|
||||
|
||||
if not timeout:
|
||||
# We are asserting that all commands will complete in this time unless otherwise specified
|
||||
@ -138,8 +141,11 @@ class DeviceManagerADB(DeviceManager):
|
||||
if ret_code == None:
|
||||
proc.kill()
|
||||
raise DMError("Timeout exceeded for shell call")
|
||||
(stdout, stderr) = proc.communicate()
|
||||
outputfile.write(stdout.rstrip('\n'))
|
||||
|
||||
procOut.seek(0)
|
||||
outputfile.write(procOut.read().rstrip('\n'))
|
||||
procOut.close()
|
||||
procErr.close()
|
||||
|
||||
lastline = _pop_last_line(outputfile)
|
||||
if lastline:
|
||||
|
@ -6,6 +6,7 @@
|
||||
Command-line client to control a device
|
||||
"""
|
||||
|
||||
import errno
|
||||
import os
|
||||
import posixpath
|
||||
import StringIO
|
||||
@ -16,7 +17,9 @@ from optparse import OptionParser
|
||||
|
||||
class DMCli(object):
|
||||
|
||||
def __init__(self, args=sys.argv[1:]):
|
||||
def __init__(self):
|
||||
# a value of None for 'max_args' means there is no limit to the number
|
||||
# of arguments. 'min_args' should always have an integer value >= 0.
|
||||
self.commands = { 'install': { 'function': self.install,
|
||||
'min_args': 1,
|
||||
'max_args': 1,
|
||||
@ -48,7 +51,7 @@ class DMCli(object):
|
||||
'help_args': '<command>',
|
||||
'help': 'run shell command on device' },
|
||||
'info': { 'function': self.getinfo,
|
||||
'min_args': None,
|
||||
'min_args': 0,
|
||||
'max_args': 1,
|
||||
'help_args': '[os|id|uptime|systime|screen|memory|processes]',
|
||||
'help': 'get information on a specified '
|
||||
@ -56,11 +59,17 @@ class DMCli(object):
|
||||
'given, print all available information)'
|
||||
},
|
||||
'ps': { 'function': self.processlist,
|
||||
'min_args': None,
|
||||
'min_args': 0,
|
||||
'max_args': 0,
|
||||
'help_args': '',
|
||||
'help': 'get information on running processes on device'
|
||||
},
|
||||
'logcat' : { 'function': self.logcat,
|
||||
'min_args': 0,
|
||||
'max_args': 0,
|
||||
'help_args': '',
|
||||
'help': 'get logcat from device'
|
||||
},
|
||||
'ls': { 'function': self.listfiles,
|
||||
'min_args': 1,
|
||||
'max_args': 1,
|
||||
@ -73,6 +82,18 @@ class DMCli(object):
|
||||
'help_args': '<remote>',
|
||||
'help': 'remove file from device'
|
||||
},
|
||||
'isdir': { 'function': self.isdir,
|
||||
'min_args': 1,
|
||||
'max_args': 1,
|
||||
'help_args': '<remote>',
|
||||
'help': 'print if remote file is a directory'
|
||||
},
|
||||
'mkdir': { 'function': lambda d: self.dm.mkDir(d),
|
||||
'min_args': 1,
|
||||
'max_args': 1,
|
||||
'help_args': '<remote>',
|
||||
'help': 'makes a directory on device'
|
||||
},
|
||||
'rmdir': { 'function': lambda d: self.dm.removeDir(d),
|
||||
'min_args': 1,
|
||||
'max_args': 1,
|
||||
@ -100,6 +121,8 @@ class DMCli(object):
|
||||
self.parser = OptionParser(usage)
|
||||
self.add_options(self.parser)
|
||||
|
||||
|
||||
def run(self, args=sys.argv[1:]):
|
||||
(self.options, self.args) = self.parser.parse_args(args)
|
||||
|
||||
if len(self.args) < 1:
|
||||
@ -116,15 +139,20 @@ class DMCli(object):
|
||||
" ".join(self.commands.keys()))
|
||||
|
||||
command = self.commands[command_name]
|
||||
if command['min_args'] and len(command_args) < command['min_args'] or \
|
||||
command['max_args'] and len(command_args) > command['max_args']:
|
||||
if (len(command_args) < command['min_args'] or
|
||||
(command['max_args'] is not None and len(command_args) >
|
||||
command['max_args'])):
|
||||
self.parser.error("Wrong number of arguments")
|
||||
|
||||
self.dm = self.getDevice(dmtype=self.options.dmtype,
|
||||
hwid=self.options.hwid,
|
||||
host=self.options.host,
|
||||
port=self.options.port)
|
||||
command['function'](*command_args)
|
||||
ret = command['function'](*command_args)
|
||||
if ret is None:
|
||||
ret = 0
|
||||
|
||||
sys.exit(ret)
|
||||
|
||||
def add_options(self, parser):
|
||||
parser.add_option("-v", "--verbose", action="store_true",
|
||||
@ -232,6 +260,9 @@ class DMCli(object):
|
||||
else:
|
||||
print "%s" % "\n".join(infoitem)
|
||||
|
||||
def logcat(self):
|
||||
print ''.join(self.dm.getLogcat())
|
||||
|
||||
def processlist(self):
|
||||
pslist = self.dm.getProcessList()
|
||||
for ps in pslist:
|
||||
@ -242,9 +273,18 @@ class DMCli(object):
|
||||
for file in filelist:
|
||||
print file
|
||||
|
||||
def isdir(self, file):
|
||||
if self.dm.dirExists(file):
|
||||
print "TRUE"
|
||||
return 0
|
||||
|
||||
print "FALSE"
|
||||
return errno.ENOTDIR
|
||||
|
||||
def cli(args=sys.argv[1:]):
|
||||
# process the command line
|
||||
cli = DMCli(args)
|
||||
cli = DMCli()
|
||||
cli.run(args)
|
||||
|
||||
if __name__ == '__main__':
|
||||
cli()
|
||||
|
@ -5,7 +5,7 @@
|
||||
import os
|
||||
from setuptools import setup
|
||||
|
||||
PACKAGE_VERSION = '0.15'
|
||||
PACKAGE_VERSION = '0.16'
|
||||
|
||||
# take description from README
|
||||
here = os.path.dirname(os.path.abspath(__file__))
|
||||
|
Loading…
Reference in New Issue
Block a user