当前位置: 首页>>代码示例>>Python>>正文


Python LOGGER.error方法代码示例

本文整理汇总了Python中commodule.log.LOGGER.error方法的典型用法代码示例。如果您正苦于以下问题:Python LOGGER.error方法的具体用法?Python LOGGER.error怎么用?Python LOGGER.error使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在commodule.log.LOGGER的用法示例。


在下文中一共展示了LOGGER.error方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: finalize_test

# 需要导入模块: from commodule.log import LOGGER [as 别名]
# 或者: from commodule.log.LOGGER import error [as 别名]
 def finalize_test(self, sessionid):
     '''shut_down testkit-stub'''
     try:
         self.testworker.finalize_test(sessionid)
     except Exception as error:
         LOGGER.error("[ Error: fail to close webapi http server, "
                      "error: %s ]" % error)
开发者ID:liuct,项目名称:testkit-lite,代码行数:9,代码来源:runner.py

示例2: __run_with_commodule

# 需要导入模块: from commodule.log import LOGGER [as 别名]
# 或者: from commodule.log.LOGGER import error [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)
开发者ID:liuct,项目名称:testkit-lite,代码行数:36,代码来源:runner.py

示例3: __write_file_result

# 需要导入模块: from commodule.log import LOGGER [as 别名]
# 或者: from commodule.log.LOGGER import error [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)
开发者ID:liuct,项目名称:testkit-lite,代码行数:32,代码来源:runner.py

示例4: __prepare_result_file

# 需要导入模块: from commodule.log import LOGGER [as 别名]
# 或者: from commodule.log.LOGGER import error [as 别名]
 def __prepare_result_file(self, testxmlfile, resultfile):
     """ write the test_xml content to resultfile"""
     try:
         parse_tree = etree.parse(testxmlfile)
         suiteparent = parse_tree.getroot()
         no_test_definition = 1
         if parse_tree.getiterator('test_definition'):
             no_test_definition = 0
         if no_test_definition:
             suiteparent = etree.Element('test_definition')
             suiteparent.tail = "\n"
             for suite in parse_tree.getiterator('suite'):
                 suite.tail = "\n"
                 suiteparent.append(suite)
         self.apply_filter(suiteparent)
         try:
             with open(resultfile, 'w') as output:
                 tree = etree.ElementTree(element=suiteparent)
                 tree.write(output)
         except IOError as error:
             LOGGER.error("[ Error: create filtered result file: %s failed,\
                 error: %s ]" % (resultfile, error))
     except IOError as error:
         LOGGER.error(error)
         return False
开发者ID:liuct,项目名称:testkit-lite,代码行数:27,代码来源:runner.py

示例5: prepare_run

# 需要导入模块: from commodule.log import LOGGER [as 别名]
# 或者: from commodule.log.LOGGER import error [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
开发者ID:liuct,项目名称:testkit-lite,代码行数:34,代码来源:runner.py

示例6: __prepare_starup_parameters

# 需要导入模块: from commodule.log import LOGGER [as 别名]
# 或者: from commodule.log.LOGGER import error [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
开发者ID:liuct,项目名称:testkit-lite,代码行数:30,代码来源:runner.py

示例7: write_json_result

# 需要导入模块: from commodule.log import LOGGER [as 别名]
# 或者: from commodule.log.LOGGER import error [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)
开发者ID:liuct,项目名称:testkit-lite,代码行数:55,代码来源:runner.py

示例8: get_test_result

# 需要导入模块: from commodule.log import LOGGER [as 别名]
# 或者: from commodule.log.LOGGER import error [as 别名]
 def get_test_result(self, sessionid):
     """get the test result for a test set """
     result = {}
     if sessionid is None:
         return result
     try:
         global TEST_SERVER_RESULT
         LOCK_OBJ.acquire()
         result = TEST_SERVER_RESULT
         LOCK_OBJ.release()
     except OSError, error:
         LOGGER.error("[ Error: failed to get test result, error:%s ]\n" % error)
开发者ID:shadeimi,项目名称:testkit-lite,代码行数:14,代码来源:tizenmobile.py

示例9: __init_com_module

# 需要导入模块: from commodule.log import LOGGER [as 别名]
# 或者: from commodule.log.LOGGER import error [as 别名]
 def __init_com_module(self, testxml):
     """
         send init test to com_module
         if webapi test,com_module will start testkit-stub
         else com_module send the test case to devices
     """
     starup_prms = self.__prepare_starup_parameters(testxml)
     # init stub and get the session_id
     session_id = self.testworker.init_test(starup_prms)
     if session_id == None:
         LOGGER.error("[ Error: Initialization Error]")
         return False
     else:
         self.set_session_id(session_id)
         return True
开发者ID:liuct,项目名称:testkit-lite,代码行数:17,代码来源:runner.py

示例10: replace_cdata

# 需要导入模块: from commodule.log import LOGGER [as 别名]
# 或者: from commodule.log.LOGGER import error [as 别名]
def replace_cdata(file_name):
    """ replace some character"""
    try:
        abs_path = mktemp()
        new_file = open(abs_path, 'w')
        old_file = open(file_name)
        for line in old_file:
            line_temp = line.replace('&lt;![CDATA', '<![CDATA')
            new_file.write(line_temp.replace(']]&gt;', ']]>'))
        new_file.close()
        old_file.close()
        remove(file_name)
        move(abs_path, file_name)
    except IOError as error:
        LOGGER.error("[ Error: fail to replace cdata in the result file, "
                     "error: %s ]\n" % error)
开发者ID:liuct,项目名称:testkit-lite,代码行数:18,代码来源:runner.py

示例11: get_version_info

# 需要导入模块: from commodule.log import LOGGER [as 别名]
# 或者: from commodule.log.LOGGER import error [as 别名]
def get_version_info():
    """
        get testkit tool version ,just read the version in VERSION file
        VERSION file must put in /opt/testkit/lite/
    """
    try:
        config = ConfigParser.ConfigParser()
        if platform.system() == "Linux":
            config.read('/opt/testkit/lite/VERSION')
        else:
            version_file = os.path.join(sys.path[0], 'VERSION')
            config.read(version_file)
        version = config.get('public_version', 'version')
        return version
    except KeyError as error:
        LOGGER.error(
            "[ Error: fail to parse version info, error: %s ]\n" % error)
        return ""
开发者ID:liuct,项目名称:testkit-lite,代码行数:20,代码来源:runner.py

示例12: get_capability

# 需要导入模块: from commodule.log import LOGGER [as 别名]
# 或者: from commodule.log.LOGGER import error [as 别名]
    def get_capability(self, file_name):
        """get_capability from file """

        capability_xml = file_name
        capabilities = {}
        try:
            parse_tree = etree.parse(capability_xml)
            root_em = parse_tree.getroot()
            for tcap in root_em.getiterator('capability'):
                capability = get_capability_form_node(tcap)
                capabilities = dict(capabilities, **capability)

            self.set_capability(capabilities)
            return True
        except IOError as error:
            LOGGER.error(
                "[ Error: fail to parse capability xml, error: %s ]" % error)
            return False
开发者ID:liuct,项目名称:testkit-lite,代码行数:20,代码来源:runner.py

示例13: __splite_external_test

# 需要导入模块: from commodule.log import LOGGER [as 别名]
# 或者: from commodule.log.LOGGER import error [as 别名]
    def __splite_external_test(self, resultfile, test_file_name, resultdir):
        """select external_test"""
        testsuite_dict_value_list = []
        testsuite_dict_add_flag = 0
        filename_diff = 1

        parser = etree.parse(resultfile)
        for tsuite in parser.getiterator('suite'):
            root = etree.Element('test_definition')
            suitefilename = os.path.splitext(resultfile)[0]
            suitefilename += ".suite_%s.xml" % filename_diff
            suitefilename = JOIN(resultdir, suitefilename)
            tsuite.tail = "\n"
            root.append(tsuite)
            try:
                with open(suitefilename, 'w') as output:
                    tree = etree.ElementTree(element=root)
                    tree.write(output)
            except IOError as error:
                LOGGER.error("[ Error: create filtered result file: %s failed,\
                 error: %s ]" % (suitefilename, error))
            case_suite_find = etree.parse(
                suitefilename).getiterator('testcase')
            if case_suite_find:
                if tsuite.get('launcher'):
                    if tsuite.get('launcher').find('WRTLauncher'):
                        self.__splite_core_test(suitefilename)
                    else:
                        testsuite_dict_value_list.append(suitefilename)
                        if testsuite_dict_add_flag == 0:
                            self.exe_sequence.append(test_file_name)
                        testsuite_dict_add_flag = 1
                        self.resultfiles.add(suitefilename)
                else:
                    if self.filter_rules["execution_type"] == ["auto"]:
                        self.core_auto_files.append(suitefilename)
                    else:
                        self.core_manual_files.append(suitefilename)
                    self.resultfiles.add(suitefilename)
            filename_diff += 1
        if testsuite_dict_add_flag:
            self.testsuite_dict[test_file_name] = testsuite_dict_value_list
开发者ID:liuct,项目名称:testkit-lite,代码行数:44,代码来源:runner.py

示例14: __merge_result_by_name

# 需要导入模块: from commodule.log import LOGGER [as 别名]
# 或者: from commodule.log.LOGGER import error [as 别名]
 def __merge_result_by_name(
         self, result_set, total_set, result_suite, total_suite):
     ''' merge result select by name'''
     if result_set.get('name') == total_set.get('name') \
             and result_suite.get('name') == total_suite.get('name'):
         if result_set.get('set_debug_msg'):
             total_set.set("set_debug_msg", result_set.get('set_debug_msg'))
         # set cases that doesn't have result in result \
         # set to N/A
         # append cases from result set to total set
         result_case_iterator = result_set.getiterator(
             'testcase')
         if result_case_iterator:
             # LOGGER.info("----[ suite: %s, set: %s, time: %s ]"
             #% (result_suite.get('name'), result_set.get('name'),
             #    datetime.today().strftime("%Y-%m-%d_%H_%M_%S")))
             for result_case in result_case_iterator:
                 try:
                     self.__count_result(result_case)
                     total_set.append(result_case)
                 except IOError as error:
                     LOGGER.error("[ Error: fail to append %s, error: %s ]"
                                  % (result_case.get('id'), error))
开发者ID:liuct,项目名称:testkit-lite,代码行数:25,代码来源:runner.py

示例15: __check_test_status

# 需要导入模块: from commodule.log import LOGGER [as 别名]
# 或者: from commodule.log.LOGGER import error [as 别名]
    def __check_test_status(self):
        '''
            get_test_status from com_module
            check the status
            if end ,return ture; else return False
        '''
        # check test running or end
        # if the status id end return True ,else return False

        session_status = self.testworker.get_test_status(self.session_id)
        # session_status["finished"] == "0" is running
        # session_status["finished"] == "1" is end
        if not session_status == None:
            if session_status["finished"] == "0":
                progress_msg_list = session_status["msg"]
                for line in progress_msg_list:
                    LOGGER.info(line)
                return False
            elif session_status["finished"] == "1":
                return True
        else:
            LOGGER.error("[ session status error ,pls finalize test ]\n")
            # return True to finished this set  ,becasue server error
            return True
开发者ID:liuct,项目名称:testkit-lite,代码行数:26,代码来源:runner.py


注:本文中的commodule.log.LOGGER.error方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。