classAdb(object): """ Provides some adb methods """
@staticmethod defadb_devices(): """ Do adb devices :return The first connected device ID """ cmd = "adb devices" c_line = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()[0] if c_line.find("List of devices attached") < 0: # adb is not working returnNone return c_line.split("\t")[0].split("\r\n")[-1] # This line may have different format
@staticmethod defsome_adb_cmd(): p = subprocess.Popen('adb shell cd sdcard&&ls&&cd ../sys&&ls', stdout=subprocess.PIPE, stderr=subprocess.PIPE) return_code = p.poll() while return_code isNone: line = p.stdout.readline() return_code = p.poll() line = line.strip() if line: print line print"Done"