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


Python LOGGER.error方法代码示例

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


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

示例1: kill_stub

# 需要导入模块: from testkitlite.util.log import LOGGER [as 别名]
# 或者: from testkitlite.util.log.LOGGER import error [as 别名]
 def kill_stub(self):
     stub_status = False
     server_url = "http://%s:9000" % self.deviceip
     ret = http_request(
         get_url(server_url, "/kill_stub"), "GET", {})
     if ret is None:
         LOGGER.error("[ ERROR: get server status timeout, please check deivce! ]")
     else: 
         if ret.get("OK") is not None:
             stub_status = True
     return stub_status
开发者ID:Shao-Feng,项目名称:testkit-lite,代码行数:13,代码来源:windowshttp.py

示例2: launch_stub

# 需要导入模块: from testkitlite.util.log import LOGGER [as 别名]
# 或者: from testkitlite.util.log.LOGGER import error [as 别名]
 def launch_stub(self, stub_app, stub_port="8000", debug_opt=""):
     stub_status = False
     server_url = "http://%s:9000" % self.deviceip
     ret = http_request(
         get_url(server_url, "/launch_stub"), "GET", {})
     if ret is None:
         LOGGER.error("[ ERROR: get server status timeout, please check deivce! ]")
     else: 
         if ret.get("OK") is not None:
             stub_status = True
     return stub_status
开发者ID:Shao-Feng,项目名称:testkit-lite,代码行数:13,代码来源:windowshttp.py

示例3: check_process

# 需要导入模块: from testkitlite.util.log import LOGGER [as 别名]
# 或者: from testkitlite.util.log.LOGGER import error [as 别名]
 def check_process(self, process_name):
     stub_status = 0       
     server_url = "http://%s:9000" % self.deviceip
     LOGGER.error("[ Server URL: %s]" % server_url)
     ret = http_request(
         get_url(server_url, "/check_stub"), "GET", {})
     if ret is None:
         LOGGER.error("[ ERROR: get server status timeout, please check deivce! ]")
     else: 
         if ret.get("OK") is not None:
             stub_status = 1
     return stub_status
开发者ID:Shao-Feng,项目名称:testkit-lite,代码行数:14,代码来源:windowshttp.py

示例4: __init__

# 需要导入模块: from testkitlite.util.log import LOGGER [as 别名]
# 或者: from testkitlite.util.log.LOGGER import error [as 别名]
 def __init__(self, config):
     self.conn = None
     if "commodule" in config:
         try:
             exec "from testkitlite.commodule.%s import get_target_conn" % config[
                 "commodule"]
             device_no = config.get('deviceid', None)
             if device_no is not None:
                 self.conn = get_target_conn(device_no)
             else:
                 self.conn = get_target_conn()
         except Exception as error:
             LOGGER.error("[ Error: Initialize commodule failed: '%s']\n" % error)
开发者ID:zhuyongyong,项目名称:testkit-lite,代码行数:15,代码来源:connector.py

示例5: _bdd_test_exec

# 需要导入模块: from testkitlite.util.log import LOGGER [as 别名]
# 或者: from testkitlite.util.log.LOGGER import error [as 别名]
def _bdd_test_exec(test_session, cases, result_obj, session_dir):
    """function for running bdd tests"""
    result_obj.set_status(0)
    result_list = []
    for i_case in cases['cases']:
        i_case_timeout = i_case.get('timeout', DEFAULT_TIMEOUT)

        try:
            case_entry = i_case['entry']
            if not EXISTS(case_entry):
                i_case['result'] = STR_BLOCK
                i_case['stdout'] = "[Message]No such file or dirctory: %s" % case_entry
                result_list.append(i_case)
                continue

            case_id = i_case['case_id']
            tmp_result_dir = "%s/%s" % (session_dir, case_id)
            os.makedirs(tmp_result_dir)
            popen_args = "behave %s --junit --junit-directory %s" % (case_entry, tmp_result_dir)
            i_case_proc = subprocess.Popen(args=popen_args, shell=True)
            i_case_pre_time = time.time()
            while True:
                i_case_exit_code = i_case_proc.poll()
                i_case_elapsed_time = time.time() - i_case_pre_time
                if i_case_exit_code == None:
                    if i_case_elapsed_time >= i_case_timeout:
                        tr_utils.KillAllProcesses(ppid=i_case_proc.pid)
                        i_case['result'] = STR_BLOCK
                        i_case['stdout'] = "[Message]Timeout"
                        LOGGER.debug("Run %s timeout" % case_id)
                        break
                elif str(i_case_exit_code) == str(i_case['expected_result']):
                    i_case['result'] = STR_PASS
                    i_case['stdout'] = tmp_result_dir
                    break
                else:
                    i_case['result'] = STR_FAIL
                    i_case['stdout'] = tmp_result_dir
                    break
                time.sleep(1)
        except KeyError:
           i_case['result'] = STR_BLOCK
           i_case['stdout'] = "[Message]No 'bdd_test_script_entry' node."
           LOGGER.error(
               "Run %s: failed: No 'bdd_test_script_entry' node, exit from executer" % case_id)
        except Exception, e:
           i_case['result'] = STR_BLOCK
           i_case['stdout'] = "[Message]%s" % e
           LOGGER.error(
               "Run %s: failed: %s, exit from executer" % (case_id, e))
        result_list.append(i_case)
开发者ID:Shao-Feng,项目名称:testkit-lite,代码行数:53,代码来源:bdd.py

示例6: _iosuiauto_test_exec

# 需要导入模块: from testkitlite.util.log import LOGGER [as 别名]
# 或者: from testkitlite.util.log.LOGGER import error [as 别名]
def _iosuiauto_test_exec(test_session, cases, result_obj, session_dir):
    """function for running iosuiauto tests"""
    result_obj.set_status(0)
    result_list = []
    for i_case in cases['cases']:
        i_case_timeout = i_case.get('timeout', DEFAULT_TIMEOUT)
        try:
            case_entry = i_case['entry']
	    expected_result = int(i_case['expected_result'])
            if not EXISTS(case_entry):
                i_case['result'] = STR_BLOCK
                i_case['stdout'] = "[Message]No such file or dirctory: %s" % case_entry
                result_list.append(i_case)
                continue
            case_id = i_case['case_id']
	    destination = "platform=%s,name=%s" % (os.environ["IOS_PLATFORM"], os.environ["IOS_NAME"])
            if os.environ.get("IOS_VERSION", None):
	        destination = "%s,OS=%s" % (destination, os.environ["IOS_VERSION"])
	    device_id = os.environ["DEVICE_ID"]
            popen_args = 'python %s -d "%s" -u "%s"' % (case_entry, destination, device_id)
            i_case_proc = subprocess.Popen(args=popen_args, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
            i_case_pre_time = time.time()
            while True:
	        output_infos = i_case_proc.communicate()
                i_case_exit_code = i_case_proc.returncode
                i_case_elapsed_time = time.time() - i_case_pre_time
                if i_case_exit_code == None:
                    if i_case_elapsed_time >= i_case_timeout:
                        tr_utils.KillAllProcesses(ppid=i_case_proc.pid)
                        i_case['result'] = STR_BLOCK
                        i_case['stdout'] = "[Message]Timeout"
                        LOGGER.debug("Run %s timeout" % case_id)
			result_list.append(i_case)
                        break
                else:
                    if i_case_exit_code == expected_result:
		        i_case['result'] = STR_PASS
                        i_case['stdout'] = "[Message]" + output_infos[0].replace("\n", "\r")
		    else:
		        i_case['result'] = STR_FAIL
			i_case['stderr'] = output_infos[1].replace("\n", "\r")
                    result_list.append(i_case)
		    break

                time.sleep(1)
        except Exception, e:
           i_case['result'] = STR_BLOCK
           i_case['stdout'] = "[Message]%s" % e
           LOGGER.error(
               "Run %s: failed: %s, exit from executer" % (case_id, e))
           result_list.append(i_case)
开发者ID:JeonghoHan,项目名称:testkit-lite,代码行数:53,代码来源:iosuiauto.py

示例7: _nodeunit_test_exec

# 需要导入模块: from testkitlite.util.log import LOGGER [as 别名]
# 或者: from testkitlite.util.log.LOGGER import error [as 别名]
def _nodeunit_test_exec(test_session, cases, result_obj, session_dir):
    """function for running nodeunit tests"""
    result_obj.set_status(0)
    result_list = []
    for i_case in cases['cases']:
        i_case_timeout = i_case.get('timeout', DEFAULT_TIMEOUT)

        try:
            case_entry = i_case['entry']
            if not EXISTS(case_entry):
                i_case['result'] = STR_BLOCK
                i_case['stdout'] = "[Message]No such file or dirctory: %s" % case_entry
                result_list.append(i_case)
                continue

            case_id = i_case['case_id']
            tmp_result_dir = "%s/%s" % (session_dir, case_id)
            os.makedirs(tmp_result_dir)
            popen_args = "nodeunit %s --reporter junit --output %s" % (case_entry, tmp_result_dir)
            i_case_proc = subprocess.Popen(args=popen_args, shell=True, stderr=subprocess.PIPE)
            i_case_pre_time = time.time()

            while True:
                i_case_exit_code = i_case_proc.poll()
                i_case_elapsed_time = time.time() - i_case_pre_time

                if i_case_exit_code == None:
                    if i_case_elapsed_time >= i_case_timeout:
                        tr_utils.KillAllProcesses(ppid=i_case_proc.pid)
                        i_case['result'] = STR_BLOCK
                        i_case['stdout'] = "[Message]Timeout"
                        LOGGER.debug("Run %s timeout" % case_id)
                        break
                else:
                    if int(i_case_exit_code) == 0:
                        i_case['result'] = STR_PASS
                        i_case['stdout'] = tmp_result_dir
                    elif int(i_case_exit_code) == 1:
                        i_case['result'] = STR_FAIL
                        i_case['stdout'] = tmp_result_dir
                    else:
                        i_case['result'] = STR_BLOCK
                        i_case['stdout'] = "[Message]%s" % ''.join(i_case_proc.stderr.readlines()).strip('\n')
                    break
                time.sleep(1)
        except Exception, e:
           i_case['result'] = STR_BLOCK
           i_case['stdout'] = "[Message]%s" % e
           LOGGER.error(
               "Run %s: failed: %s, exit from executer" % (case_id, e))
        result_list.append(i_case)
开发者ID:Shao-Feng,项目名称:testkit-lite,代码行数:53,代码来源:nodeunit.py

示例8: _xcunit_test_exec

# 需要导入模块: from testkitlite.util.log import LOGGER [as 别名]
# 或者: from testkitlite.util.log.LOGGER import error [as 别名]
def _xcunit_test_exec(test_session, cases, result_obj, session_dir):
    """function for running xcunit tests"""
    result_obj.set_status(0)
    result_list = []
    for i_case in cases['cases']:
        i_case_timeout = i_case.get('timeout', DEFAULT_TIMEOUT)
        try:
            case_entry = i_case['entry']
            if not EXISTS(case_entry):
                i_case['result'] = STR_BLOCK
                i_case['stdout'] = "[Message]No such file or dirctory: %s" % case_entry
                result_list.append(i_case)
                continue
            case_id = i_case['case_id']
	    destination = "platform=%s,name=%s" % (os.environ["IOS_PLATFORM"], os.environ["IOS_NAME"])
            if os.environ.get("IOS_VERSION", None):
	        destination = "%s,OS=%s" % (destination, os.environ["IOS_VERSION"])
            popen_args = 'python %s -d "%s"' % (case_entry, destination)
            i_case_proc = subprocess.Popen(args=popen_args, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
            i_case_pre_time = time.time()
            while True:
		output_infos = i_case_proc.communicate()
                i_case_exit_code = i_case_proc.returncode
                i_case_elapsed_time = time.time() - i_case_pre_time
                if i_case_exit_code == None:
                    if i_case_elapsed_time >= i_case_timeout:
                        tr_utils.KillAllProcesses(ppid=i_case_proc.pid)
                        i_case['result'] = STR_BLOCK
                        i_case['stdout'] = "[Message]Timeout"
                        LOGGER.debug("Run %s timeout" % case_id)
			result_list.append(i_case)
                        break
                else:
                    for line in output_infos[0].split('\n'):
		        result_dic = {}
			if line.startswith("Test Case '-["):
			    if line.find("seconds") != -1:
			        info_list = line.split(' ')
                                result_dic['case_id'] = "%s/%s" % (info_list[2][3:], info_list[3][:-2])
                                result_dic['result'] = {"passed": STR_PASS, "failed": STR_FAIL}[info_list[4]] 
				result_list.append(result_dic)
                    break
                time.sleep(1)
        except Exception, e:
           i_case['result'] = STR_BLOCK
           i_case['stdout'] = "[Message]%s" % e
           LOGGER.error(
               "Run %s: failed: %s, exit from executer" % (case_id, e))
           result_list.append(i_case)
开发者ID:Shao-Feng,项目名称:testkit-lite,代码行数:51,代码来源:xcunit.py

示例9: _mocha_test_exec

# 需要导入模块: from testkitlite.util.log import LOGGER [as 别名]
# 或者: from testkitlite.util.log.LOGGER import error [as 别名]
def _mocha_test_exec(test_session, cases, result_obj, session_dir):
    """function for running mocha tests"""
    result_obj.set_status(0)
    result_list = []
    for i_case in cases['cases']:
        i_case_timeout = i_case.get('timeout', DEFAULT_TIMEOUT)

        try:
            case_entry = i_case['entry']
            status, output =  commands.getstatusoutput("ssh %s 'ls %s'" %  (os.environ["DEVICE_ID"], case_entry))
            if status != 0:
                i_case['result'] = STR_BLOCK
                i_case['stdout'] = "[Message]No such file or dirctory: %s" % case_entry
                result_list.append(i_case)
                continue

            case_id = i_case['case_id']
            tmp_result_dir = "%s/json_results" % session_dir
            os.makedirs(tmp_result_dir)
            popen_args = "ssh %s 'mocha %s --reporter json' > %s/%s.json" % (os.environ["DEVICE_ID"], case_entry, tmp_result_dir, case_id)
            i_case_proc = subprocess.Popen(args=popen_args, shell=True)
            i_case_pre_time = time.time()
            while True:
                i_case_exit_code = i_case_proc.poll()
                i_case_elapsed_time = time.time() - i_case_pre_time
                if i_case_exit_code == None:
                    if i_case_elapsed_time >= i_case_timeout:
                        tr_utils.KillAllProcesses(ppid=i_case_proc.pid)
                        i_case['result'] = STR_BLOCK
                        i_case['stdout'] = "[Message]Timeout"
                        LOGGER.debug("Run %s timeout" % case_id)
                        break
                else:
                    i_case['result'] = STR_FAIL
                    i_case['stdout'] = tmp_result_dir
                    break
                time.sleep(1)
        except Exception, e:
           i_case['result'] = STR_BLOCK
           i_case['stdout'] = "[Message]%s" % e
           LOGGER.error(
               "Run %s: failed: %s, exit from executer" % (case_id, e))
        result_list.append(i_case)
开发者ID:testkit,项目名称:testkit-lite,代码行数:45,代码来源:mocha.py

示例10: _core_test_exec

# 需要导入模块: from testkitlite.util.log import LOGGER [as 别名]
# 或者: from testkitlite.util.log.LOGGER import error [as 别名]
def _core_test_exec(conn, test_session, test_set_name, exetype, cases_queue, result_obj):
    """function for running core tests"""
    exetype = exetype.lower()
    total_count = len(cases_queue)
    current_idx = 0
    manual_skip_all = False
    result_list = []
    stdout_file = FILES_ROOT + test_session + "_stdout.log"
    stderr_file = FILES_ROOT + test_session + "_stderr.log"
    initscript = os.environ.get('initscript','')
    postscript = os.environ.get('postscript','')
    for test_case in cases_queue:
        if result_obj.get_status() == 1:
            break

        current_idx += 1
        core_cmd = ""
        if "entry" in test_case:
            core_cmd = test_case["entry"]
        else:
            LOGGER.info(
                "[ Warnning: test script is empty,"
                " please check your test xml file ]")
            continue
        expected_result = test_case.get('expected_result', '0')
        time_out = int(test_case.get('timeout', '90'))
        location = test_case.get('location', 'device')
        measures = test_case.get('measures', [])
        retmeasures = []
        #LOGGER.info("CASE_ID %s"  %test_case['case_id'])
        os.environ['CASE_ID'] = test_case['case_id']
        LOGGER.info("\n[core test] execute case:\nTestCase: %s\n"
                    "TestEntry: %s\nExpected: %s\nTotal: %s, Current: %s"
                    % (test_case['case_id'], test_case['entry'],
                       expected_result, total_count, current_idx))
        LOGGER.info("[ execute core test script, please wait ! ]")
        strtime = datetime.now().strftime(DATE_FORMAT_STR)
        LOGGER.info("start time: %s" % strtime)
        test_case["start_at"] = strtime
        if exetype == 'auto':
            return_code, stdout, stderr = -1, [], []
            if location == 'host':
                if len(initscript) > 1:
                    return_code, stdout, stderr = conn.shell_cmd_host(initscript, time_out, False, stdout_file, stderr_file)
                   
                    if return_code is not None and return_code != "timeout":
                        LOGGER.info('init script ok')
                    else:
                        LOGGER.info('init script fail')
                return_code, stdout, stderr = -1, [], []
                return_code, stdout, stderr = conn.shell_cmd_host(core_cmd, time_out, False, stdout_file, stderr_file)
            else:
                if len(initscript) >1 :
                    return_code, stdout, stderr = conn.shell_cmd_ext(initscript, time_out, False, stdout_file, stderr_file)
                    if return_code is not None and return_code != "timeout":
                        LOGGER.info('init script ok')
                    else:
                        LOGGER.info('init script fail')
                return_code, stdout, stderr = -1, [], []
                return_code, stdout, stderr = conn.shell_cmd_ext(core_cmd, time_out, False, stdout_file, stderr_file)
            print 'return ', return_code, stdout, stderr
            if return_code is not None and return_code != "timeout":
                test_case["result"] = "pass" if str(
                    return_code) == expected_result else "fail"
                test_case["stdout"] = stdout
                test_case["stderr"] = stderr
                for item in measures:
                    ind = item['name']
                    fname = item['file']
                    if fname is None:
                        continue
                    tmpname = FILES_ROOT + test_session + "_mea_tmp"
                    if conn.download_file(fname, tmpname):
                        try:
                            config = ConfigParser.ConfigParser()
                            config.read(tmpname)
                            item['value'] = config.get(ind, 'value')
                            retmeasures.append(item)
                            os.remove(tmpname)
                        except IOError as error:
                            LOGGER.error(
                                "[ Error: fail to parse value,"
                                " error:%s ]\n" % error)
                test_case["measures"] = retmeasures
            else:
                test_case["result"] = "BLOCK"
                test_case["stdout"] = stdout
                test_case["stderr"] = stderr
        elif exetype == 'manual':
            # handle manual core cases
            try:
                # LOGGER.infopre-condition info
                if "pre_condition" in test_case:
                    LOGGER.info("\n****\nPre-condition: %s\n ****\n"
                                % test_case['pre_condition'])
                # LOGGER.infostep info
                if "steps" in test_case:
                    for step in test_case['steps']:
                        LOGGER.info(
                            "********************\n"
#.........这里部分代码省略.........
开发者ID:zqzhang,项目名称:testkit-lite,代码行数:103,代码来源:default.py

示例11: _web_test_exec

# 需要导入模块: from testkitlite.util.log import LOGGER [as 别名]
# 或者: from testkitlite.util.log.LOGGER import error [as 别名]
def _web_test_exec(conn, server_url, test_web_app, exetype, cases_queue, result_obj):
    """function for running web tests"""
    print 'test_web_app', test_web_app
    exetype = exetype.lower()
    test_set_finished = False
    err_cnt = 0
    for test_group in cases_queue:
        if test_set_finished:
            break

        ret = http_request(
            get_url(server_url, "/set_testcase"), "POST", test_group, 30)
        if ret is None:
            LOGGER.error(
                "[ set testcases timeout, please check device! ]")
            result_obj.set_status(1)
            break

        if not conn.launch_app(test_web_app):
            LOGGER.error("[ ERROR: launch test app %s failed! ]" % test_web_app)
            result_obj.set_status(1)
            break

        while True:
            if result_obj.get_status() == 1:
                test_set_finished = True
                break
            ret = http_request(
                get_url(server_url, "/check_server_status"), "GET", {})
            if ret is None:
                LOGGER.error(
                    "[ ERROR: get server status timeout, please check deivce! ]")
                err_cnt += 1
            else:
                result_cases = ret.get("cases")
                error_code = ret.get("error_code")
                if error_code is not None:
                    if not conn.launch_app(test_web_app):
                        test_set_finished = True
                        result_obj.set_status(1)
                        break
                    if error_code == LAUNCH_ERROR:
                        LOGGER.error("[ ERROR: test app no response, hang or not launched! ]")
                        test_set_finished = True
                        result_obj.set_status(1)
                        break
                    elif error_code == BLOCK_ERROR:
                        LOGGER.error("[ ERROR: test case block issue! ]")
                        err_cnt += 1
                else:
                    err_cnt = 0

                if result_cases is not None and len(result_cases):
                    result_obj.extend_result(result_cases)
                elif exetype == 'manual':
                    LOGGER.info(
                        "[ please execute manual cases ]\r\n")

                if ret["finished"] == 1:
                    test_set_finished = True
                    result_obj.set_status(1)
                    break
                elif ret["block_finished"] == 1:
                    break

            if err_cnt >= CNT_RETRY:
                LOGGER.error(
                    "[ ERROR: get too many errors, stop current set! ]")
                test_set_finished = True
                result_obj.set_status(1)
                break
            time.sleep(2)
开发者ID:zqzhang,项目名称:testkit-lite,代码行数:74,代码来源:default.py


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