Skip to content

Latest commit

 

History

History
96 lines (64 loc) · 2.16 KB

README_en.md

File metadata and controls

96 lines (64 loc) · 2.16 KB

pyatool

中文README

Maintainability PyPI version Downloads Documentation Status

python android toolkit 🔨

TL;DR

Directly call standard API.

from pyatool import PYAToolkit

# init
device = PYAToolkit('123456F')

# 1. call it directly
package_list = device.show_package()
# 2. or, call it via std
package_list = device.std.show_package(toolkit=device)

# return content depends on called function
print(package_list)

View all API we provided here.

And, some demo.

Install

support python3 only

pip install pyatool

Goal

Easy way to handle android devices with python

Need more functions?

If you want to execute adb shell pm list package to check your installed packages, you can:

# ALL you need
PYAToolkit.bind_cmd(func_name='show_package', cmd='shell pm list package')

# and you can use it
device_toolkit = PYAToolkit('123456F')
result = device_toolkit.show_package()

# it will do:
adb -s 123456F shell pm list package

Say goodbye to subprocess.Popen :)

If you need a complex function:

def download_and_install(url, toolkit=None):
    resp = requests.get(url)
    if not resp.ok:
        return False
    with tempfile.NamedTemporaryFile('wb+', suffix='.apk', delete=False) as temp:
        temp.write(resp.content)
        temp.close()
        toolkit.adb.run(['install', '-r', '-d', '-t', temp.name])
        os.remove(temp.name)
    return True


PYAToolkit.bind_func(real_func=download_and_install)

and then you can use it:

device_toolkit = PYAToolkit('123456F')
device_toolkit.download_and_install()

Suggestion or Contribution?

Welcome issue & PR :)

License

MIT