def connect(self):
        if not self._is_ready:
            if not self.adb_name:  # pylint: disable=E0203
                with open_serial_connection(timeout=self.timeout,
                                            port=self.port,
                                            baudrate=self.baudrate,
                                            init_dtr=0) as target:
                    target.sendline('')
                    self.logger.debug('Waiting for the Android prompt.')
                    target.expect(self.android_prompt)

                    self.logger.debug('Waiting for IP address...')
                    wait_start_time = time.time()
                    while True:
                        target.sendline('ip addr list eth0')
                        time.sleep(1)
                        try:
                            target.expect('inet ([1-9]\d*.\d+.\d+.\d+)',
                                          timeout=10)
                            self.adb_name = target.match.group(1) + ':5555'  # pylint: disable=W0201
                            break
                        except pexpect.TIMEOUT:
                            pass  # We have our own timeout -- see below.
                        if (time.time() -
                                wait_start_time) > self.ready_timeout:
                            raise DeviceError('Could not acquire IP address.')

            if self.adb_name in adb_list_devices():
                adb_disconnect(self.adb_name)
            adb_connect(self.adb_name, timeout=self.timeout)
            super(Juno, self).connect()  # wait for boot to complete etc.
            self._is_ready = True
Exemple #2
0
    def connect(self):
        if not self._is_ready:
            if self.config.adb_name:
                self.adb_name = self.config.adb_name  # pylint: disable=attribute-defined-outside-init
            else:
                with open_serial_connection(
                        timeout=self.config.serial_max_timeout,
                        port=self.config.serial_device,
                        baudrate=self.config.serial_baud) as target:
                    # Get IP address and push the Gator and PMU logger.
                    target.sendline(
                        'su'
                    )  # as of Android v5.0.2, Linux does not boot into root shell
                    target.sendline('netcfg')
                    ipaddr_re = re.compile('eth0 +UP +(.+)/.+', re.MULTILINE)
                    target.expect(ipaddr_re)
                    output = target.after
                    match = re.search('eth0 +UP +(.+)/.+', output)
                    if not match:
                        raise DeviceError('Could not get adb IP address.')
                    ipaddr = match.group(1)

                    # Connect to device using adb.
                    target.expect(self.android_prompt)  # pylint: disable=E1101
                    self.adb_name = ipaddr + ":5555"  # pylint: disable=W0201

            if self.adb_name in adb_list_devices():
                adb_disconnect(self.adb_name)
            adb_connect(self.adb_name)
            self._is_ready = True
            self.execute("input keyevent 82", timeout=ADB_SHELL_TIMEOUT)
            self.execute("svc power stayon true", timeout=ADB_SHELL_TIMEOUT)
    def connect(self):
        if not self._is_ready:
            if not self.adb_name:  # pylint: disable=E0203
                with open_serial_connection(timeout=self.timeout,
                                            port=self.port,
                                            baudrate=self.baudrate,
                                            init_dtr=0) as target:
                    target.sendline('')
                    self.logger.debug('Waiting for the Android prompt.')
                    target.expect(self.android_prompt)

                    self.logger.debug('Waiting for IP address...')
                    wait_start_time = time.time()
                    while True:
                        target.sendline('ip addr list eth0')
                        time.sleep(1)
                        try:
                            target.expect('inet ([1-9]\d*.\d+.\d+.\d+)', timeout=10)
                            self.adb_name = target.match.group(1) + ':5555'  # pylint: disable=W0201
                            break
                        except pexpect.TIMEOUT:
                            pass  # We have our own timeout -- see below.
                        if (time.time() - wait_start_time) > self.ready_timeout:
                            raise DeviceError('Could not acquire IP address.')

            if self.adb_name in adb_list_devices():
                adb_disconnect(self.adb_name)
            adb_connect(self.adb_name, timeout=self.timeout)
            super(Juno, self).connect()  # wait for boot to complete etc.
            self._is_ready = True
    def connect(self):
        if not self._is_ready:
            if self.config.adb_name:
                self.adb_name = self.config.adb_name  # pylint: disable=attribute-defined-outside-init
            else:
                with open_serial_connection(timeout=self.config.serial_max_timeout,
                                            port=self.config.serial_device,
                                            baudrate=self.config.serial_baud) as target:
                    # Get IP address and push the Gator and PMU logger.
                    target.sendline('su')  # as of Android v5.0.2, Linux does not boot into root shell
                    target.sendline('netcfg')
                    ipaddr_re = re.compile('eth0 +UP +(.+)/.+', re.MULTILINE)
                    target.expect(ipaddr_re)
                    output = target.after
                    match = re.search('eth0 +UP +(.+)/.+', output)
                    if not match:
                        raise DeviceError('Could not get adb IP address.')
                    ipaddr = match.group(1)

                    # Connect to device using adb.
                    target.expect(self.android_prompt)  # pylint: disable=E1101
                    self.adb_name = ipaddr + ":5555"  # pylint: disable=W0201

            if self.adb_name in adb_list_devices():
                adb_disconnect(self.adb_name)
            adb_connect(self.adb_name)
            self._is_ready = True
            self.execute("input keyevent 82", timeout=ADB_SHELL_TIMEOUT)
            self.execute("svc power stayon true", timeout=ADB_SHELL_TIMEOUT)