示例#1
0
def post_cmd_start():
    fcode = get_factorycode()
    devicecode = get_devicecode()
    running = get_running_state()
    test_mode = get_sqlite_value3('r_test_mode')

    # 1. return if still running
    if running:
        return redirect(url_for('blue_test.vf_running'))

    # 2. adjust datas in testdatas table
    # update_testdatas_fcode(fcode)
    # update_testdatas_devicecode(devicecode)
    update_testdatas_bool_qualified_overall()

    # 3. production related actions
    if test_mode == 'production':
        # 3.1 stage testdata
        testdatas_stage()
        # 3.2 upload
        try:
            pass
            # upload_to_cloud()
        except Exception as e:
            logger_app.error('[upload] {}'.format(str(e)))

    errno = get_errno()
    if errno == 0:
        return redirect(url_for('blue_test.vf_finished'))
    else:
        return redirect(url_for('blue_test.vf_error', errno=errno))
示例#2
0
def get_test_mode():
    from app.lib.tools import get_sqlite_value3
    test_mode = get_sqlite_value3('r_test_mode')
    if test_mode == 'production':
        return '生产'
    elif test_mode == 'test':
        return '测试'
    else:
        return 'error'
示例#3
0
文件: mycmd.py 项目: linanster/aging
def start():
    # reserve time for frontend to receive event message
    time.sleep(1)
    logger_app.info('==测试开始==')
    logger_app.info('==starttest begin==')
    testdatas_cleanup()
    reset_errno()
    # set_running_state()
    reset_eventdone_sql()

    devicecode = get_devicecode()
    totalcount = get_totalcount()
    fwversion = get_fwversion()
    mcuversion = get_mcuversion()
    ble_strength_low = get_ble_strength_low()
    wifi_strength_low = get_wifi_strength_low()
    wifi_mac_low = get_sqlite_value3('r_wifi_mac_low')
    wifi_mac_high = get_sqlite_value3('r_wifi_mac_high')
    ble_mac_low = get_sqlite_value3('r_ble_mac_low')
    ble_mac_high = get_sqlite_value3('r_ble_mac_high')
    test_mode = get_sqlite_value3('r_test_mode')

    logger_app.info('==config devicecode: %s==' % devicecode)
    logger_app.info('==config totalcount: %s==' % totalcount)
    logger_app.info('==config fwversion: %s==' % fwversion)
    logger_app.info('==config mcuversion: %s==' % mcuversion)
    logger_app.info('==config ble_strength_low: %s==' % ble_strength_low)
    logger_app.info('==config wifi_strength_low: %s==' % wifi_strength_low)
    logger_app.info('==config wifi_mac_low: %s==' % wifi_mac_low)
    logger_app.info('==config wifi_mac_high: %s==' % wifi_mac_high)
    logger_app.info('==config ble_mac_low: %s==' % ble_mac_low)
    logger_app.info('==config ble_mac_high: %s==' % ble_mac_high)
    logger_app.info('==test mode: %s==' % test_mode)
    # return, if either is not set by test_config setp
    if totalcount is None or devicecode is None or fwversion is None or devicecode == 0:
        errno = 11
        reset_running_state()
        set_errno(errno)
        return errno

    loop = 1
    # while loop <= 3:
    while loop <= 1:
        # METHOD-1
        # errno = subprocess.call("./ble-backend -command=starttest -totalcount={}".format(num), shell=True, cwd=gofolder)

        # METHOD-2
        # p = subprocess.Popen("./ble-backend -command=starttest -totalcount={}".format(num), shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=gofolder)
        # output = p.communicate()
        # output_stdout = output[0].decode('utf-8')
        # output_stderr = output[1].decode('utf-8')
        # errno = p.poll()
        # print(output_stdout)
        # print(output_stderr)

        # METHOD-3
        # p = subprocess.Popen("./ble-backend -command=starttest -totalcount={}".format(num), shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=gofolder)
        # while p.poll() is None:
        #     output = p.stdout.readline().decode('utf-8')[0:-1]
        #     print(output)
        # errno = p.poll()
        # if errno != 0:
        #     errmsg = p.stderr.read().decode('utf-8')[:-1]
        #     print(errmsg)
        #     print(errno)
        # p.stdout.close()
        # p.stderr.close()

        # METHOD-4
        # errno = _gosubprocess("./ble-backend -command=starttest -totalcount={} -deviceid={} -fwversion={} -mcuversion={}".format(totalcount, devicecode, fwversion, mcuversion))
        errno = _gosubprocess("./ble-backend -command=starttest")

        loop += 1
        if errno == 0:
            # todo
            errno = 0
            break
        else:
            testdatas_cleanup()
            # todo
            # errno = 1
            time.sleep(Timeout)
            # subprocess.call("./ble-backend -command=allkickout", shell=True, cwd=gofolder)
            _gosubprocess("./ble-backend -command=allkickout")
            set_retried_sql()
            continue
    if errno == 0:
        logger_app.info('==starttest success==')
        logger_app.info("==errno:{}==".format(errno))
    else:
        logger_app.error('==starttest failed==')
        logger_app.error("==errno:{}==".format(errno))
    # reserve time for frontend to receive event message
    time.sleep(1)
    reset_running_state()
    set_errno(errno)
    logger_app.info('==测试结束==')
    return errno
示例#4
0
def ble_mac_high():
    from app.lib.tools import get_sqlite_value3
    return get_sqlite_value3('r_ble_mac_high')
示例#5
0
def wifi_mac_low():
    from app.lib.tools import get_sqlite_value3
    return get_sqlite_value3('r_wifi_mac_low')