本文整理汇总了Python中devicemanager.DeviceManager类的典型用法代码示例。如果您正苦于以下问题:Python DeviceManager类的具体用法?Python DeviceManager怎么用?Python DeviceManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DeviceManager类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, host=None, port=5555, retryLimit=5, packageName='fennec',
adbPath='adb', deviceSerial=None, deviceRoot=None,
logLevel=mozlog.ERROR, autoconnect=True, runAdbAsRoot=False, **kwargs):
DeviceManager.__init__(self, logLevel=logLevel,
deviceRoot=deviceRoot)
self.host = host
self.port = port
self.retryLimit = retryLimit
# the path to adb, or 'adb' to assume that it's on the PATH
self._adbPath = adbPath
# The serial number of the device to use with adb, used in cases
# where multiple devices are being managed by the same adb instance.
self._deviceSerial = deviceSerial
# Some devices do no start adb as root, if allowed you can use
# this to reboot adbd on the device as root automatically
self._runAdbAsRoot = runAdbAsRoot
if packageName == 'fennec':
if os.getenv('USER'):
self._packageName = 'org.mozilla.fennec_' + os.getenv('USER')
else:
self._packageName = 'org.mozilla.fennec_'
elif packageName:
self._packageName = packageName
# verify that we can run the adb command. can't continue otherwise
self._verifyADB()
if autoconnect:
self.connect()
示例2: main
def main():
dm_none = DeviceManager(None, None)
automation = RemoteAutomation(dm_none)
parser = RemoteOptions(automation)
options, args = parser.parse_args()
if (options.deviceIP == None):
print "Error: you must provide a device IP to connect to via the --device option"
sys.exit(1)
dm = DeviceManager(options.deviceIP, options.devicePort)
automation.setDeviceManager(dm)
if (options.remoteProductName != None):
automation.setProduct(options.remoteProductName)
# Set up the defaults and ensure options are set
options = parser.verifyRemoteOptions(options)
if (options == None):
print "ERROR: Invalid options specified, use --help for a list of valid options"
sys.exit(1)
parts = dm.getInfo('screen')['screen'][0].split()
width = int(parts[0].split(':')[1])
height = int(parts[1].split(':')[1])
if (width < 1050 or height < 1050):
print "ERROR: Invalid screen resolution %sx%s, please adjust to 1366x1050 or higher" % (width, height)
sys.exit(1)
automation.setAppName(options.app)
automation.setRemoteProfile(options.remoteProfile)
automation.setRemoteLog(options.remoteLogFile)
reftest = RemoteReftest(automation, dm, options, SCRIPT_DIRECTORY)
# Start the webserver
reftest.startWebServer(options)
# Hack in a symbolic link for jsreftest
os.system("ln -s ../jsreftest " + str(os.path.join(SCRIPT_DIRECTORY, "jsreftest")))
# Dynamically build the reftest URL if possible, beware that args[0] should exist 'inside' the webroot
manifest = args[0]
if os.path.exists(os.path.join(SCRIPT_DIRECTORY, args[0])):
manifest = "http://" + str(options.remoteWebServer) + ":" + str(options.httpPort) + "/" + args[0]
elif os.path.exists(args[0]):
manifestPath = os.path.abspath(args[0]).split(SCRIPT_DIRECTORY)[1].strip('/')
manifest = "http://" + str(options.remoteWebServer) + ":" + str(options.httpPort) + "/" + manifestPath
procName = options.app.split('/')[-1]
if (dm.processExist(procName)):
dm.killProcess(procName)
#an example manifest name to use on the cli
# manifest = "http://" + options.remoteWebServer + "/reftests/layout/reftests/reftest-sanity/reftest.list"
reftest.runTests(manifest, options)
reftest.stopWebServer(options)
示例3: __init__
def __init__(self, host=None, port=5555, retryLimit=5, packageName='fennec',
adbPath='adb', deviceSerial=None, deviceRoot=None,
logLevel=mozlog.ERROR, **kwargs):
DeviceManager.__init__(self, logLevel)
self.host = host
self.port = port
self.retryLimit = retryLimit
self.deviceRoot = deviceRoot
# the path to adb, or 'adb' to assume that it's on the PATH
self._adbPath = adbPath
# The serial number of the device to use with adb, used in cases
# where multiple devices are being managed by the same adb instance.
self._deviceSerial = deviceSerial
if packageName == 'fennec':
if os.getenv('USER'):
self._packageName = 'org.mozilla.fennec_' + os.getenv('USER')
else:
self._packageName = 'org.mozilla.fennec_'
elif packageName:
self._packageName = packageName
# verify that we can run the adb command. can't continue otherwise
self._verifyADB()
# try to connect to the device over tcp/ip if we have a hostname
if self.host:
self._connectRemoteADB()
# verify that we can connect to the device. can't continue
self._verifyDevice()
# set up device root
self._setupDeviceRoot()
# Some commands require root to work properly, even with ADB (e.g.
# grabbing APKs out of /data). For these cases, we check whether
# we're running as root. If that isn't true, check for the
# existence of an su binary
self._checkForRoot()
# Can we use run-as? (not required)
try:
self._verifyRunAs()
except DMError:
pass
# can we use zip to speed up some file operations? (currently not
# required)
try:
self._verifyZip()
except DMError:
pass
示例4: __init__
def __init__(self, host, port=20701, retryLimit=5, deviceRoot=None,
logLevel=logging.ERROR, **kwargs):
DeviceManager.__init__(self, logLevel=logLevel,
deviceRoot=deviceRoot)
self.host = host
self.port = port
self.retryLimit = retryLimit
self._sock = None
self._everConnected = False
# Get version
verstring = self._runCmds([{'cmd': 'ver'}])
ver_re = re.match('(\S+) Version (\S+)', verstring)
self.agentProductName = ver_re.group(1)
self.agentVersion = ver_re.group(2)
示例5: __init__
def __init__(self, host, port=20701, retryLimit=5, deviceRoot=None, logLevel=mozlog.ERROR, **kwargs):
DeviceManager.__init__(self, logLevel)
self.host = host
self.port = port
self.retryLimit = retryLimit
self._sock = None
self._everConnected = False
self.deviceRoot = deviceRoot
# Initialize device root
self.getDeviceRoot()
# Get version
verstring = self._runCmds([{"cmd": "ver"}])
ver_re = re.match("(\S+) Version (\S+)", verstring)
self.agentProductName = ver_re.group(1)
self.agentVersion = ver_re.group(2)
示例6: __init__
def __init__(self, context=None, case=None):
self.logger = Logger.getLogger()
self.assertion = assertion()
self.logger.debug('init store')
self.store = store(context, case)
self.device = DeviceManager.getInstance().getDevice()
self._isRecord = context.isRecording()
self._checkpoint = -1
示例7: open_connection
def open_connection(self, args):
host = args[0]
port = args[1]
device_class = args[2]
profiles_path = args[3]
self.fpm = None
dm = DeviceManager(host, port)
dm.debug = 3
if not dm._sock:
dm = None
wx.PostEvent(self.notify_window, FptEvent('conn_failed', ('%s:%d' % (host, port),)))
if dm:
self.fpm = FennecProfileTool(profiles_path, device_class, dm, self.set_status)
if not self.fpm.default_profile:
self.fpm = None
wx.PostEvent(self.notify_window, FptEvent('no_default_profile', (host,)))
else:
wx.PostEvent(self.notify_window, FptEvent('connected', (dm.host,)))
示例8: parseMessage
def parseMessage(msg_type=None,session_id=None,caseresult_id=None,test_info=None,file_path=None):
logger = Logger.getLogger()
if msg_type == 'sessiondata':
logger.debug('********************session request***********************')
url = SendUtils._session_create_url % session_id
sessionStarttime = TestBuilder.getBuilder().getStartTime()
deviceId = DeviceManager.getInstance().getDevice().getDeviceId()
properties = DeviceManager.getInstance().getDevice().getDeviceInfo()
logger.debug('********************session starttime*********************'+sessionStarttime)
postData = {'planname':'plan','starttime':sessionStarttime,'deviceid':deviceId,'deviceinfo':properties}
contentType = 'application/json'
method = 'POST'
return {'url':url,'data':postData,'content_type':contentType,'method':method}
if msg_type == 'caseresult':
logger.debug('********************case result*********************')
sid = session_id
tid = caseresult_id
info = test_info
path = file_path
if info:
if info[0] == 'startTest':
logger.debug('********************start test*********************')
url = (SendUtils._caseresult_create_url) % (sid,tid)
caseName = info[1][1]._testMethodName
startTime = time.strftime('%Y-%m-%d %H:%M:%S ', time.localtime(time.time()))
postData = {'casename':caseName,'starttime':startTime}
contentType = 'application/json'
method = 'POST'
return [{'url':url,'data':postData,'content_type':contentType,'method':method}]
elif info[0] == 'addSuccess':
logger.debug('********************add success***********************')
url = (SendUtils._caseresult_update_url) % (sid,tid)
_time = time.strftime('%Y-%m-%d %H:%M:%S ', time.localtime(time.time()))
postData = {'result':'pass','time':_time}
contentType = 'application/json'
method = 'POST'
return [{'url':url,'data':postData,'content_type':contentType,'method':method}]
elif info[0] == 'addFailure':
logger.debug('********************add failure***********************')
resultUrl = (SendUtils._caseresult_update_url) % (sid,tid)
resultTime = time.strftime('%Y-%m-%d %H:%M:%S ', time.localtime(time.time()))
resultPostData = {'result':'fail','time':resultTime}
resultContentType = 'application/json'
resultMethod = 'POST'
resultRequest = {'url':resultUrl,'data':resultPostData,'content_type':resultContentType,'method':resultMethod}
#log file
logUrl = (SendUtils._upload_file_url) % (sid,tid)
logfolder = os.path.join(info[1][1].worker.store.getFailDir(),'log')
zipName = '%s_%s.%s'%(sid,tid,'zip')
zipFolder(logfolder,zipName)
logPostData = _openFile(zipName)
logContentType = 'application/zip'
logMethod = 'PUT'
fileRequest = {'url':logUrl,'data':logPostData,'content_type':logContentType,'method':logMethod}
return [resultRequest,fileRequest]
elif info[0] == 'addError':
logger.debug('********************add error***********************')
resultUrl = (SendUtils._caseresult_update_url) % (sid,tid)
resultTime = time.strftime('%Y-%m-%d %H:%M:%S ', time.localtime(time.time()))
resultPostData = {'result':'error','time':resulTime}
resultContentType = 'application/json'
resultMethod = 'POST'
resultRequest = {'url':resultUrl,'data':resultPostData,'content_type':resultContentType,'method':resultMethod}
#log file
#logUrl = (SendUtils._upload_file_url) % (sid,tid)
#logfolder = os.path.join(info[1][1].device.workspace_result_fail,'log')
#zipName = '%s_%s.%s'%(sid,tid,'zip')
#zipFolder(logfolder,_zipname)
#logPostData = _openFile(_zipname)
#logContentType = 'application/zip'
#logMethod = 'PUT'
#fileRequest = {'url':logUrl,'data':logPostData,'content_type':logContentType,'method':logMethod}
return [resultRequest]
elif file_path:
logger.debug('********************upload snapshot***********************')
sid = session_id
tid = caseresult_id
url = (SendUtils._upload_file_url) % (sid,tid)
postData = _openFile(file_path)
contentType = 'image/png'
method = 'PUT'
return [{'url':url,'data':postData,'content_type':contentType,'method':method}]