mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-02 10:00:54 +00:00
Bug 774293 - Fix issues in devicemanager revealed by pyflakes;r=wlach
This commit is contained in:
parent
8ee7419879
commit
822e64b426
@ -2,7 +2,6 @@
|
||||
# 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/.
|
||||
|
||||
import time
|
||||
import hashlib
|
||||
import socket
|
||||
import os
|
||||
|
@ -6,8 +6,8 @@ import subprocess
|
||||
from devicemanager import DeviceManager, DMError, _pop_last_line
|
||||
import re
|
||||
import os
|
||||
import sys
|
||||
import tempfile
|
||||
import time
|
||||
|
||||
class DeviceManagerADB(DeviceManager):
|
||||
|
||||
@ -65,7 +65,7 @@ class DeviceManagerADB(DeviceManager):
|
||||
self.useRunAs = False
|
||||
try:
|
||||
self.verifyRoot()
|
||||
except DMError, e:
|
||||
except DMError:
|
||||
try:
|
||||
self.checkCmd(["root"])
|
||||
# The root command does not fail even if ADB cannot get
|
||||
@ -394,7 +394,9 @@ class DeviceManagerADB(DeviceManager):
|
||||
args.append("-9")
|
||||
args.append(pid)
|
||||
p = self.runCmdAs(args)
|
||||
didKillProcess = True
|
||||
p.communicate()
|
||||
if p.returncode == 0:
|
||||
didKillProcess = True
|
||||
|
||||
return didKillProcess
|
||||
|
||||
@ -499,11 +501,11 @@ class DeviceManagerADB(DeviceManager):
|
||||
# success: MD5 hash for given filename
|
||||
# failure: None
|
||||
def getRemoteHash(self, filename):
|
||||
data = p = self.runCmd(["shell", "ls", "-l", filename]).stdout.read()
|
||||
data = self.runCmd(["shell", "ls", "-l", filename]).stdout.read()
|
||||
return data.split()[3]
|
||||
|
||||
def getLocalHash(self, filename):
|
||||
data = p = subprocess.Popen(["ls", "-l", filename], stdout=subprocess.PIPE).stdout.read()
|
||||
data = subprocess.Popen(["ls", "-l", filename], stdout=subprocess.PIPE).stdout.read()
|
||||
return data.split()[4]
|
||||
|
||||
# Internal method to setup the device root and cache its value
|
||||
@ -693,7 +695,7 @@ class DeviceManagerADB(DeviceManager):
|
||||
return ret
|
||||
|
||||
def runCmd(self, args):
|
||||
# If we are not root but have run-as, and we're trying to execute
|
||||
# If we are not root but have run-as, and we're trying to execute
|
||||
# a shell command then using run-as is the best we can do
|
||||
finalArgs = [self.adbPath]
|
||||
if self.deviceSerial:
|
||||
@ -711,7 +713,7 @@ class DeviceManagerADB(DeviceManager):
|
||||
return self.runCmd(args)
|
||||
|
||||
def checkCmd(self, args):
|
||||
# If we are not root but have run-as, and we're trying to execute
|
||||
# If we are not root but have run-as, and we're trying to execute
|
||||
# a shell command then using run-as is the best we can do
|
||||
finalArgs = [self.adbPath]
|
||||
if self.deviceSerial:
|
||||
|
@ -5,17 +5,14 @@
|
||||
import select
|
||||
import socket
|
||||
import SocketServer
|
||||
import time, datetime
|
||||
import time
|
||||
import os
|
||||
import re
|
||||
import hashlib
|
||||
import posixpath
|
||||
import subprocess
|
||||
from threading import Thread
|
||||
import traceback
|
||||
import sys
|
||||
import StringIO
|
||||
from devicemanager import DeviceManager, DMError, FileError, NetworkTools, _pop_last_line
|
||||
from devicemanager import DeviceManager, FileError, NetworkTools, _pop_last_line
|
||||
import errno
|
||||
|
||||
class AgentError(Exception):
|
||||
@ -126,7 +123,6 @@ class DeviceManagerSUT(DeviceManager):
|
||||
one fails. this is necessary in particular for pushFile(), where we don't want
|
||||
to accidentally send extra data if a failure occurs during data transmission.
|
||||
'''
|
||||
done = False
|
||||
while self.retries < self.retrylimit:
|
||||
try:
|
||||
self._doCmds(cmdlist, outputfile, timeout)
|
||||
@ -503,7 +499,7 @@ class DeviceManagerSUT(DeviceManager):
|
||||
return None
|
||||
|
||||
try:
|
||||
data = self.runCmds([{ 'cmd': 'exec ' + appname }])
|
||||
self.runCmds([{ 'cmd': 'exec ' + appname }])
|
||||
except AgentError:
|
||||
return None
|
||||
|
||||
@ -547,7 +543,7 @@ class DeviceManagerSUT(DeviceManager):
|
||||
if forceKill:
|
||||
print "WARNING: killProcess(): forceKill parameter unsupported on SUT"
|
||||
try:
|
||||
data = self.runCmds([{ 'cmd': 'kill ' + appname }])
|
||||
self.runCmds([{ 'cmd': 'kill ' + appname }])
|
||||
except AgentError:
|
||||
return False
|
||||
|
||||
@ -640,7 +636,8 @@ class DeviceManagerSUT(DeviceManager):
|
||||
# or, if error,
|
||||
# <filename>,-1\n<error message>
|
||||
try:
|
||||
data = self.runCmds([{ 'cmd': 'pull ' + remoteFile }])
|
||||
# just send the command first, we read the response inline below
|
||||
self.runCmds([{ 'cmd': 'pull ' + remoteFile }])
|
||||
except AgentError:
|
||||
return None
|
||||
|
||||
@ -880,7 +877,6 @@ class DeviceManagerSUT(DeviceManager):
|
||||
cmd = 'rebt'
|
||||
|
||||
if (self.debug > 3): print "INFO: sending rebt command"
|
||||
callbacksvrstatus = None
|
||||
|
||||
if (ipAddr is not None):
|
||||
#create update.info file:
|
||||
|
@ -268,10 +268,9 @@ class Emulator(object):
|
||||
local_port = s.getsockname()[1]
|
||||
s.close()
|
||||
|
||||
output = self._run_adb(['-s', 'emulator-%d' % self.port,
|
||||
'forward',
|
||||
'tcp:%d' % local_port,
|
||||
'tcp:%d' % remote_port])
|
||||
self._run_adb(['-s', 'emulator-%d' % self.port, 'forward',
|
||||
'tcp:%d' % local_port,
|
||||
'tcp:%d' % remote_port])
|
||||
|
||||
self.local_port = local_port
|
||||
|
||||
|
@ -3,19 +3,18 @@
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
import time
|
||||
import sys
|
||||
import os
|
||||
import socket
|
||||
import automationutils
|
||||
import tempfile
|
||||
import shutil
|
||||
import subprocess
|
||||
|
||||
from automation import Automation
|
||||
from devicemanager import DeviceManager, NetworkTools
|
||||
from devicemanager import NetworkTools
|
||||
|
||||
class RemoteAutomation(Automation):
|
||||
_devicemanager = None
|
||||
|
||||
|
||||
def __init__(self, deviceManager, appName = '', remoteLog = None):
|
||||
self._devicemanager = deviceManager
|
||||
self._appName = appName
|
||||
@ -28,7 +27,7 @@ class RemoteAutomation(Automation):
|
||||
|
||||
def setDeviceManager(self, deviceManager):
|
||||
self._devicemanager = deviceManager
|
||||
|
||||
|
||||
def setAppName(self, appName):
|
||||
self._appName = appName
|
||||
|
||||
@ -37,7 +36,7 @@ class RemoteAutomation(Automation):
|
||||
|
||||
def setProduct(self, product):
|
||||
self._product = product
|
||||
|
||||
|
||||
def setRemoteLog(self, logfile):
|
||||
self._remoteLog = logfile
|
||||
|
||||
@ -88,11 +87,11 @@ class RemoteAutomation(Automation):
|
||||
if (self._remoteProfile):
|
||||
profileDir = self._remoteProfile
|
||||
|
||||
# Hack for robocop, if app & testURL == None and extraArgs contains the rest of the stuff, lets
|
||||
# Hack for robocop, if app & testURL == None and extraArgs contains the rest of the stuff, lets
|
||||
# assume extraArgs is all we need
|
||||
if app == "am" and extraArgs[0] == "instrument":
|
||||
return app, extraArgs
|
||||
|
||||
|
||||
cmd, args = Automation.buildCommandLine(self, app, debuggerInfo, profileDir, testURL, extraArgs)
|
||||
# Remove -foreground if it exists, if it doesn't this just returns
|
||||
try:
|
||||
@ -113,7 +112,7 @@ class RemoteAutomation(Automation):
|
||||
|
||||
return self.RProcess(self._devicemanager, cmd, stdout, stderr, env, cwd)
|
||||
|
||||
# be careful here as this inner class doesn't have access to outer class members
|
||||
# be careful here as this inner class doesn't have access to outer class members
|
||||
class RProcess(object):
|
||||
# device manager process
|
||||
dm = None
|
||||
@ -162,7 +161,7 @@ class RemoteAutomation(Automation):
|
||||
if (hexpid == None):
|
||||
hexpid = "0x0"
|
||||
return int(hexpid, 0)
|
||||
|
||||
|
||||
@property
|
||||
def stdout(self):
|
||||
t = self.dm.getFile(self.proc)
|
||||
@ -171,7 +170,7 @@ class RemoteAutomation(Automation):
|
||||
retVal = t[self.stdoutlen:]
|
||||
self.stdoutlen = tlen
|
||||
return retVal.strip('\n').strip()
|
||||
|
||||
|
||||
def wait(self, timeout = None):
|
||||
timer = 0
|
||||
interval = 5
|
||||
@ -190,6 +189,6 @@ class RemoteAutomation(Automation):
|
||||
if (timer >= timeout):
|
||||
return 1
|
||||
return 0
|
||||
|
||||
|
||||
def kill(self):
|
||||
self.dm.killProcess(self.procName)
|
||||
|
Loading…
Reference in New Issue
Block a user