Exemplo n.º 1
0
    def __init__(self, tc_name, global_config):
        """
        Constructor
        """
        LabWifiBase.__init__(self, tc_name, global_config)

        # Get TC Parameters
        self._direction = self._tc_parameters.get_param_value("DIRECTION")
        # Read the DL_FILE value from UseCase xml Parameter
        self._dlfilename = os.path.join(
            self._ftp_path, self._tc_parameters.get_param_value("DL_FILE", ""))
        # Read the UL_FILE value from UseCase xml Parameter
        self._ulfilename = os.path.join(
            self._ftp_path, self._tc_parameters.get_param_value("UL_FILE", ""))
        self._xfer_timeout = int(
            self._tc_parameters.get_param_value("XFER_TIMEOUT"))

        self._xfer_40_to_20mhz_ratio = str(
            self._tc_parameters.get_param_value("XFER_40MHz_TO_20MHz_RATIO",
                                                ""))
        if is_number(self._xfer_40_to_20mhz_ratio):
            self._xfer_40_to_20mhz_ratio = float(self._xfer_40_to_20mhz_ratio)
        else:
            self._xfer_40_to_20mhz_ratio = 1.5

        self._xfer_mimo_to_siso_ratio = str(
            self._tc_parameters.get_param_value("XFER_MIMO_TO_SISO_RATIO", ""))
        if is_number(self._xfer_mimo_to_siso_ratio):
            self._xfer_mimo_to_siso_ratio = float(
                self._xfer_mimo_to_siso_ratio)
        else:
            self._xfer_mimo_to_siso_ratio = 1.5

        self.__1st_iteration = True
Exemplo n.º 2
0
    def __init__(self, tc_name, global_config):

        LabNfcBase.__init__(self, tc_name, global_config)

        # starting height
        self.__starting_Z = self._tc_parameters.get_param_value("STARTING_Z")
        if self.__starting_Z is None:
            self.__starting_Z = 0
        else:
            self.__starting_Z = int(self.__starting_Z)

        # ending height
        self.__max_Z = self._tc_parameters.get_param_value("MAX_Z")
        if self.__max_Z is None:
            self.__max_Z = 0
        else:
            self.__max_Z = int(self.__max_Z)

        # test max Z or not
        self.__is_max_z = str_to_bool(
            self._tc_parameters.get_param_value("FOUND_MAX_Z"))

        # position of the testing square
        self.__right_up_corner_position = str(
            self._tc_parameters.get_param_value("RIGHT_UP_CORNER")).split("x")

        self.__starting_X = int(self.__right_up_corner_position[0])
        self.__starting_Y = int(self.__right_up_corner_position[1])

        # get the resolution
        self.__resolution = int(
            self._tc_parameters.get_param_value("RESOLUTION"))

        # output file
        self.__result_file_name = self._tc_parameters.get_param_value(
            "RESULT_FILE_NAME")
        self.__result_file_handler = open(
            os.path.join(self._saving_directory, self.__result_file_name), 'w')

        # get the antenna position
        nfc_antenna_position = self._device.get_config("NfcAntennaPosition",
                                                       "").split(',')
        if len(nfc_antenna_position) == 2 and is_number(
                nfc_antenna_position[0]) and is_number(
                    nfc_antenna_position[1]):
            self._x_antenna = int(nfc_antenna_position[0])
            self._y_antenna = int(nfc_antenna_position[1])
        else:
            self._x_antenna = 0
            self._y_antenna = 0
Exemplo n.º 3
0
    def __init__(self, tc_name, global_config):
        """
        Initializes this instance.
        """

        # Call UseCase base __init__ method
        UseCaseBase.__init__(self, tc_name, global_config)

        # Retrieve testcase parameters
        self.__launch_mode = self._tc_parameters.get_param_value("LAUNCH_MODE")
        self.__command = self._tc_parameters.get_param_value("COMMAND")
        self.__expected_result = \
            self._tc_parameters.get_param_value("EXPECTED_RESULT")
        self.__command_timeout = \
            self._tc_parameters.get_param_value("COMMAND_TIMEOUT")

        # initialize at proxy connection parameters
        self.__serial_handler = SerialHandler()

        # Instantiate the modem UE commands
        self.__modem_flashing_api = self._device.get_uecmd("ModemFlashing")

        # Check input parameter LAUNCH_MODE
        possible_launch_mode = {"NORMAL": ModemFlashing.AT_PROXY_NORMAL_MODE,
                                "TUNNELING": ModemFlashing.AT_PROXY_TUNNELING_MODE}
        if self.__launch_mode in possible_launch_mode.keys():
            self.__launch_mode = possible_launch_mode[self.__launch_mode]
        else:
            self.__launch_mode = None

        # Check input parameter COMMAND_TIMEOUT
        if is_number(self.__command_timeout) is True:
            self.__command_timeout = int(self.__command_timeout)
        else:
            self.__command_timeout = None
Exemplo n.º 4
0
    def set_atmospheric_params(self,
                               atmospheric_temp=None,
                               humidity=None,
                               transmission=None):
        """
        allow to edit several constant link to atmospheric to tune the measurement

        :type atmospheric_temp: float
        :param atmospheric_temp : Atmospheric temperature in degree celsius.

        :type humidity: float
        :param humidity: Relative humidity of the air. (0.0 to 1.0,30% = 0.30)

        :type transmission: float
        :param transmission: Estimated atmospheric transmission. If it is 0, the camera will calculate a transmission
        """
        if is_number(atmospheric_temp):
            atmospheric_temp = self.__c_to_k(float(atmospheric_temp))

        params_list = {
            "atmTemp": atmospheric_temp,
            "relHum": humidity,
            "estAtmTransm": transmission
        }
        self.__set_object_params(params_list, self.__object_params)
Exemplo n.º 5
0
    def run(self, context):
        """
        Runs the test step

        :type context: TestStepContext
        :param context: test case context
        """
        DeviceTestStepBase.run(self, context)

        property_to_set = self._pars.property.upper()
        # We assert here the possible values instead of checking the "default" case in the big
        # if/elif following in order to make it more testable.
        assert property_to_set in [STR_STATE, STR_TIMEOUT, STR_BRIGHTNESS, STR_BACKLIGHT], \
                                "this is impossible %s" % property_to_set

        value = self._pars.value

        # Call the method that will handle to property to set.

        # Properties with boolean
        if property_to_set == STR_STATE:
            self._manage_state(value)
            return

        # Properties with numbers
        if not is_number(value):
            self._raise_config_exception(STR_INVALID_VALUE)
        if property_to_set == STR_TIMEOUT:
            self._api.set_screen_timeout(int(value))
        elif property_to_set == STR_BACKLIGHT:
            self._api.set_backlight_level(value)
        elif property_to_set == STR_BRIGHTNESS:
            self._api.set_display_brightness(int(value))
Exemplo n.º 6
0
    def set_image_object_params(self,
                                emissivity=None,
                                reflected_temp=None,
                                object_distance=None):
        """
        allow to edit several constants link to the target to tune the measurement

        :type emissivity: float
        :param emissivity: Object emissivity (0.001 to 1.0)

        :type reflected_temp: float
        :param reflected_temp: Temperature of the surroundings reflected in the object, in degree celsius.

        :type object_distance: float
        :param object_distance: Distance from the camera to the target in meter.

        """
        # convert to kelvin this value

        if is_number(reflected_temp):
            reflected_temp = self.__c_to_k(float(reflected_temp))

        params_list = {
            "emissivity": emissivity,
            "ambTemp": reflected_temp,
            "objectDistance": object_distance
        }
        self.__set_object_params(params_list, self.__object_params)
    def set_up(self):
        """
        Initialize the test
        """
        # Call UseCase base Setup function
        UseCaseBase.set_up(self)

        # Check value of FILENAME parameter
        if self._audio_filename == "" or is_number(self._audio_filename):
            error_msg = "The parameter FILENAME must a string containing the local audio file or an url !"
            self.get_logger().error(error_msg)
            raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, error_msg)

        # Check if needed to enable data for audio streaming
        if self._audio_filename.startswith("http://"):
            self._use_data_connection = True
        else:
            # To prevent b2b iterations
            self._use_data_connection = False

        # Check value of VOLUME parameter
        if self._multimedia_volume < 0 or self._multimedia_volume > 100:
            error_msg = "The parameter VOLUME must be an integer between 0 and 100 !"
            self.get_logger().error(error_msg)
            raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, error_msg)

        # FILENAME is an url, enable data connection
        if self._use_data_connection:
            self._enable_data_connection()

        # Get audio file duration
        audio_file_duration = self._multimedia_api.get_media_file_duration(self._audio_filename)

        # Check value of DURATION parameter
        if self._audio_duration == "":
            self.get_logger().warning("The parameter DURATION is empty! The whole audio file will be played.")
            self._audio_duration = audio_file_duration
            # Add a delay to make sure the use case play whole the file
            self._audio_duration += 5

        elif self._audio_duration <= 0:
            error_msg = "The parameter DURATION must be an integer strictly upper than 0 !"
            self.get_logger().error(error_msg)
            raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, error_msg)

        else:
            if self._audio_duration > audio_file_duration:
                self.get_logger().warning("The parameter DURATION is upper than audio file duration ! "
                                          "The whole audio file will be played.")
                self._audio_duration = audio_file_duration
                # Add a delay to make sure the use case play whole the file
                self._audio_duration += 5

        # Disable device lock screen
        self._phonesystem_api.disable_lockscreen(True)
        # Set phone to keep the device display on and wake it up
        self._phonesystem_api.display_on()
        self._phonesystem_api.wake_screen()

        return Global.SUCCESS, "No errors"
Exemplo n.º 8
0
    def __check_tc_parameters(self):
        """
        Check validity of TC parameters
        """
        # pylint: disable=R0912
        self._bt_tethering_deactivation_test = \
            str_to_bool(str(self._bt_tethering_deactivation_test))
        self._lola_test = str_to_bool(str(self._lola_test))

        if self._nap_or_pan_test in ["PAN", "PANU", "PAN-U"]:
            self._nap_or_pan_test = "PAN-U"
        if self._nap_or_pan_test not in ["NAP", "PAN-U"]:
            msg = "Wrong TC parameter NAP_OR_PAN_TEST"
            self._logger.error(msg)
            raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg)
        if self._pairing_initiator not in ["PHONE1", "PHONE2"]:
            msg = "Wrong TC parameter PAIRING_INITIATOR"
            self._logger.error(msg)
            raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg)
        if self._who_disconnect in ["PAN", "PANU", "PAN-U"]:
            self._who_disconnect = "PAN-U"
        if self._who_disconnect not in ["NAP", "PAN-U"]:
            msg = "Wrong TC parameter WHO_DISCONNECT"
            self._logger.error(msg)
            raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg)
        if self._who_restarts_bt in ["PAN", "PANU", "PAN-U"]:
            self._who_restarts_bt = "PAN-U"
        if self._who_restarts_bt not in ["NONE", "NAP", "PAN-U"]:
            msg = "Wrong TC parameter WHO_RESTARTS_BT_BEFORE_TEST"
            self._logger.error(msg)
            raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg)
        if self._connection_to_share not in ["CELLULAR", "WIFI"]:
            msg = "Wrong TC parameter CONNECTION_TO_SHARE"
            self._logger.error(msg)
            raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg)
        if self._connection_to_share == "WIFI" \
                and self._wifi_access_point == "":
            msg = "TC parameter WIFI_ACCESS_POINT not defined"
            self._logger.error(msg)
            raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg)
        if self._server_to_ping == "" \
                and self._connection_to_share == "CELLULAR":
            msg = "TC parameter SERVER_TO_PING not defined"
            self._logger.error(msg)
            raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg)
        if not self._packet_count.isdigit():
            msg = "Wrong TC parameter PACKET_COUNT"
            self._logger.error(msg)
            raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg)
        if not self._packet_size.isdigit():
            msg = "Wrong TC parameter PACKET_SIZE"
            self._logger.error(msg)
            raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg)
        if not is_number(self._target_packet_loss_rate):
            msg = "Wrong TC parameter TARGET_PACKET_LOSS_RATE"
            self._logger.error(msg)
            raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg)
        else:
            self._target_packet_loss_rate = \
                float(self._target_packet_loss_rate)
Exemplo n.º 9
0
    def __init__(self, tc_name, global_config):
        """
        Constructor
        """
        LiveNfcBase.__init__(self, tc_name, global_config)

        # Create NFC robot
        self._nfc_robot = self._em.get_nfc_robot("NFC_ROBOT1")

        # Get the TC parameter: Should we use offset for robot moves (considering antenna position on DUT)
        self._use_antenna_offset = str_to_bool_ex(
            self._tc_parameters.get_param_value("USE_ANTENNA_OFFSET", ""))
        self._x_offset = None
        self._y_offset = None
        if self._use_antenna_offset:
            # Get the NFC antenna position from Device_Catalog.xml
            nfc_antenna_position = self._device.get_config(
                "NfcAntennaPosition", "").split(',')
            if len(nfc_antenna_position) == 2 and \
                    is_number(nfc_antenna_position[0]) and is_number(nfc_antenna_position[1]):
                self._x_offset = int(nfc_antenna_position[0])
                self._y_offset = int(nfc_antenna_position[1])
Exemplo n.º 10
0
    def _compare_using_math_operators(self):
        interval_radius = None
        if self._pars.operator == self.WITHIN_BOUNDS:
            temp = self._pars.second.split(',')
            if len(temp) == 2:
                self._pars.second = temp[0]
                interval_radius = temp[1]
            else:
                self._raise_config_exception(
                    "Must have exactly 2 elements in a comma separated list for SECOND",
                    AcsConfigException.OPERATION_FAILED)
            if is_number(self._pars.first) and is_number(
                    self._pars.second) and is_number(interval_radius):
                first = float(self._pars.first)
                second = float(self._pars.second)
                interval_radius = float(interval_radius)
            else:
                self._raise_config_exception(
                    "FIRST, SECOND and interval_radius(2nd element derived from separating SECOND) must be both numbers",
                    AcsConfigException.OPERATION_FAILED)

            self._logger.info(
                "Evaluate {0} {1} {2} with interval radius {3}; it's expected to be {4}"
                .format(first, self._pars.operator, second, interval_radius,
                        self._pars.pass_if))
        else:
            if is_number(self._pars.first) and is_number(self._pars.second):
                first = float(self._pars.first)
                second = float(self._pars.second)
            else:
                first = str(self._pars.first)
                second = str(self._pars.second)

            self._logger.info("Evaluate %s %s %s; it's expected to be %s" %
                              (str(first), self._pars.operator, str(second),
                               str(self._pars.pass_if)))

        return self._do_compare(first, second, self._pars.operator,
                                interval_radius)
Exemplo n.º 11
0
    def _robot_positioning(self, x_coordinate, y_coordinate, z_coordinate,
                           timer):
        """
        Change robot position considering offset if required
        :type x_coordinate: str
        :param x_coordinate: X-axis coordinate. Use "null" to move along Z axis
        :type y_coordinate : str
        :param y_coordinate: Y-axis coordinate. Use "null" to move along Z axis
        :type z_coordinate : str
        :param z_coordinate: Z-axis coordinate. Use "null" to move in XY plan
        :type timer : str
        :param timer: time in seconds to stay in position before coming back at origin. Use "null" to keep the position
        """
        if self._use_antenna_offset:
            if is_number(x_coordinate):
                self._logger.debug("X position before offset: " + x_coordinate)
                x_coordinate = str(int(x_coordinate) + self._x_offset)
            if is_number(y_coordinate):
                self._logger.debug("Y position before offset: " + y_coordinate)
                y_coordinate = str(int(y_coordinate) + self._y_offset)

        self._logger.info("Start moving robot")
        self._nfc_robot.positioning(x_coordinate, y_coordinate, z_coordinate,
                                    timer)
Exemplo n.º 12
0
    def set_external_optic_params(self, temperature=None, transmission=None):
        """
        allow to edit several constant link to optical to tune the measurement

        :type temperature: float
        :param temperature: External Optics temperature in degree celsius. Used for heat shields, close-up lenses etc.

        :type transmission: float
        :param transmission: External Optics transmission. (0.001 to 1.0) Set to 1.0 if no external optics is present
        """
        if is_number(temperature):
            temperature = self.__c_to_k(float(temperature))

        params_list = {"extOptTemp": temperature, "extOptTransm": transmission}
        self.__set_object_params(params_list, self.__object_params)
Exemplo n.º 13
0
    def positioning(self, xCoordinate, yCoordinate, zCoordinate, timer):
        """
        Change robot position
        :type xCoordinate: str
        :param xCoordinate: X-axis coordinate. Use "null" to move along Z axis
        :type yCoordinate : str
        :param yCoordinate: Y-axis coordinate. Use "null" to move along Z axis
        :type zCoordinate : str
        :param zCoordinate: Z-axis coordinate. Use "null" to move in XY plan
        :type timer : str
        :param timer: time in seconds to stay in position before coming back at origin. Use "null" to keep the position
        """

        # make sure that the com interface is released
        self._serialtesting()

        cmd_line = "%s %s %s %s %s" % (xCoordinate, yCoordinate, zCoordinate, timer, self.serial_com_port)

        # try several time in case of unhandled exceptions
        for i in range(self.__retrieve):
            try:
                ExeRunner.start_exe(self, cmd_line)
                break
            except TestEquipmentException:
                # if we are in the last try, raise the test equipment exception
                if i == self.__retrieve-1:
                    raise (TestEquipmentException.CRITICAL_FAILURE, " Robot failed to move see log")
                # if robot failed, just wait and try again
                time.sleep(5)
                pass

        # save new position
        if is_number(xCoordinate) and is_number(yCoordinate) and is_number(zCoordinate):
            self.__current_position['x'] = int(xCoordinate)
            self.__current_position['y'] = int(yCoordinate)
            self.__current_position['z'] = int(zCoordinate)
Exemplo n.º 14
0
    def get_backlight_level(self):
        """
        Gets the backlight level info

        :rtype: int
        :return: The backlight level
        """
        module_name, class_name = self._get_module_and_class_names("Display")
        output = self._internal_uecmd_exec(module_name, class_name, "getScreenBrightness")
        output = output["values"].get("output")
        if not is_number(output):
            tmp_txt = "get_backlight_level output returned a non integer value %s" % str(output)
            self._logger.error(tmp_txt)
            raise DeviceException(DeviceException.OPERATION_FAILED, tmp_txt)
        else:
            return int(output)
Exemplo n.º 15
0
    def get_screen_timeout(self):
        """
        Gets the time before screen goes to idle.

        :rtype: int
        :return: screen timeout in seconds
        """

        module_name, class_name = self._get_module_and_class_names("Display")
        output = self._internal_uecmd_exec(module_name, class_name, "getScreenTimeout")
        output = output["values"].get("output")
        if not is_number(output):
            tmp_txt = "get_screen_timeout output returned a non integer value %s" % str(output)
            self._logger.error(tmp_txt)
            raise DeviceException(DeviceException.OPERATION_FAILED, tmp_txt)
        else:
            return int(output)
Exemplo n.º 16
0
    def __check_tc_parameters(self):
        """
        Check validity of TC parameters
        """
        self._bt_tethering_deactivation_test = \
            str_to_bool(str(self._bt_tethering_deactivation_test))
        self._lola_test = str_to_bool(str(self._lola_test))

        if self._nap_or_pan_test in ["PAN", "PANU", "PAN-U"]:
            self._nap_or_pan_test = "PAN-U"
        if self._nap_or_pan_test not in ["NAP", "PAN-U"]:
            msg = "Wrong TC parameter NAP_OR_PAN_TEST"
            self._logger.error(msg)
            raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg)
        if self._pairing_initiator not in ["PHONE1", "PHONE2"]:
            msg = "Wrong TC parameter PAIRING_INITIATOR"
            self._logger.error(msg)
            raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg)
        if self._who_disconnect in ["PAN", "PANU", "PAN-U"]:
            self._who_disconnect = "PAN-U"
        if self._who_disconnect not in ["NAP", "PAN-U"]:
            msg = "Wrong TC parameter WHO_DISCONNECT"
            self._logger.error(msg)
            raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg)
        if self._who_restarts_bt in ["PAN", "PANU", "PAN-U"]:
            self._who_restarts_bt = "PAN-U"
        if self._who_restarts_bt not in ["NONE", "NAP", "PAN-U"]:
            msg = "Wrong TC parameter WHO_RESTARTS_BT_BEFORE_TEST"
            self._logger.error(msg)
            raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg)
        if not self._packet_count.isdigit():
            msg = "Wrong TC parameter PACKET_COUNT"
            self._logger.error(msg)
            raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg)
        if not self._packet_size.isdigit():
            msg = "Wrong TC parameter PACKET_SIZE"
            self._logger.error(msg)
            raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg)
        if not is_number(self._target_packet_loss_rate):
            msg = "Wrong TC parameter TARGET_PACKET_LOSS_RATE"
            self._logger.error(msg)
            raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg)
        else:
            self._target_packet_loss_rate = \
                float(self._target_packet_loss_rate)
Exemplo n.º 17
0
 def __set_object_params(self, params_list, ressource):
     """
     internal function to set numeric params
     """
     for key, value in params_list.items():
         if value not in [None, ""]:
             if is_number(value):
                 cmd = "rset " + ressource + ".%s %s" % (key, str(value))
                 self.__send_command(cmd)
                 output = self.__read_info()
                 if output != "":
                     msg = "error happen when performing [%s] : %s" % (
                         cmd, output)
                     self.get_logger().error(msg)
                     raise TestEquipmentException(
                         TestEquipmentException.OPERATION_FAILED, msg)
             else:
                 msg = "set_image_object_params %s parameter should be a number" % (
                     key)
                 self.get_logger().error(msg)
                 raise TestEquipmentException(
                     TestEquipmentException.OPERATION_FAILED, msg)
Exemplo n.º 18
0
    def set_up(self):
        """
        Initialize the test
        """
        # Call UseCase base Setup function
        UseCaseBase.set_up(self)

        # Check value of FILENAME parameter
        if self._video_filename == "" or is_number(self._video_filename):
            error_msg = "The parameter FILENAME must a string containing the local video file !"
            self.get_logger().error(error_msg)
            raise AcsConfigException(AcsConfigException.INVALID_PARAMETER,
                                     error_msg)

        # Check value of VOLUME parameter
        if self._multimedia_volume < 0 or self._multimedia_volume > 100:
            error_msg = "The parameter VOLUME must be an integer between 0 and 100 !"
            self.get_logger().error(error_msg)
            raise AcsConfigException(AcsConfigException.INVALID_PARAMETER,
                                     error_msg)

        # Check value of SCREEN_ORIENTATION
        valid_screen_orientation = [
            "portrait", "landscape", "reverse_portrait", "reverse_landscape"
        ]
        if self._screen_orientation not in (valid_screen_orientation +
                                            [None, ""]):
            error_msg = "The parameter SCREEN_ORIENTATION must be a string with following " \
                        "values: %s or empty value!" % ("".join(valid_screen_orientation))
            self._logger.error(error_msg)
            raise AcsConfigException(AcsConfigException.INVALID_PARAMETER,
                                     error_msg)

        # Get video file duration
        video_file_duration = self._multimedia_api.get_media_file_duration(
            self._video_filename)

        # Check value of DURATION parameter
        if not self._video_duration:
            self.get_logger().warning(
                "The parameter DURATION is empty! The whole video file will be played."
            )
            self._video_duration = video_file_duration
            self._play_whole_file = True
            # when playing video until end of file, there is a delay on DUT side before considering playback complete
            self._settledown_duration = 5

        elif self._video_duration <= 0:
            error_msg = "The parameter DURATION must be an integer strictly upper than 0 !"
            self.get_logger().error(error_msg)
            raise AcsConfigException(AcsConfigException.INVALID_PARAMETER,
                                     error_msg)

        elif self._video_duration > video_file_duration:
            self.get_logger().warning(
                "The parameter DURATION is greater than video file duration ! The "
                "whole video file will be repeated until duration is reached.")
            self._repeat_playback = True

        # Disable device lock screen
        self._phonesystem_api.disable_lockscreen(True)
        # Set phone to keep the device display on and wake it up
        self._phonesystem_api.display_on()
        self._phonesystem_api.wake_screen()

        return Global.SUCCESS, "No errors"
Exemplo n.º 19
0
    def run_async_uecmd(self, module_name, class_name, method_name, args, start_delay, repeat_delay="",
                        total_duration=""):
        """
        Starts an asynchronous uecmd and return a task id to follow the result

        :type  module_name: str
        :param module_name: uecmd module

        :type  class_name: str
        :param class_name: class of uecmd

        :type  method_name: str
        :param method_name: uecmd function

        :type  args: str
        :param args: args to pass to the uecmd

        :type  start_delay: int
        :param start_delay: time in second before starting the uecmd

        :type  repeat_delay: int
        :param repeat_delay: [optional] time in second before repeating the uecmd.
        If used, total_duration must be set too.

        :type  total_duration: int
        :param total_duration: [optional] the maximum duration time in second allowed
        to repeat the uecmd. If used, repeat_delay must be set too.

        :rtype: str
        :return: scheduled task id
        """
        # first check that both
        if is_number(repeat_delay) != is_number(total_duration):
            text = "repeat_delay (%s) and total_duration (%s) must be used together as valid integer" % (
                repeat_delay, total_duration)
            self._logger.error(text)
            raise DeviceException(DeviceException.INVALID_PARAMETER, text)

        # if the var are not numbers and different from their default values, raise an error
        if repeat_delay in ["", None]:
            repeat_delay = 0
        elif is_number(repeat_delay):
            repeat_delay = int(repeat_delay)
        else:
            text = "repeat_delay (%s) must be a valid integer" % str(repeat_delay)
            self._logger.error(text)
            raise DeviceException(DeviceException.INVALID_PARAMETER, text)
        if total_duration in ["", None]:
            total_duration = 0
        elif is_number(total_duration):
            total_duration = int(total_duration)
        else:
            text = "total_duration (%s) must be a valid integer" % str(total_duration)
            self._logger.error(text)
            raise DeviceException(DeviceException.INVALID_PARAMETER, text)

        try:
            result = self.__windows_service.launch_async_uecmd(
                module_name, class_name, method_name, args, self._uecmd_default_timeout, False,
                int(start_delay), repeat_delay, total_duration)
            if result.get_verdict() != CommandResult.VERDICT_PASS or result.has_exception():
                raise DeviceException(DeviceException.OPERATION_FAILED,
                                      str(result.get_verdict_message()))
            return result['task_id']
        # catch service communication errors
        except CommandResultException as cre:
            raise DeviceException(DeviceException.INTERNAL_EXEC_ERROR, str(cre))