コード例 #1
0
def run(filename, path, number=None):

    logger = Logger(filename, path)

    controller = PhoneControl(3)

    serial = controller.read_serial()
    logger.write_log("1st Device on List = {}".format(serial))

    controller.init_device()

    logger.write_log("Script Dial Number---------")
    if number is None:
        n = raw_input("Enter the number to dial : ")
    else:
        n = number

    try:
        dialable, parsedNumber, msg = utils.validate_number(n)
        if dialable:
            logger.write_log(msg + " " + str(parsedNumber))
            action(logger, controller, parsedNumber)
        else:
            logger.error_log("Invalid phone number")
    except Exception as ex:
        logger.error_log(ex.message)
コード例 #2
0
def run(a, op, b, filename="log_calculator.txt"):
    # path to save logs
    cwd_path = os.path.dirname(os.path.abspath(__file__))
    path = os.path.join(cwd_path, "..", "..", "qa", "reports", "")
    logger = Logger(filename, path)
    controller = PhoneControl(1)

    serials = controller.read_serials()
    for i in range(len(serials)):
        logger.write_log(" Device {} = {}".format(i + 1, serials))

        controller.init_device(serials[i])
        device_params = utils.get_device_data(serials[i])
        logger.write_log("Script UI Calculator -----------------")

        try:
            calculator = Calculator(a, op, b)
            if calculator.valid:
                logger.write_log("Operation: " + a + op + b)
                action(logger, controller, calculator, device_params)
            else:
                logger.error_log("Validation of Inputs Failed")
        except SyntaxError as ex:
            logger.end_log(ex.message)
        except ValueError as ex:
            logger.end_log(ex.message)
        except TypeError as ex:
            logger.end_log(ex.message)
        except ZeroDivisionError as ex:
            logger.end_log(ex.message)
        except Exception as ex:
            logger.error_log(ex.message)
コード例 #3
0
ファイル: turn_wifi.py プロジェクト: JoaquinMirandaC/AutomADB
def run(turn, stf_info=None, name="", filename="log_wifi.txt"):
    stf = False
    device_params = {}
    # path to save logs
    path = os.path.dirname(os.path.abspath(__file__))
    path = os.path.join(path, "..", "..", "qa", "reports", "")
    # instantiate logger to save a report file
    logger = Logger(filename, path, name)
    # initiate connection to device(s)
    controller = PhoneControl()
    # if a serial was received, run test only for that single serial
    if stf_info is not None:
        serials = [stf_info['remote_serial']]
        device_params = utils.get_device_data(stf_info['device'])
        stf = True
    else:
        # read the serials
        serials = controller.read_serials()

    for i in range(len(serials)):
        logger.write_log(" Device {} = {}".format(i+1, serials))
        # init device with serial
        controller.init_device(serials[i])
        # get the device parameters from the device version json
        if not stf:
            device_params = utils.get_device_data(serials[i])
        logger.write_log("Script Turn Wifi " + turn + " ---------")
        try:
            action(turn, logger, controller, device_params)
            time.sleep(3)
        except Exception as ex:
            logger.error_log(ex.message)
コード例 #4
0
def run(number=None, filename="log_dialer.txt"):
    # path to save logs
    path = os.path.dirname(os.path.abspath(__file__))
    path = os.path.join(path, "..", "..", "qa", "reports", "")
    logger = Logger(filename, path)

    controller = PhoneControl()

    serials = controller.read_serials()
    for i in range(len(serials)):
        logger.write_log(" Device {} = {}".format(i + 1, serials))

        controller.init_device(serials[i])
        device_params = utils.get_device_data(serials[i])
        logger.write_log("Script Dial Number---------")
        if number is None:
            n = raw_input("Enter the number to dial : ")
        else:
            n = number
        try:
            dialable, parsedNumber, msg = utils.validate_number(n)
            if dialable:
                logger.write_log(msg + " " + str(parsedNumber))
                action(logger, controller, parsedNumber, device_params)
            else:
                logger.end_log("Invalid phone number")
        except Exception as ex:
            logger.error_log(ex.message)
コード例 #5
0
def run(filename, path):
    logger = Logger(filename, path)

    controller = PhoneControl(3)

    serial = controller.read_serial()
    logger.write_log("1st Device on List = {}".format(serial))

    controller.init_device()

    logger.write_log("Script Turn Wifi On---------")
    try:
        action(logger, controller)
        time.sleep(3)
    except Exception as ex:
        logger.error_log(ex.message)
コード例 #6
0
def run(number=None, stf_info=None, name="", filename="log_dialer.txt"):
    stf = False
    device_params = {}
    # path to save logs
    path = os.path.dirname(os.path.abspath(__file__))
    path = os.path.join(path, "..", "..", "qa", "reports", "")
    logger = Logger(filename, path, name)

    # 1 sec between steps so dialing is faster
    controller = PhoneControl(1)

    if stf_info is not None:
        serials = [stf_info['remote_serial']]
        device_params = utils.get_device_data(stf_info['device'])
        stf = True
    else:
        serials = controller.read_serials()

    for i in range(len(serials)):
        logger.write_log(" Device {} = {}".format(i + 1, serials))

        controller.init_device(serials[i])

        if not stf:
            device_params = utils.get_device_data(serials[i])

        logger.write_log("Script Dial Number UI---------")
        if number is None:
            n = raw_input("Enter the number to dial : ")
        else:
            n = number
        try:
            dialable, parsedNumber, msg = utils.validate_number(n)
            if dialable:
                logger.write_log(msg + " " + str(parsedNumber))
                action(logger, controller, parsedNumber, device_params)
            else:
                logger.end_log("Invalid phone number")
        except Exception as ex:
            logger.error_log(ex.message)
コード例 #7
0
def run(turn, filename="log_wifi.txt"):
    # path to save logs
    path = os.path.dirname(os.path.abspath(__file__))
    path = os.path.join(path, "..", "..", "qa", "reports", "")
    # instantiate logger to save a report file
    logger = Logger(filename, path)
    # initiate connection to device(s)
    controller = PhoneControl()
    # read the serials
    serials = controller.read_serials()
    for i in range(len(serials)):
        logger.write_log(" Device {} = {}".format(i + 1, serials))
        # init device with serial
        controller.init_device(serials[i])
        # get the device parameters from the device version dictionary
        device_params = utils.get_device_data(serials[i])
        logger.write_log("Script Turn Wifi " + turn + " ---------")
        try:
            action(turn, logger, controller, device_params)
            time.sleep(3)
        except Exception as ex:
            logger.error_log(ex.message)