コード例 #1
0
ファイル: sync_client.py プロジェクト: zyclove/freeline
    def check_device_connection(self):
        commands = [self._adb, 'devices']
        output, err, code = cexec(commands, callback=None)
        if code == 0:
            devices = output.strip().split('\n')
            length = len(devices)
            from exceptions import UsbConnectionException
            if length < 2:
                self.debug('No device\'s connection found')
                raise UsbConnectionException(
                    'No device\'s connection found',
                    '\tUse `adb devices` to check your device connection')
            if length > 2:
                self.debug('More than 1 devices connect:')
                self.debug(devices)
                raise UsbConnectionException(
                    'More than 1 devices connect', '\tOnly 1 device allowed, '
                    'use `adb devices` to check your devices\' connection')

            for content in devices:
                if content.find('offline') <> -1:
                    raise UsbConnectionException(
                        'Device is connected but offline',
                        '\tPlease replug in device')

                if content.find('unauthorized') <> -1:
                    raise UsbConnectionException(
                        'Device is connected but unauthorized',
                        '\tReplug in device and accept authorization as usual')

                if not (content.find('device') > -1):
                    raise UsbConnectionException(
                        'Device is connected but unknown status',
                        '\tPlease replug in device')
コード例 #2
0
ファイル: android_tools.py プロジェクト: msdx/freeline
 def _check_connection(self):
     self.debug('check device\' connection...')
     commands = [self._adb, 'devices']
     output, err, code = cexec(commands, callback=None)
     if code == 0:
         length = len(output.strip().split('\n'))
         from exceptions import UsbConnectionException
         if length < 2:
             raise UsbConnectionException('No device\'s connection found',
                                          '\tUse `adb devices` to check your device connection')
         if length > 2:
             raise UsbConnectionException('More than 1 device connect',
                                          '\tOnly 1 device allowed, '
                                          'use `adb devices` to check your devices\' connection')