From 753e3314f62ce3415517c8625521c0e49a009670 Mon Sep 17 00:00:00 2001 From: r0xen Date: Fri, 12 Nov 2021 13:40:56 +0100 Subject: [PATCH 01/16] Update __init__.py ppadb.command.transport: Transport.shell() misses return, when a custom handler is supplied it's never used because of a missing return making the feature useless. --- ppadb/command/transport/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ppadb/command/transport/__init__.py b/ppadb/command/transport/__init__.py index 1adadf6..aeef77b 100644 --- a/ppadb/command/transport/__init__.py +++ b/ppadb/command/transport/__init__.py @@ -23,7 +23,7 @@ def shell(self, cmd, handler=None, timeout=None): conn.send(cmd) if handler: - handler(conn) + return handler(conn) else: result = conn.read_all() conn.close() From d731fd2dbe4004cc8c6f6644e77d55f1bbdb903b Mon Sep 17 00:00:00 2001 From: Ahmet Bilal Can Date: Thu, 10 Feb 2022 11:44:05 +0300 Subject: [PATCH 02/16] call disable-user while uninstalling if app is device-admin --- ppadb/device.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ppadb/device.py b/ppadb/device.py index dd08ec4..43fd29c 100644 --- a/ppadb/device.py +++ b/ppadb/device.py @@ -135,6 +135,10 @@ def uninstall(self, package): return True elif m: logger.error(m.group(1)) + if "DELETE_FAILED_DEVICE_POLICY_MANAGER" in m.group(1): + logger.info('App is device-admin, calling disable-user') + self.shell('pm disable-user {}'.format(package)) + return self.uninstall(package) return False else: logger.error("There is no message after uninstalling") From 9675c4471ec9680ae5287b9555dba3e808223e34 Mon Sep 17 00:00:00 2001 From: mib1185 Date: Tue, 2 Apr 2024 01:55:17 +0200 Subject: [PATCH 03/16] mark pattern variables raw strings --- ppadb/command/host/__init__.py | 2 +- ppadb/command/host_async/__init__.py | 2 +- ppadb/command/transport/__init__.py | 8 ++++---- ppadb/device.py | 4 ++-- ppadb/device_async.py | 4 ++-- ppadb/plugins/device/cpustat.py | 2 +- ppadb/plugins/device/traffic.py | 2 +- ppadb/plugins/device/utils.py | 6 +++--- 8 files changed, 15 insertions(+), 15 deletions(-) diff --git a/ppadb/command/host/__init__.py b/ppadb/command/host/__init__.py index 6711a53..ef0a3a2 100644 --- a/ppadb/command/host/__init__.py +++ b/ppadb/command/host/__init__.py @@ -3,7 +3,7 @@ class Host(Command): - CONNECT_RESULT_PATTERN = "(connected to|already connected)" + CONNECT_RESULT_PATTERN = r"(connected to|already connected)" OFFLINE = "offline" DEVICE = "device" diff --git a/ppadb/command/host_async/__init__.py b/ppadb/command/host_async/__init__.py index f32e011..e80a466 100644 --- a/ppadb/command/host_async/__init__.py +++ b/ppadb/command/host_async/__init__.py @@ -2,7 +2,7 @@ class HostAsync: - CONNECT_RESULT_PATTERN = "(connected to|already connected)" + CONNECT_RESULT_PATTERN = r"(connected to|already connected)" OFFLINE = "offline" DEVICE = "device" diff --git a/ppadb/command/transport/__init__.py b/ppadb/command/transport/__init__.py index 1adadf6..5586180 100644 --- a/ppadb/command/transport/__init__.py +++ b/ppadb/command/transport/__init__.py @@ -51,7 +51,7 @@ def screencap(self): return result def clear(self, package): - clear_result_pattern = "(Success|Failed)" + clear_result_pattern = r"(Success|Failed)" result = self.shell("pm clear {}".format(package)) m = re.search(clear_result_pattern, result) @@ -68,7 +68,7 @@ def framebuffer(self): def list_features(self): result = self.shell("pm list features 2>/dev/null") - result_pattern = "^feature:(.*?)(?:=(.*?))?\r?$" + result_pattern = r"^feature:(.*?)(?:=(.*?))?\r?$" features = {} for line in result.split('\n'): m = re.match(result_pattern, line) @@ -80,7 +80,7 @@ def list_features(self): def list_packages(self): result = self.shell("pm list packages 2>/dev/null") - result_pattern = "^package:(.*?)\r?$" + result_pattern = r"^package:(.*?)\r?$" packages = [] for line in result.split('\n'): @@ -92,7 +92,7 @@ def list_packages(self): def get_properties(self): result = self.shell("getprop") - result_pattern = "^\[([\s\S]*?)\]: \[([\s\S]*?)\]\r?$" + result_pattern = r"^\[([\s\S]*?)\]: \[([\s\S]*?)\]\r?$" properties = {} for line in result.split('\n'): diff --git a/ppadb/device.py b/ppadb/device.py index dd08ec4..79ec848 100644 --- a/ppadb/device.py +++ b/ppadb/device.py @@ -31,8 +31,8 @@ class Device(Transport, Serial, Input, Utils, WM, Traffic, CPUStat, BatteryStats): - INSTALL_RESULT_PATTERN = "(Success|Failure|Error)\s?(.*)" - UNINSTALL_RESULT_PATTERN = "(Success|Failure.*|.*Unknown package:.*)" + INSTALL_RESULT_PATTERN = r"(Success|Failure|Error)\s?(.*)" + UNINSTALL_RESULT_PATTERN = r"(Success|Failure.*|.*Unknown package:.*)" def __init__(self, client, serial): self.client = client diff --git a/ppadb/device_async.py b/ppadb/device_async.py index 5e4a8b0..59cb3b0 100644 --- a/ppadb/device_async.py +++ b/ppadb/device_async.py @@ -21,8 +21,8 @@ def _get_src_info(src): class DeviceAsync(TransportAsync): - INSTALL_RESULT_PATTERN = "(Success|Failure|Error)\s?(.*)" - UNINSTALL_RESULT_PATTERN = "(Success|Failure.*|.*Unknown package:.*)" + INSTALL_RESULT_PATTERN = r"(Success|Failure|Error)\s?(.*)" + UNINSTALL_RESULT_PATTERN = r"(Success|Failure.*|.*Unknown package:.*)" def __init__(self, client, serial): self.client = client diff --git a/ppadb/plugins/device/cpustat.py b/ppadb/plugins/device/cpustat.py index 1175f3d..9dd38e1 100644 --- a/ppadb/plugins/device/cpustat.py +++ b/ppadb/plugins/device/cpustat.py @@ -87,7 +87,7 @@ def total(self): class CPUStat(Plugin): total_cpu_pattern = re.compile( - "cpu\s+([\d]+)\s([\d]+)\s([\d]+)\s([\d]+)\s([\d]+)\s([\d]+)\s([\d]+)\s([\d]+)\s([\d]+)\s([\d]+)\s") + r"cpu\s+([\d]+)\s([\d]+)\s([\d]+)\s([\d]+)\s([\d]+)\s([\d]+)\s([\d]+)\s([\d]+)\s([\d]+)\s([\d]+)\s") def cpu_times(self): return self.get_total_cpu() diff --git a/ppadb/plugins/device/traffic.py b/ppadb/plugins/device/traffic.py index 0e1a66a..e44fbe9 100644 --- a/ppadb/plugins/device/traffic.py +++ b/ppadb/plugins/device/traffic.py @@ -33,7 +33,7 @@ def get_traffic(self, package_name): cmd = 'dumpsys package {} | grep userId'.format(package_name) result = self.shell(cmd).strip() - pattern = "userId=([\d]+)" + pattern = r"userId=([\d]+)" if result: match = re.search(pattern, result) diff --git a/ppadb/plugins/device/utils.py b/ppadb/plugins/device/utils.py index 225674d..be836ea 100644 --- a/ppadb/plugins/device/utils.py +++ b/ppadb/plugins/device/utils.py @@ -32,7 +32,7 @@ def get_top_activity(self): return None def get_top_activities(self): - pattern = "ACTIVITY\s([\w\.]+)/([\w\.]+)\s[\w\d]+\spid=([\d]+)" + pattern = r"ACTIVITY\s([\w\.]+)/([\w\.]+)\s[\w\d]+\spid=([\d]+)" cmd = "dumpsys activity top | grep ACTIVITY" result = self.shell(cmd) @@ -82,7 +82,7 @@ def get_uid(self, package_name): cmd = 'dumpsys package {} | grep userId'.format(package_name) result = self.shell(cmd).strip() - pattern = "userId=([\d]+)" + pattern = r"userId=([\d]+)" if result: match = re.search(pattern, result) @@ -99,7 +99,7 @@ def get_package_version_name(self, package_name): cmd = 'dumpsys package {} | grep versionName'.format(package_name) result = self.shell(cmd).strip() - pattern = "versionName=([\d\.]+)" + pattern = r"versionName=([\d\.]+)" if result: match = re.search(pattern, result) From b85afe786ea93b510ac2e8e162987aff3c63f063 Mon Sep 17 00:00:00 2001 From: mib1185 Date: Tue, 2 Apr 2024 02:40:13 +0200 Subject: [PATCH 04/16] mark more pattern variables raw strings --- ppadb/plugins/device/utils.py | 14 +++++++------- ppadb/plugins/device/wm.py | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/ppadb/plugins/device/utils.py b/ppadb/plugins/device/utils.py index be836ea..99872ee 100644 --- a/ppadb/plugins/device/utils.py +++ b/ppadb/plugins/device/utils.py @@ -45,13 +45,13 @@ def get_top_activities(self): return activities def get_meminfo(self, package_name): - total_meminfo_re = re.compile('\s*TOTAL\s*(?P\d+)' - '\s*(?P\d+)' - '\s*(?P\d+)' - '\s*(?P\d+)' - '\s*(?P\d+)' - '\s*(?P\d+)' - '\s*(?P\d+)') + total_meminfo_re = re.compile(r'\s*TOTAL\s*(?P\d+)' + r'\s*(?P\d+)' + r'\s*(?P\d+)' + r'\s*(?P\d+)' + r'\s*(?P\d+)' + r'\s*(?P\d+)' + r'\s*(?P\d+)') cmd = 'dumpsys meminfo {}'.format(package_name) result = self.shell(cmd) diff --git a/ppadb/plugins/device/wm.py b/ppadb/plugins/device/wm.py index 7a3c520..6d88823 100644 --- a/ppadb/plugins/device/wm.py +++ b/ppadb/plugins/device/wm.py @@ -9,7 +9,7 @@ ]) class WM(Plugin): - SIZE_RE = 'Physical size:\s([\d]+)x([\d]+)' + SIZE_RE = r'Physical size:\s([\d]+)x([\d]+)' def wm_size(self): result = self.shell("wm size") match = re.search(self.SIZE_RE, result) From 2710257b1a88b28ef0a1bba0d97e1609adcb2c6b Mon Sep 17 00:00:00 2001 From: Emmanuel Arias Date: Wed, 18 Dec 2024 16:14:21 -0300 Subject: [PATCH 05/16] Fix SyntaxWarning Fix SyntaxWarning during build --- ppadb/command/transport/__init__.py | 2 +- ppadb/device.py | 2 +- ppadb/device_async.py | 2 +- ppadb/plugins/device/cpustat.py | 2 +- ppadb/plugins/device/traffic.py | 2 +- ppadb/plugins/device/utils.py | 20 ++++++++++---------- ppadb/plugins/device/wm.py | 2 +- 7 files changed, 16 insertions(+), 16 deletions(-) diff --git a/ppadb/command/transport/__init__.py b/ppadb/command/transport/__init__.py index 1adadf6..768094a 100644 --- a/ppadb/command/transport/__init__.py +++ b/ppadb/command/transport/__init__.py @@ -92,7 +92,7 @@ def list_packages(self): def get_properties(self): result = self.shell("getprop") - result_pattern = "^\[([\s\S]*?)\]: \[([\s\S]*?)\]\r?$" + result_pattern = r"^\[([\s\S]*?)\]: \[([\s\S]*?)\]\r?$" properties = {} for line in result.split('\n'): diff --git a/ppadb/device.py b/ppadb/device.py index dd08ec4..8742978 100644 --- a/ppadb/device.py +++ b/ppadb/device.py @@ -31,7 +31,7 @@ class Device(Transport, Serial, Input, Utils, WM, Traffic, CPUStat, BatteryStats): - INSTALL_RESULT_PATTERN = "(Success|Failure|Error)\s?(.*)" + INSTALL_RESULT_PATTERN = r(Success|Failure|Error)\s?(.*)" UNINSTALL_RESULT_PATTERN = "(Success|Failure.*|.*Unknown package:.*)" def __init__(self, client, serial): diff --git a/ppadb/device_async.py b/ppadb/device_async.py index 5e4a8b0..abcae88 100644 --- a/ppadb/device_async.py +++ b/ppadb/device_async.py @@ -21,7 +21,7 @@ def _get_src_info(src): class DeviceAsync(TransportAsync): - INSTALL_RESULT_PATTERN = "(Success|Failure|Error)\s?(.*)" + INSTALL_RESULT_PATTERN = r"(Success|Failure|Error)\s?(.*)" UNINSTALL_RESULT_PATTERN = "(Success|Failure.*|.*Unknown package:.*)" def __init__(self, client, serial): diff --git a/ppadb/plugins/device/cpustat.py b/ppadb/plugins/device/cpustat.py index 1175f3d..9dd38e1 100644 --- a/ppadb/plugins/device/cpustat.py +++ b/ppadb/plugins/device/cpustat.py @@ -87,7 +87,7 @@ def total(self): class CPUStat(Plugin): total_cpu_pattern = re.compile( - "cpu\s+([\d]+)\s([\d]+)\s([\d]+)\s([\d]+)\s([\d]+)\s([\d]+)\s([\d]+)\s([\d]+)\s([\d]+)\s([\d]+)\s") + r"cpu\s+([\d]+)\s([\d]+)\s([\d]+)\s([\d]+)\s([\d]+)\s([\d]+)\s([\d]+)\s([\d]+)\s([\d]+)\s([\d]+)\s") def cpu_times(self): return self.get_total_cpu() diff --git a/ppadb/plugins/device/traffic.py b/ppadb/plugins/device/traffic.py index 0e1a66a..e44fbe9 100644 --- a/ppadb/plugins/device/traffic.py +++ b/ppadb/plugins/device/traffic.py @@ -33,7 +33,7 @@ def get_traffic(self, package_name): cmd = 'dumpsys package {} | grep userId'.format(package_name) result = self.shell(cmd).strip() - pattern = "userId=([\d]+)" + pattern = r"userId=([\d]+)" if result: match = re.search(pattern, result) diff --git a/ppadb/plugins/device/utils.py b/ppadb/plugins/device/utils.py index 225674d..99872ee 100644 --- a/ppadb/plugins/device/utils.py +++ b/ppadb/plugins/device/utils.py @@ -32,7 +32,7 @@ def get_top_activity(self): return None def get_top_activities(self): - pattern = "ACTIVITY\s([\w\.]+)/([\w\.]+)\s[\w\d]+\spid=([\d]+)" + pattern = r"ACTIVITY\s([\w\.]+)/([\w\.]+)\s[\w\d]+\spid=([\d]+)" cmd = "dumpsys activity top | grep ACTIVITY" result = self.shell(cmd) @@ -45,13 +45,13 @@ def get_top_activities(self): return activities def get_meminfo(self, package_name): - total_meminfo_re = re.compile('\s*TOTAL\s*(?P\d+)' - '\s*(?P\d+)' - '\s*(?P\d+)' - '\s*(?P\d+)' - '\s*(?P\d+)' - '\s*(?P\d+)' - '\s*(?P\d+)') + total_meminfo_re = re.compile(r'\s*TOTAL\s*(?P\d+)' + r'\s*(?P\d+)' + r'\s*(?P\d+)' + r'\s*(?P\d+)' + r'\s*(?P\d+)' + r'\s*(?P\d+)' + r'\s*(?P\d+)') cmd = 'dumpsys meminfo {}'.format(package_name) result = self.shell(cmd) @@ -82,7 +82,7 @@ def get_uid(self, package_name): cmd = 'dumpsys package {} | grep userId'.format(package_name) result = self.shell(cmd).strip() - pattern = "userId=([\d]+)" + pattern = r"userId=([\d]+)" if result: match = re.search(pattern, result) @@ -99,7 +99,7 @@ def get_package_version_name(self, package_name): cmd = 'dumpsys package {} | grep versionName'.format(package_name) result = self.shell(cmd).strip() - pattern = "versionName=([\d\.]+)" + pattern = r"versionName=([\d\.]+)" if result: match = re.search(pattern, result) diff --git a/ppadb/plugins/device/wm.py b/ppadb/plugins/device/wm.py index 7a3c520..6d88823 100644 --- a/ppadb/plugins/device/wm.py +++ b/ppadb/plugins/device/wm.py @@ -9,7 +9,7 @@ ]) class WM(Plugin): - SIZE_RE = 'Physical size:\s([\d]+)x([\d]+)' + SIZE_RE = r'Physical size:\s([\d]+)x([\d]+)' def wm_size(self): result = self.shell("wm size") match = re.search(self.SIZE_RE, result) From 6693e67ff878a93edfda894b2a10ebfa42bb1000 Mon Sep 17 00:00:00 2001 From: Emmanuel Arias Date: Wed, 18 Dec 2024 16:19:47 -0300 Subject: [PATCH 06/16] fix openning quote --- ppadb/device.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ppadb/device.py b/ppadb/device.py index 8742978..ffcb32b 100644 --- a/ppadb/device.py +++ b/ppadb/device.py @@ -31,7 +31,7 @@ class Device(Transport, Serial, Input, Utils, WM, Traffic, CPUStat, BatteryStats): - INSTALL_RESULT_PATTERN = r(Success|Failure|Error)\s?(.*)" + INSTALL_RESULT_PATTERN = r"(Success|Failure|Error)\s?(.*)" UNINSTALL_RESULT_PATTERN = "(Success|Failure.*|.*Unknown package:.*)" def __init__(self, client, serial): From a13c5d94cd64d980807905f0cf9ad3b536ccfb19 Mon Sep 17 00:00:00 2001 From: Daniel O'Connor Date: Sun, 9 Feb 2025 01:14:11 +0000 Subject: [PATCH 07/16] Manually add https://github.com/Swind/pure-python-adb/pull/85 --- MANIFEST.in | 1 + 1 file changed, 1 insertion(+) diff --git a/MANIFEST.in b/MANIFEST.in index 9ef07db..a51ec2c 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,3 +1,4 @@ recursive-exclude test * include README.rst include HISTORY.rst +include LICENSE \ No newline at end of file From b042d1bf121f36797aaa717aca740024fa86f137 Mon Sep 17 00:00:00 2001 From: Daniel O'Connor Date: Sun, 9 Feb 2025 01:36:09 +0000 Subject: [PATCH 08/16] Run black --- example/screencap.py | 2 -- ppadb/device.py | 4 ++-- ppadb/plugins/device/utils.py | 14 ++++++------ scripts/batterystats_codegen.py | 39 +++++++++++++++++++++------------ setup.py | 26 +++++++++++----------- 5 files changed, 47 insertions(+), 38 deletions(-) diff --git a/example/screencap.py b/example/screencap.py index e8f62a8..9d4e54f 100644 --- a/example/screencap.py +++ b/example/screencap.py @@ -4,5 +4,3 @@ device = client.device("emulator-5554") device.push("./screencap.py", "/sdcard/screencap.py") - - diff --git a/ppadb/device.py b/ppadb/device.py index 354e036..2491cdb 100644 --- a/ppadb/device.py +++ b/ppadb/device.py @@ -148,8 +148,8 @@ def uninstall(self, package): elif m: logger.error(m.group(1)) if "DELETE_FAILED_DEVICE_POLICY_MANAGER" in m.group(1): - logger.info('App is device-admin, calling disable-user') - self.shell('pm disable-user {}'.format(package)) + logger.info("App is device-admin, calling disable-user") + self.shell("pm disable-user {}".format(package)) return self.uninstall(package) return False else: diff --git a/ppadb/plugins/device/utils.py b/ppadb/plugins/device/utils.py index 219427a..06ef5fd 100644 --- a/ppadb/plugins/device/utils.py +++ b/ppadb/plugins/device/utils.py @@ -57,13 +57,13 @@ def get_top_activities(self): def get_meminfo(self, package_name): total_meminfo_re = re.compile( - r'\s*TOTAL\s*(?P\d+)' - r'\s*(?P\d+)' - r'\s*(?P\d+)' - r'\s*(?P\d+)' - r'\s*(?P\d+)' - r'\s*(?P\d+)' - r'\s*(?P\d+)' + r"\s*TOTAL\s*(?P\d+)" + r"\s*(?P\d+)" + r"\s*(?P\d+)" + r"\s*(?P\d+)" + r"\s*(?P\d+)" + r"\s*(?P\d+)" + r"\s*(?P\d+)" ) cmd = "dumpsys meminfo {}".format(package_name) diff --git a/scripts/batterystats_codegen.py b/scripts/batterystats_codegen.py index de276af..aefbee7 100644 --- a/scripts/batterystats_codegen.py +++ b/scripts/batterystats_codegen.py @@ -61,6 +61,7 @@ def get_section(name): return mapping.get(name) """ + class BatteryStatsSection: def __init__(self, id, description, fields): self.id = id @@ -70,13 +71,15 @@ def __init__(self, id, description, fields): @staticmethod def Load(raw): sections = [] - for line in raw.split('\n'): + for line in raw.split("\n"): if not line: continue id, description, raw_fields = line.split(",", 2) if raw_fields.strip().startswith('"'): - remaining_fields = list(map(lambda item: item.strip(), raw_fields[1:-1].split(","))) + remaining_fields = list( + map(lambda item: item.strip(), raw_fields[1:-1].split(",")) + ) else: remaining_fields = [raw_fields.strip()] @@ -86,13 +89,16 @@ def Load(raw): def convert_to_var_name(field): - return field.replace(" ", "_")\ - .replace("-", "_")\ - .replace("'", "")\ - .lower()\ - .replace("wi_fi", "wifi")\ - .replace("1x", "_1x")\ + return ( + field.replace(" ", "_") + .replace("-", "_") + .replace("'", "") + .lower() + .replace("wi_fi", "wifi") + .replace("1x", "_1x") .replace("(mah)", "mah") + ) + def generate(): sections = BatteryStatsSection.Load(raw_batterystats_fields) @@ -100,13 +106,17 @@ def generate(): mapping = [] for section in sections: class_name = section.description.replace(" ", "").replace("-", "") - vars = list(map(lambda item: convert_to_var_name(item), section.remaining_fields)) - init_vars = list(map(lambda item: " self.{} = {}".format(item, item), vars)) + vars = list( + map(lambda item: convert_to_var_name(item), section.remaining_fields) + ) + init_vars = list( + map(lambda item: " self.{} = {}".format(item, item), vars) + ) code = CLASS_TEMPLATE.format( ID=section.id, CLASS_NAME=class_name, VARS=",".join(vars), - INIT_VARS="\n".join(init_vars) + INIT_VARS="\n".join(init_vars), ) code_blocks.append(code) mapping.append("'{}':{}".format(section.id, class_name)) @@ -115,13 +125,14 @@ def generate(): return "\n".join(code_blocks) + "\n" + mapping_code + "\n" + GET_SECTION + if __name__ == "__main__": import os codegen = generate() folder_path = os.path.dirname(__file__) - file_path = os.path.join(folder_path, "..", "ppadb", "plugins", "device", "batterystats_section.py") + file_path = os.path.join( + folder_path, "..", "ppadb", "plugins", "device", "batterystats_section.py" + ) with open(file_path, "w") as fp: fp.write(codegen) - - diff --git a/setup.py b/setup.py index 7cf8795..610847e 100644 --- a/setup.py +++ b/setup.py @@ -5,29 +5,29 @@ from setuptools import setup, find_packages -with open('README.rst') as readme_file: +with open("README.rst") as readme_file: readme = readme_file.read() -with open('HISTORY.rst') as history_file: +with open("HISTORY.rst") as history_file: history = history_file.read() classifiers = [ - 'Development Status :: 4 - Beta', - 'Intended Audience :: Developers', - 'License :: OSI Approved :: MIT License', - 'Programming Language :: Python :: 3', - 'Topic :: Software Development :: Testing', + "Development Status :: 4 - Beta", + "Intended Audience :: Developers", + "License :: OSI Approved :: MIT License", + "Programming Language :: Python :: 3", + "Topic :: Software Development :: Testing", ] setup( - name='pure-python-adb', + name="pure-python-adb", version="0.3.0-dev", - description='Pure python implementation of the adb client', - long_description=readme + '\n\n' + history, - author='Swind Ou', - author_email='swind@cloudmosa.com', + description="Pure python implementation of the adb client", + long_description=readme + "\n\n" + history, + author="Swind Ou", + author_email="swind@cloudmosa.com", url="https://github.com/Swind/pure-python-adb", - license='MIT license', + license="MIT license", packages=find_packages(exclude=["*.test", "*.test.*", "test.*", "test"]), install_requires=[], extras_require={"async": ["aiofiles>=0.4.0"]}, From e16246902ebee432f2f1d6493a3d6565ea02eec8 Mon Sep 17 00:00:00 2001 From: Daniel O'Connor Date: Sun, 9 Feb 2025 01:47:36 +0000 Subject: [PATCH 09/16] Fix https://github.com/Swind/pure-python-adb/issues/94 ; Apply a version of d573b301a5fb9d1806122128fd968f2c7afd2077 --- ppadb/device.py | 4 ++-- ppadb/device_async.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ppadb/device.py b/ppadb/device.py index 2491cdb..002d8ce 100644 --- a/ppadb/device.py +++ b/ppadb/device.py @@ -91,7 +91,7 @@ def install( shared_mass_storage=False, # -s internal_system_memory=False, # -f downgrade=False, # -d - grand_all_permissions=False, # -g + grant_all_permissions=False, # -g ): dest = Sync.temp(path) self.push(path, dest) @@ -111,7 +111,7 @@ def install( parameters.append("-f") if downgrade: parameters.append("-d") - if grand_all_permissions: + if grant_all_permissions: parameters.append("-g") try: diff --git a/ppadb/device_async.py b/ppadb/device_async.py index 95271f9..b2165ce 100644 --- a/ppadb/device_async.py +++ b/ppadb/device_async.py @@ -81,7 +81,7 @@ async def install( shared_mass_storage=False, # -s internal_system_memory=False, # -f downgrade=False, # -d - grand_all_permissions=False, # -g + grant_all_permissions=False, # -g ): dest = SyncAsync.temp(path) @@ -105,7 +105,7 @@ async def install( parameters.append("-f") if downgrade: parameters.append("-d") - if grand_all_permissions: + if grant_all_permissions: parameters.append("-g") try: From 5bbf54c5ebeefa19100321224ed188eb79a98420 Mon Sep 17 00:00:00 2001 From: Daniel O'Connor Date: Sun, 9 Feb 2025 01:53:14 +0000 Subject: [PATCH 10/16] Add a workaround for https://github.com/Swind/pure-python-adb/issues/110 --- ppadb/command/transport_async/__init__.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ppadb/command/transport_async/__init__.py b/ppadb/command/transport_async/__init__.py index 9a0f347..ac6a66a 100644 --- a/ppadb/command/transport_async/__init__.py +++ b/ppadb/command/transport_async/__init__.py @@ -28,9 +28,13 @@ async def sync(self): return conn - async def screencap(self): + # Take a screenshot. Optionally, you can pass + # additional command line arguments, ie "2>/dev/null" + async def screencap(self, optional_args=None): async with await self.create_connection() as conn: cmd = "shell:/system/bin/screencap -p" + if optional_args is not None: + cmd = cmd + " " + optional_args await conn.send(cmd) result = await conn.read_all() From 6aa757a91d2669feca204da2ce83d5de7b6a3cf0 Mon Sep 17 00:00:00 2001 From: Daniel O'Connor Date: Sun, 9 Feb 2025 01:54:01 +0000 Subject: [PATCH 11/16] Add a workaround for https://github.com/Swind/pure-python-adb/issues/110 --- ppadb/command/transport/__init__.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ppadb/command/transport/__init__.py b/ppadb/command/transport/__init__.py index 41ac979..97bcaa1 100644 --- a/ppadb/command/transport/__init__.py +++ b/ppadb/command/transport/__init__.py @@ -37,11 +37,13 @@ def sync(self): return conn - def screencap(self): + def screencap(self, optional_args=None): conn = self.create_connection() with conn: cmd = "shell:/system/bin/screencap -p" + if optional_args is not None: + cmd = cmd + " " + optional_args conn.send(cmd) result = conn.read_all() From 61022fa8c7c77097e201893fabc2bd417b9609b0 Mon Sep 17 00:00:00 2001 From: Daniel O'Connor Date: Sun, 9 Feb 2025 02:02:47 +0000 Subject: [PATCH 12/16] Add history --- HISTORY.rst | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/HISTORY.rst b/HISTORY.rst index 927f9a3..6d6b348 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -1,3 +1,15 @@ +0.3.0 (Unreleased) +-------------------- + +* Fixes #111: Invalid escape sequence via @eamanu and @mib1185 +* Fixes #110: Add ability to pass extra arguments to `screencap` commands for waydroid via @CloCkWeRX +* Fixes #88: missing return in ppadb.command.transport: Transport.shell() for custom handler via @roxen +* Adds #85: Include LICENSE in pip package via @jan-janssen +* Adds #57: Recursive directory push for DeviceAsync class via @JeffLIrion +* Adds #89: Call disable-user if app is device-admin via @eybisi +* Change: Device#install and DeviceAsync#install changes param from `grand_all_permissions` to `grant_all_permissions` + + 0.2.1 (2019-10-14) -------------------- From 0eee352c52bfbc9ffd0c264c67fa8e0234843e36 Mon Sep 17 00:00:00 2001 From: Daniel O'Connor Date: Sun, 9 Feb 2025 02:04:28 +0000 Subject: [PATCH 13/16] Add history --- HISTORY.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/HISTORY.rst b/HISTORY.rst index 6d6b348..e1560d3 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -4,6 +4,7 @@ * Fixes #111: Invalid escape sequence via @eamanu and @mib1185 * Fixes #110: Add ability to pass extra arguments to `screencap` commands for waydroid via @CloCkWeRX * Fixes #88: missing return in ppadb.command.transport: Transport.shell() for custom handler via @roxen +* Fixes #60: Close socket if the connection fails via @JeffLIrion * Adds #85: Include LICENSE in pip package via @jan-janssen * Adds #57: Recursive directory push for DeviceAsync class via @JeffLIrion * Adds #89: Call disable-user if app is device-admin via @eybisi From 00be401c89eacbf52c95e8ce944cf3362a6963af Mon Sep 17 00:00:00 2001 From: Daniel O'Connor Date: Sun, 9 Feb 2025 02:10:01 +0000 Subject: [PATCH 14/16] Add history --- HISTORY.rst | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/HISTORY.rst b/HISTORY.rst index e1560d3..332173b 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -3,8 +3,12 @@ * Fixes #111: Invalid escape sequence via @eamanu and @mib1185 * Fixes #110: Add ability to pass extra arguments to `screencap` commands for waydroid via @CloCkWeRX -* Fixes #88: missing return in ppadb.command.transport: Transport.shell() for custom handler via @roxen +* Fixes #88: Missing return in ppadb.command.transport: Transport.shell() for custom handler via @roxen * Fixes #60: Close socket if the connection fails via @JeffLIrion +* Fixes #64: ADB reverse command via @Hamz-a +* Fixes incorrect timestamp type in asynchronous push via @slicen +* Adds #65: Added support to remove reverses via @Hamz-a +* Adds #67: asynchronous install and uninstall commands via @slicen * Adds #85: Include LICENSE in pip package via @jan-janssen * Adds #57: Recursive directory push for DeviceAsync class via @JeffLIrion * Adds #89: Call disable-user if app is device-admin via @eybisi From c7a225c7eb33f4282802cf44878b7096f7def105 Mon Sep 17 00:00:00 2001 From: Daniel O'Connor Date: Sun, 9 Feb 2025 02:12:45 +0000 Subject: [PATCH 15/16] Improve metadata --- HISTORY.rst | 2 +- setup.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index 332173b..d46945b 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -12,7 +12,7 @@ * Adds #85: Include LICENSE in pip package via @jan-janssen * Adds #57: Recursive directory push for DeviceAsync class via @JeffLIrion * Adds #89: Call disable-user if app is device-admin via @eybisi -* Change: Device#install and DeviceAsync#install changes param from `grand_all_permissions` to `grant_all_permissions` +* Change #94: Device#install and DeviceAsync#install changes param from `grand_all_permissions` to `grant_all_permissions` 0.2.1 (2019-10-14) diff --git a/setup.py b/setup.py index 610847e..f2cf73b 100644 --- a/setup.py +++ b/setup.py @@ -22,11 +22,11 @@ setup( name="pure-python-adb", version="0.3.0-dev", - description="Pure python implementation of the adb client", + description="Pure python implementation of the adb client, forked and maintained", long_description=readme + "\n\n" + history, - author="Swind Ou", - author_email="swind@cloudmosa.com", - url="https://github.com/Swind/pure-python-adb", + author="Sergio Martins", + author_email="", + url="https://github.com/spm5065/pure-python-adb", license="MIT license", packages=find_packages(exclude=["*.test", "*.test.*", "test.*", "test"]), install_requires=[], From 88552d3f094feca52ecfbbc591cabd06d2f5763d Mon Sep 17 00:00:00 2001 From: Daniel O'Connor Date: Sun, 9 Feb 2025 12:58:22 +1030 Subject: [PATCH 16/16] Update HISTORY.rst --- HISTORY.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/HISTORY.rst b/HISTORY.rst index d46945b..aa5a4f9 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -6,7 +6,7 @@ * Fixes #88: Missing return in ppadb.command.transport: Transport.shell() for custom handler via @roxen * Fixes #60: Close socket if the connection fails via @JeffLIrion * Fixes #64: ADB reverse command via @Hamz-a -* Fixes incorrect timestamp type in asynchronous push via @slicen +* Fixes #92: incorrect timestamp type in asynchronous push via @slicen and @GeekDuanLian * Adds #65: Added support to remove reverses via @Hamz-a * Adds #67: asynchronous install and uninstall commands via @slicen * Adds #85: Include LICENSE in pip package via @jan-janssen