Exemplo n.º 1
0
    def __init__(self, serial=''):
        """Initializes the ArduinoWifiDongle object."""
        self.serial = serial
        self.port = self._get_serial_port()
        self.log = logger.create_tagged_trace_logger("ArduinoWifiDongle|%s" %
                                                     self.serial)
        log_path_base = getattr(logging, "log_path", "/tmp/logs")
        self.log_file_path = os.path.join(
            log_path_base, "ArduinoWifiDongle_%s_serial_log.txt" % self.serial)
        self.log_file_fd = open(self.log_file_path, "a")

        self.set_logging = True
        self.lock = threading.Lock()
        self.start_controller_log()

        self.ssid = None
        self.ip_addr = None
        self.status = 0
        self.scan_results = []
        self.scanning = False
        self.ping = False

        try:
            os.stat(TMP_DIR)
        except:
            os.mkdir(TMP_DIR)
Exemplo n.º 2
0
    def __init__(self, serial):
        """Initializes the ArduinoWifiDongle object.

        Args:
            serial: The serial number for the wifi dongle.
        """
        if not serial:
            raise ArduinoWifiDongleError(
                'The ArduinoWifiDongle serial number must not be empty.')
        self.serial = serial
        self.port = self._get_serial_port()
        self.log = logger.create_tagged_trace_logger('ArduinoWifiDongle|%s' %
                                                     self.serial)
        log_path_base = getattr(logging, 'log_path', '/tmp/logs')
        self.log_file_path = os.path.join(
            log_path_base, 'ArduinoWifiDongle_%s_serial_log.txt' % self.serial)
        self.log_file_fd = open(self.log_file_path, 'a')

        self.set_logging = True
        self.lock = threading.Lock()
        self.start_controller_log()

        self.ssid = None
        self.ip_addr = None
        self.status = 0
        self.scan_results = []
        self.scanning = False
        self.ping = False

        os.makedirs(TMP_DIR, exist_ok=True)
Exemplo n.º 3
0
 def __init__(self, config):
     self.config = config.copy()
     self.device_id = self.config['device_id']
     self.log = logger.create_tagged_trace_logger(
         'EInstrumentChamber|{}'.format(self.device_id))
     self.current_mode = None
     self.ser = self._get_serial(config['port'])
Exemplo n.º 4
0
 def __init__(self, config):
     import flow
     self.config = config.copy()
     self.log = logger.create_tagged_trace_logger('OtaChamber|{}'.format(
         self.config['ip_address']))
     self.chamber = ChamberAutoConnect(flow.Flow(), self.config)
     self.stirrer_ids = [0, 1, 2]
     self.current_mode = None
Exemplo n.º 5
0
 def __init__(self, config):
     self.config = config.copy()
     self.device_id = self.config['device_id']
     self.log = logger.create_tagged_trace_logger('OtaChamber|{}'.format(
         self.device_id))
     self.TURNTABLE_FILE_PATH = '/usr/local/bin/fnPerformaxCmd'
     utils.exe_cmd('sudo {} -d {} -i 0'.format(self.TURNTABLE_FILE_PATH,
                                               self.device_id))
     self.current_mode = None
Exemplo n.º 6
0
    def __init__(self, ip_addr):
        """Init method for request instrument.

        Args:
            ip_addr: IP Address.
                Type, Str.
        """
        self._request_timeout = 120
        self._request_protocol = 'http'
        self._ip_addr = ip_addr
        self._escseq = '\r\n'

        self._logger = logger.create_tagged_trace_logger(self._ip_addr)
    def __init__(self, config):
        self.sniffer_proc_pid = None
        self.log = logger.create_tagged_trace_logger('Tshark Sniffer')
        self.ssh_config = config['ssh_config']
        self.sniffer_os = config['os']
        self.run_as_sudo = config.get('run_as_sudo', False)
        self.sniffer_output_file_type = config['output_file_type']
        self.sniffer_snap_length = config['snap_length']
        self.sniffer_interface = config['interface']

        #Logging into sniffer
        self.log.info('Logging into sniffer.')
        self._sniffer_server = ssh.connection.SshConnection(
            ssh.settings.from_config(self.ssh_config))
        # Get tshark params
        self.tshark_fields = self._generate_tshark_fields(
            self.TSHARK_FIELDS_LIST)
        self.tshark_path = self._sniffer_server.run('which tshark').stdout
Exemplo n.º 8
0
    def __init__(self, uicd_zip, workflow_paths, log_path=None):
        """Creates a UicdCli object. Extracts the required uicd-cli binaries.

        Args:
            uicd_zip: The path to uicd_cli.tar.gz
            workflow_paths: List of paths to uicd workflows and/or directories
                containing them.
            log_path: Directory for storing logs generated by Uicd.
        """
        # This is done so unit tests can cache the mocked shutil.rmtree value
        # and call it on __del__ when the patch has been lifted.
        self._rm_tmpdir = shutil.rmtree

        self._uicd_zip = uicd_zip[0] if isinstance(uicd_zip, list) else uicd_zip
        self._uicd_path = tempfile.mkdtemp(prefix='uicd')
        self._log_path = log_path
        if self._log_path:
            os.makedirs(self._log_path, exist_ok=True)
        self._log = logger.create_tagged_trace_logger(tag='Uicd')
        self._set_workflows(workflow_paths)
        self._setup_cli()
Exemplo n.º 9
0
    def __init__(self, ip_addr, ip_port):
        """Init method for Socket Instrument.

        Args:
            ip_addr: IP Address.
                Type, str.
            ip_port: TCPIP Port.
                Type, str.
        """
        self._socket_timeout = 120
        self._socket_buffer_size = 1024

        self._ip_addr = ip_addr
        self._ip_port = ip_port

        self._escseq = '\n'
        self._codefmt = 'utf-8'

        self._logger = logger.create_tagged_trace_logger(
            '%s:%s' % (self._ip_addr, self._ip_port))

        self._socket = None
Exemplo n.º 10
0
 def __init__(self, config):
     self.config = config.copy()
     self.device_id = self.config['device_id']
     self.log = logger.create_tagged_trace_logger('pdu_ps1158[{}]'.format(
         self.device_id))
Exemplo n.º 11
0
 def __init__(self, addr, tc, client_id):
     self.address = addr
     self.test_counter = tc
     self.client_id = client_id
     self.log = logger.create_tagged_trace_logger(str(addr))
 def __init__(self, config):
     self.log = logger.create_tagged_trace_logger('Mock Sniffer')
Exemplo n.º 13
0
 def __init__(self):
     """ Initializes the cellular simulator. """
     self.log = logger.create_tagged_trace_logger('CellularSimulator')
Exemplo n.º 14
0
 def __init__(self, config):
     self.config = config.copy()
     self.device_id = self.config['device_id']
     self.log = logger.create_tagged_trace_logger('OtaChamber|{}'.format(
         self.device_id))
     self.current_mode = None
    def __init__(self, fd_conf_data):
        """
        Args:
            fd_conf_data: A dict of a fuchsia device configuration data
                Required keys:
                    ip: IP address of fuchsia device
                optional key:
                    port: Port for the sl4f web server on the fuchsia device
                        (Default: 80)
                    ssh_config: Location of the ssh_config file to connect to
                        the fuchsia device
                        (Default: None)
        """
        self.conf_data = fd_conf_data
        if "ip" not in fd_conf_data:
            raise FuchsiaDeviceError(FUCHSIA_DEVICE_NO_IP_MSG)
        self.ip = fd_conf_data["ip"]
        self.port = fd_conf_data.get("port", 80)
        self.ssh_config = fd_conf_data.get("ssh_config", None)
        self.ssh_username = fd_conf_data.get("ssh_username",
                                             FUCHSIA_SSH_USERNAME)
        self.hard_reboot_on_fail = fd_conf_data.get("hard_reboot_on_fail",
                                                    False)
        self.device_pdu_config = fd_conf_data.get("PduDevice", None)
        self._persistent_ssh_conn = None

        self.log = acts_logger.create_tagged_trace_logger(
            "FuchsiaDevice | %s" % self.ip)

        if utils.is_valid_ipv4_address(self.ip):
            self.address = "http://{}:{}".format(self.ip, self.port)
        elif utils.is_valid_ipv6_address(self.ip):
            self.address = "http://[{}]:{}".format(self.ip, self.port)
        else:
            raise ValueError('Invalid IP: %s' % self.ip)

        self.init_address = self.address + "/init"
        self.cleanup_address = self.address + "/cleanup"
        self.print_address = self.address + "/print_clients"
        self.ping_rtt_match = re.compile(r'RTT Min/Max/Avg '
                                         r'= \[ (.*?) / (.*?) / (.*?) \] ms')

        # TODO(): Come up with better client numbering system
        self.client_id = "FuchsiaClient" + str(random.randint(0, 1000000))
        self.test_counter = 0
        self.serial = re.sub('[.:%]', '_', self.ip)
        log_path_base = getattr(logging, 'log_path', '/tmp/logs')
        self.log_path = os.path.join(log_path_base,
                                     'FuchsiaDevice%s' % self.serial)
        self.fuchsia_log_file_path = os.path.join(
            self.log_path, "fuchsialog_%s_debug.txt" % self.serial)
        self.log_process = None

        # Grab commands from FuchsiaAvdtpLib
        self.avdtp_lib = FuchsiaAvdtpLib(self.address, self.test_counter,
                                         self.client_id)

        # Grab commands from FuchsiaLightLib
        self.light_lib = FuchsiaLightLib(self.address, self.test_counter,
                                         self.client_id)

        # Grab commands from FuchsiaBacklightLib
        self.backlight_lib = FuchsiaBacklightLib(self.address,
                                                 self.test_counter,
                                                 self.client_id)

        # Grab commands from FuchsiaBleLib
        self.ble_lib = FuchsiaBleLib(self.address, self.test_counter,
                                     self.client_id)
        # Grab commands from FuchsiaBtcLib
        self.btc_lib = FuchsiaBtcLib(self.address, self.test_counter,
                                     self.client_id)
        # Grab commands from FuchsiaGattcLib
        self.gattc_lib = FuchsiaGattcLib(self.address, self.test_counter,
                                         self.client_id)
        # Grab commands from FuchsiaGattsLib
        self.gatts_lib = FuchsiaGattsLib(self.address, self.test_counter,
                                         self.client_id)

        # Grab commands from FuchsiaGpioLib
        self.gpio_lib = FuchsiaGpioLib(self.address, self.test_counter,
                                       self.client_id)

        # Grab commands from FuchsiaHardwarePowerStatecontrolLib
        self.hardware_power_statecontrol_lib = FuchsiaHardwarePowerStatecontrolLib(
            self.address, self.test_counter, self.client_id)

        # Grab commands from FuchsiaHwinfoLib
        self.hwinfo_lib = FuchsiaHwinfoLib(self.address, self.test_counter,
                                           self.client_id)

        # Grab commands from FuchsiaI2cLib
        self.i2c_lib = FuchsiaI2cLib(self.address, self.test_counter,
                                     self.client_id)

        # Grab commands from FuchsiaInputReportLib
        self.input_report_lib = FuchsiaInputReportLib(self.address,
                                                      self.test_counter,
                                                      self.client_id)

        # Grab commands from FuchsiaKernelLib
        self.kernel_lib = FuchsiaKernelLib(self.address, self.test_counter,
                                           self.client_id)

        # Grab commands from FuchsiaLoggingLib
        self.logging_lib = FuchsiaLoggingLib(self.address, self.test_counter,
                                             self.client_id)

        # Grab commands from FuchsiaNetstackLib
        self.netstack_lib = FuchsiaNetstackLib(self.address, self.test_counter,
                                               self.client_id)

        # Grab commands from FuchsiaProfileServerLib
        self.sdp_lib = FuchsiaProfileServerLib(self.address, self.test_counter,
                                               self.client_id)

        # Grab commands from FuchsiaRegulatoryRegionLib
        self.regulatory_region_lib = FuchsiaRegulatoryRegionLib(
            self.address, self.test_counter, self.client_id)

        # Grab commands from FuchsiaSysInfoLib
        self.sysinfo_lib = FuchsiaSysInfoLib(self.address, self.test_counter,
                                             self.client_id)

        # Grabs command from FuchsiaWlanDeprecatedConfigurationLib
        self.wlan_deprecated_configuration_lib = FuchsiaWlanDeprecatedConfigurationLib(
            self.address, self.test_counter, self.client_id)

        # Grab commands from FuchsiaWlanLib
        self.wlan_lib = FuchsiaWlanLib(self.address, self.test_counter,
                                       self.client_id)

        # Grab commands from FuchsiaWlanApPolicyLib
        self.wlan_ap_policy_lib = FuchsiaWlanApPolicyLib(
            self.address, self.test_counter, self.client_id)

        # Grab commands from FuchsiaWlanPolicyLib
        self.wlan_policy_lib = FuchsiaWlanPolicyLib(self.address,
                                                    self.test_counter,
                                                    self.client_id)

        self.skip_sl4f = False
        # Start sl4f on device
        self.start_services(skip_sl4f=self.skip_sl4f)
        # Init server
        self.init_server_connection()