mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 900629 - Mirror mozdevice 0.29;r=ahal
This commit is contained in:
parent
58f292422e
commit
dc72c5b8c6
@ -169,7 +169,7 @@ class DeviceManager(object):
|
||||
self.removeFile(tempScreenshotFile)
|
||||
|
||||
@abstractmethod
|
||||
def pushFile(self, localFilename, remoteFilename, retryLimit=1):
|
||||
def pushFile(self, localFilename, remoteFilename, retryLimit=1, createDir=True):
|
||||
"""
|
||||
Copies localname from the host to destname on the device.
|
||||
"""
|
||||
|
@ -191,7 +191,7 @@ class DeviceManagerADB(DeviceManager):
|
||||
def _disconnectRemoteADB(self):
|
||||
self._checkCmd(["disconnect", self.host + ":" + str(self.port)])
|
||||
|
||||
def pushFile(self, localname, destname, retryLimit=None):
|
||||
def pushFile(self, localname, destname, retryLimit=None, createDir=True):
|
||||
# you might expect us to put the file *in* the directory in this case,
|
||||
# but that would be different behaviour from devicemanagerSUT. Throw
|
||||
# an exception so we have the same behaviour between the two
|
||||
@ -232,7 +232,7 @@ class DeviceManagerADB(DeviceManager):
|
||||
remoteZip = remoteDir + "/adbdmtmp.zip"
|
||||
subprocess.Popen(["zip", "-r", localZip, '.'], cwd=localDir,
|
||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
|
||||
self.pushFile(localZip, remoteZip, retryLimit=retryLimit)
|
||||
self.pushFile(localZip, remoteZip, retryLimit=retryLimit, createDir=False)
|
||||
os.remove(localZip)
|
||||
data = self._runCmdAs(["shell", "unzip", "-o", remoteZip,
|
||||
"-d", remoteDir]).stdout.read()
|
||||
|
@ -230,7 +230,7 @@ class DeviceManagerSUT(DeviceManager):
|
||||
|
||||
# Get our response
|
||||
try:
|
||||
# Wait up to a second for socket to become ready for reading...
|
||||
# Wait up to a second for socket to become ready for reading...
|
||||
if select.select([self._sock], [], [], select_timeout)[0]:
|
||||
temp = self._sock.recv(1024)
|
||||
self._logger.debug("response: %s" % temp)
|
||||
@ -338,9 +338,10 @@ class DeviceManagerSUT(DeviceManager):
|
||||
# woops, we couldn't find an end of line/return value
|
||||
raise DMError("Automation Error: Error finding end of line/return value when running '%s'" % cmdline)
|
||||
|
||||
def pushFile(self, localname, destname, retryLimit = None):
|
||||
def pushFile(self, localname, destname, retryLimit=None, createDir=True):
|
||||
retryLimit = retryLimit or self.retryLimit
|
||||
self.mkDirs(destname)
|
||||
if createDir:
|
||||
self.mkDirs(destname)
|
||||
|
||||
try:
|
||||
filesize = os.path.getsize(localname)
|
||||
@ -382,8 +383,7 @@ class DeviceManagerSUT(DeviceManager):
|
||||
self.mkDirs(remoteName)
|
||||
existentDirectories.append(parent)
|
||||
|
||||
self.pushFile(os.path.join(root, f), remoteName, retryLimit=retryLimit)
|
||||
|
||||
self.pushFile(os.path.join(root, f), remoteName, retryLimit=retryLimit, createDir=False)
|
||||
|
||||
def dirExists(self, remotePath):
|
||||
ret = self._runCmds([{ 'cmd': 'isdir ' + remotePath }]).strip()
|
||||
@ -562,30 +562,23 @@ class DeviceManagerSUT(DeviceManager):
|
||||
# the class level if we wanted to refactor sendCMD(). For now they are
|
||||
# only used to pull files.
|
||||
|
||||
def uread(to_recv, error_msg, timeout=None):
|
||||
def uread(to_recv, error_msg):
|
||||
""" unbuffered read """
|
||||
timer = 0
|
||||
select_timeout = 1
|
||||
if not timeout:
|
||||
timeout = self.default_timeout
|
||||
|
||||
try:
|
||||
if select.select([self._sock], [], [], select_timeout)[0]:
|
||||
data = ""
|
||||
if select.select([self._sock], [], [], self.default_timeout)[0]:
|
||||
data = self._sock.recv(to_recv)
|
||||
timer = 0
|
||||
timer += select_timeout
|
||||
if timer > timeout:
|
||||
err('timeout in uread while retrieving file')
|
||||
|
||||
if not data:
|
||||
# timed out waiting for response or error response
|
||||
err(error_msg)
|
||||
|
||||
return data
|
||||
except:
|
||||
err(error_msg)
|
||||
|
||||
def read_until_char(c, buf, error_msg):
|
||||
""" read until 'c' is found; buffer rest """
|
||||
while not '\n' in buf:
|
||||
while not c in buf:
|
||||
data = uread(1024, error_msg)
|
||||
buf += data
|
||||
return buf.partition(c)
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
from setuptools import setup
|
||||
|
||||
PACKAGE_VERSION = '0.28'
|
||||
PACKAGE_VERSION = '0.29'
|
||||
|
||||
setup(name='mozdevice',
|
||||
version=PACKAGE_VERSION,
|
||||
|
@ -45,14 +45,12 @@ class PushTest(unittest.TestCase):
|
||||
f.flush()
|
||||
|
||||
subTests = [ { 'cmds': [ ("isdir /mnt/sdcard/baz", "TRUE"),
|
||||
("isdir /mnt/sdcard/baz", "TRUE"),
|
||||
("push /mnt/sdcard/baz/%s %s\r\n%s" %
|
||||
(os.path.basename(f.name), len(pushfile),
|
||||
pushfile),
|
||||
expectedFileResponse) ],
|
||||
'expectException': False },
|
||||
{ 'cmds': [ ("isdir /mnt/sdcard/baz", "TRUE"),
|
||||
("isdir /mnt/sdcard/baz", "TRUE"),
|
||||
("push /mnt/sdcard/baz/%s %s\r\n%s" %
|
||||
(os.path.basename(f.name), len(pushfile),
|
||||
pushfile),
|
||||
|
Loading…
Reference in New Issue
Block a user