本文整理汇总了Python中devicemanager.DeviceManager.getInstance方法的典型用法代码示例。如果您正苦于以下问题:Python DeviceManager.getInstance方法的具体用法?Python DeviceManager.getInstance怎么用?Python DeviceManager.getInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类devicemanager.DeviceManager
的用法示例。
在下文中一共展示了DeviceManager.getInstance方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from devicemanager import DeviceManager [as 别名]
# 或者: from devicemanager.DeviceManager import getInstance [as 别名]
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
示例2: parseMessage
# 需要导入模块: from devicemanager import DeviceManager [as 别名]
# 或者: from devicemanager.DeviceManager import getInstance [as 别名]
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}]