本文整理汇总了Python中commodule.log.LOGGER.info方法的典型用法代码示例。如果您正苦于以下问题:Python LOGGER.info方法的具体用法?Python LOGGER.info怎么用?Python LOGGER.info使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类commodule.log.LOGGER
的用法示例。
在下文中一共展示了LOGGER.info方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: prepare_run
# 需要导入模块: from commodule.log import LOGGER [as 别名]
# 或者: from commodule.log.LOGGER import info [as 别名]
def prepare_run(self, testxmlfile, resultdir=None):
"""
testxmlfile: target testxml file
execdir and resultdir: should be the absolute path since TRunner
is the common lib
"""
# resultdir is set to current directory by default
if not resultdir:
resultdir = os.getcwd()
ok_prepare = True
if ok_prepare:
try:
filename = testxmlfile
filename = os.path.splitext(filename)[0]
if platform.system() == "Linux":
filename = filename.split('/')[-2]
else:
filename = filename.split('\\')[-2]
if self.filter_rules["execution_type"] == ["manual"]:
resultfile = "%s.manual.xml" % filename
else:
resultfile = "%s.auto.xml" % filename
resultfile = JOIN(resultdir, resultfile)
if not EXISTS(resultdir):
os.mkdir(resultdir)
LOGGER.info("[ analysis test xml file: %s ]" % resultfile)
self.__prepare_result_file(testxmlfile, resultfile)
self.__split_test_xml(resultfile, resultdir)
except IOError as error:
LOGGER.error(error)
ok_prepare &= False
return ok_prepare
示例2: __write_file_result
# 需要导入模块: from commodule.log import LOGGER [as 别名]
# 或者: from commodule.log.LOGGER import info [as 别名]
def __write_file_result(self, set_result_xml, set_result):
"""write xml result file"""
result_file = set_result['resultfile']
try:
if self.rerun:
LOGGER.info("[ Web UI FW Unit Test Does not support rerun.\
Result should be N/A ]\n")
else:
test_tree = etree.parse(set_result_xml)
test_em = test_tree.getroot()
result_tree = etree.parse(result_file)
result_em = result_tree.getroot()
dubug_file = os.path.basename(set_result_xml)
dubug_file = os.path.splitext(dubug_file)[0] + '.dlog'
for result_suite in result_em.getiterator('suite'):
for result_set in result_suite.getiterator('set'):
for test_suite in test_em.getiterator('suite'):
for test_set in test_suite.getiterator('set'):
if result_set.get('name') == \
test_set.get('name'):
result_set.set("set_debug_msg", dubug_file)
test_suite.remove(test_set)
test_suite.append(result_set)
test_tree.write(set_result_xml)
os.remove(result_file)
LOGGER.info("[ cases result saved to resultfile ]\n")
except OSError as error:
traceback.print_exc()
LOGGER.error(
"[ Error: fail to write cases result, error: %s ]\n" % error)
示例3: killall
# 需要导入模块: from commodule.log import LOGGER [as 别名]
# 或者: from commodule.log.LOGGER import info [as 别名]
def killall(ppid):
"""Kill all children process by parent process ID"""
sys_platform = platform.system()
try:
if sys_platform == "Linux":
ppid = str(ppid)
pidgrp = []
def getchildpids(ppid):
"""Return a list of children process"""
command = "ps -ef | awk '{if ($3 == %s) print $2;}'" % str(ppid)
pids = os.popen(command).read()
pids = pids.split()
return pids
pidgrp.extend(getchildpids(ppid))
for pid in pidgrp:
pidgrp.extend(getchildpids(pid))
# Insert self process ID to PID group list
pidgrp.insert(0, ppid)
while len(pidgrp) > 0:
pid = pidgrp.pop()
try:
os.kill(int(pid), signal.SIGKILL)
except OSError, error:
pattern = re.compile('No such process')
match = pattern.search(str(error))
if not match:
LOGGER.info(
"[ Error: fail to kill pid: %s, error: %s ]\n" % (
int(pid), error))
# kill for windows platform
else:
示例4: __prepare_starup_parameters
# 需要导入模块: from commodule.log import LOGGER [as 别名]
# 或者: from commodule.log.LOGGER import info [as 别名]
def __prepare_starup_parameters(self, testxml):
""" prepare_starup_parameters """
starup_parameters = {}
LOGGER.info("[ prepare_starup_parameters ]")
try:
parse_tree = etree.parse(testxml)
tsuite = parse_tree.getroot().getiterator('suite')[0]
tset = parse_tree.getroot().getiterator('set')[0]
if tset.get("launcher") is not None:
starup_parameters['test-launcher'] = tset.get("launcher")
else:
starup_parameters['test-launcher'] = tsuite.get("launcher")
starup_parameters['testsuite-name'] = tsuite.get("name")
starup_parameters['testset-name'] = tset.get("name")
starup_parameters['stub-name'] = self.stub_name
if self.external_test is not None:
starup_parameters['external-test'] = self.external_test
starup_parameters['debug'] = self.debug
starup_parameters['test_prefix'] = self.test_prefix
if self.rerun:
starup_parameters['rerun'] = self.rerun
if len(self.capabilities) > 0:
starup_parameters['capability'] = self.capabilities
except IOError as error:
LOGGER.error(
"[ Error: prepare starup parameters, error: %s ]" % error)
return starup_parameters
示例5: __run_with_commodule
# 需要导入模块: from commodule.log import LOGGER [as 别名]
# 或者: from commodule.log.LOGGER import info [as 别名]
def __run_with_commodule(self, webapi_file):
"""run_with_commodule,Initialization,check status,get result"""
try:
# prepare test set list
test_xml_set_list = self.__split_xml_to_set(webapi_file)
# create temporary parameter
for test_xml_set in test_xml_set_list:
LOGGER.info("\n[ run set: %s ]" % test_xml_set)
# prepare the test JSON
self.__prepare_external_test_json(test_xml_set)
# init test here
init_status = self.__init_com_module(test_xml_set)
if not init_status:
continue
# send set JSON Data to com_module
self.testworker.run_test(
self.session_id, self.set_parameters)
while True:
time.sleep(1)
# check the test status ,if the set finished,get
# the set_result,and finalize_test
if self.__check_test_status():
set_result = self.testworker.get_test_result(
self.session_id)
# write_result to set_xml
self.__write_set_result(
test_xml_set, set_result)
# shut down server
self.finalize_test(self.session_id)
break
except IOError as error:
LOGGER.error(
"[ Error: fail to run webapi test xml, error: %s ]" % error)
示例6: __run_webapi_test
# 需要导入模块: from commodule.log import LOGGER [as 别名]
# 或者: from commodule.log.LOGGER import info [as 别名]
def __run_webapi_test(self, latest_dir):
""" run webAPI test"""
if self.bdryrun:
LOGGER.info("[ WRTLauncher mode does not support dryrun ]")
return True
list_auto = []
list_manual = []
for i in self.exe_sequence:
if i[-4::1] == "auto":
list_auto.append(i)
if i[-6::1] == "manual":
list_manual.append(i)
list_auto.sort()
list_manual.sort()
self.exe_sequence = []
self.exe_sequence.extend(list_auto)
self.exe_sequence.extend(list_manual)
for webapi_total_file in self.exe_sequence:
for webapi_file in self.testsuite_dict[webapi_total_file]:
# print identical xml file name
if self.current_test_xml != JOIN(latest_dir, webapi_total_file):
time.sleep(3)
LOGGER.info("\n[ testing xml: %s.xml ]\n"
% JOIN(latest_dir, webapi_total_file))
self.current_test_xml = JOIN(latest_dir, webapi_total_file)
self.__run_with_commodule(webapi_file)
示例7: run_test
# 需要导入模块: from commodule.log import LOGGER [as 别名]
# 或者: from commodule.log.LOGGER import info [as 别名]
def run_test(self, sessionid, test_set):
"""
process the execution for a test set
"""
if sessionid is None:
return False
if not "cases" in test_set:
return False
# start debug trace thread
dlogfile = test_set['current_set_name'].replace('.xml', '.dlog')
self.opts['dlog_file'] = dlogfile
self.conn.start_debug(dlogfile)
time.sleep(1)
self.result_obj = TestSetResut(
self.opts['testsuite_name'], self.opts['testset_name'])
cases, exetype, ctype = test_set[
"cases"], test_set["exetype"], test_set["type"]
if self.opts['test_type'] == "webapi":
return self.__run_web_test(sessionid, self.opts['testset_name'], exetype, ctype, cases)
elif self.opts['test_type'] == "coreapi":
return self.__run_core_test(sessionid, self.opts['testset_name'], exetype, cases)
elif self.opts['test_type'] == "jqunit":
return self.__run_jqt_test(sessionid, self.opts['testset_name'], cases)
else:
LOGGER.info("[ unsupported test suite type ! ]")
return False
示例8: __get_test_options
# 需要导入模块: from commodule.log import LOGGER [as 别名]
# 或者: from commodule.log.LOGGER import info [as 别名]
def __get_test_options(self, deviceid, test_launcher, test_suite):
"""get test option dict """
test_opt = {}
test_opt["suite_name"] = test_suite
cmd = ""
if test_launcher.find("WRTLauncher") != -1:
test_opt["launcher"] = "wrt-launcher"
# test suite need to be installed by commodule
if self.__test_auto_iu:
test_wgt = self.__test_wgt
cmd = WRT_INSTALL_STR % (deviceid, test_suite, test_wgt)
exit_code, ret = shell_command(cmd)
else:
test_wgt = test_suite
# query the whether test widget is installed ok
cmd = WRT_QUERY_STR % (deviceid, test_wgt)
exit_code, ret = shell_command(cmd)
if len(ret) == 0:
LOGGER.info('[ test widget "%s" not installed in target ]' % test_wgt)
return None
else:
test_opt["suite_id"] = ret[0].strip("\r\n")
self.__test_wgt = test_opt["suite_id"]
else:
test_opt["launcher"] = test_launcher
return test_opt
示例9: _upload_file
# 需要导入模块: from commodule.log import LOGGER [as 别名]
# 或者: from commodule.log.LOGGER import info [as 别名]
def _upload_file(deviceid, remote_path, local_path):
"""upload file to device"""
cmd = "sdb -s %s push %s %s" % (deviceid, local_path, remote_path)
exit_code, result = shell_command(cmd)
if exit_code != 0:
LOGGER.info('[ Upload file "%s" failed,' " get error: %s ]" % (local_path, result))
return False
else:
return True
示例10: _download_file
# 需要导入模块: from commodule.log import LOGGER [as 别名]
# 或者: from commodule.log.LOGGER import info [as 别名]
def _download_file(deviceid, remote_path, local_path):
"""download file from device"""
cmd = "sdb -s %s pull %s %s" % (deviceid, remote_path, local_path)
exit_code, ret = shell_command(cmd)
if exit_code != 0:
LOGGER.info('[ Download file "%s" from target failed, error: %s ]' % (remote_path, ret[0].strip("\r\n")))
return False
else:
return True
示例11: download_file
# 需要导入模块: from commodule.log import LOGGER [as 别名]
# 或者: from commodule.log.LOGGER import info [as 别名]
def download_file(self, remote_path, local_path):
"""download file from device"""
cmd = "adb -s %s pull %s %s" % (self.deviceid, remote_path, local_path)
exit_code, ret = shell_command(cmd)
if exit_code != 0:
error = ret[0].strip('\r\n') if len(ret) else "sdb shell timeout"
LOGGER.info("[ Download file \"%s\" failed, error: %s ]"
% (remote_path, error))
return False
else:
return True
示例12: upload_file
# 需要导入模块: from commodule.log import LOGGER [as 别名]
# 或者: from commodule.log.LOGGER import info [as 别名]
def upload_file(self, remote_path, local_path):
"""upload file to device"""
cmd = "sdb -s %s push %s %s" % (self.deviceid, local_path, remote_path)
exit_code, ret = shell_command(cmd)
if exit_code != 0:
error = ret[0].strip('\r\n') if len(ret) else "sdb shell timeout"
LOGGER.info("[ Upload file \"%s\" failed,"
" get error: %s ]" % (local_path, error))
return False
else:
return True
示例13: write_json_result
# 需要导入模块: from commodule.log import LOGGER [as 别名]
# 或者: from commodule.log.LOGGER import info [as 别名]
def write_json_result(set_result_xml, set_result):
''' fetch result form JSON'''
case_results = set_result["cases"]
try:
parse_tree = etree.parse(set_result_xml)
root_em = parse_tree.getroot()
dubug_file = os.path.basename(set_result_xml)
dubug_file = os.path.splitext(dubug_file)[0] + '.dlog'
for tset in root_em.getiterator('set'):
tset.set("set_debug_msg", dubug_file)
for tcase in tset.getiterator('testcase'):
for case_result in case_results:
if tcase.get("id") == case_result['case_id']:
tcase.set('result', case_result['result'].upper())
# Check performance test
if tcase.find('measurement') is not None:
for measurement in tcase.getiterator(
'measurement'):
if 'measures' in case_result:
m_results = case_result['measures']
for m_result in m_results:
if measurement.get('name') == \
m_result['name'] and 'value' in m_result:
measurement.set(
'value', m_result[
'value'])
if tcase.find("./result_info") is not None:
tcase.remove(tcase.find("./result_info"))
result_info = etree.SubElement(tcase, "result_info")
actual_result = etree.SubElement(
result_info, "actual_result")
actual_result.text = case_result['result'].upper()
start = etree.SubElement(result_info, "start")
end = etree.SubElement(result_info, "end")
stdout = etree.SubElement(result_info, "stdout")
stderr = etree.SubElement(result_info, "stderr")
if 'start_at' in case_result:
start.text = case_result['start_at']
if 'end_at' in case_result:
end.text = case_result['end_at']
if 'stdout' in case_result:
stdout.text = str2xmlstr(case_result['stdout'])
if 'stderr' in case_result:
stderr.text = str2xmlstr(case_result['stderr'])
parse_tree.write(set_result_xml)
LOGGER.info("[ cases result saved to resultfile ]\n")
except IOError as error:
traceback.print_exc()
LOGGER.error(
"[ Error: fail to write cases result, error: %s ]\n" % error)
示例14: extend_result
# 需要导入模块: from commodule.log import LOGGER [as 别名]
# 或者: from commodule.log.LOGGER import info [as 别名]
def extend_result(self, cases_result=None, print_out=True):
"""update cases result to the result buffer"""
self._mutex.acquire()
if cases_result is not None:
self._result["cases"].extend(cases_result)
if print_out:
for case_it in cases_result:
LOGGER.info(self._progress %
(self._suite_name, case_it['case_id'], case_it['result']))
if case_it['result'].lower() in ['fail', 'block'] and 'stdout' in case_it:
LOGGER.info(case_it['stdout'])
self._mutex.release()
示例15: kill_testkit_lite
# 需要导入模块: from commodule.log import LOGGER [as 别名]
# 或者: from commodule.log.LOGGER import info [as 别名]
def kill_testkit_lite(pid_file):
""" kill testkit lite"""
try:
with open(pid_file, "r") as pidfile:
pid = pidfile.readline().rstrip("\n")
if pid:
killall(pid)
except IOError, error:
pattern = re.compile('No such file or directory|No such process')
match = pattern.search(str(error))
if not match:
LOGGER.info("[ Error: fail to kill existing testkit-lite, "\
"error: %s ]\n" % error)