def getDeviceProps(serial): #global CONFIG CONFIG = copy.copy(CONFIG_BASIC) CONFIG['deviceid'] = serial product = AdbCommand('adb -s %s shell getprop ro.product.device' % serial, retry=2, timeout=5).run() CONFIG['product'] = product.strip() if product else 'unknown' revision = AdbCommand('adb -s %s shell getprop ro.build.version.incremental' % serial, retry=2, timeout=5).run() CONFIG['revision'] = revision.strip() if revision else 'unknown' screen_size = AdbCommand('adb -s %s shell dumpsys display' % serial, retry=2, timeout=5).run() if not screen_size: CONFIG['screen_width'] = 'unknown' CONFIG['screen_height'] = 'unknown' else: display = screen_size.strip().split('\n') for i in display: if i.find('mBaseDisplayInfo') != -1: _ = i.strip().split(',') for __ in _: if __.find('real') != -1: ___ = __.strip().split() ___.remove('real') ___.remove('x') CONFIG['screen_width'] , CONFIG['screen_height'] = ___ break return CONFIG
def getDevices(): devices = {} ret = AdbCommand('adb devices', retry=2, timeout=5).run() if ret.find('List of devices attached') == -1: raise Exception('adb error: %s' % ret) _ = [i.strip() for i in ret.strip().split('\n')] _.remove('List of devices attached') if not _: return devices devices = dict([i.strip().split('\t') for i in _]) return devices