Coder Social home page Coder Social logo

shuixi2013 / pythonadb Goto Github PK

View Code? Open in Web Editor NEW

This project forked from claudiugeorgiu/pythonadb

0.0 0.0 0.0 171 KB

Android Debug Bridge (ADB) basic wrapper in Python, with timeout support in case of long operations

License: MIT License

Python 100.00%

pythonadb's Introduction

PythonADB

Android Debug Bridge (ADB) wrapper in Python.

Codacy Ubuntu Build Status Windows Build Status MacOS Build Status Code Coverage Python Version License

This project contains a basic Python wrapper of the command line adb (Android Debug Bridge) tool (by using the subprocess module in Python). Currently the main functions are supported (shell commands, file copy operations and app installations) but the wrapper is easily extensible with new features. All the implemented functions support an optional timeout value (tested on Ubuntu, Windows and MacOS) to let the command fail if it takes too long to finish execution (this can be useful during automatic testing).

❱ Prerequisites

This project is only a wrapper of ADB, so adb should be already installed and working. In order to test if you have a working adb installation, you can run the following command in a terminal:

$ adb version
Android Debug Bridge version 1.0.41
...

If adb is installed in a custom location, ADB_PATH environment variable can be used to specify the adb executable to be used by PythonADB (e.g., in Ubuntu, run export ADB_PATH=/custom/location/adb before running PythonADB in the same terminal).

❱ Usage

Apart from ADB, the only requirement of this project is a working Python 3 (at least 3.6) installation. The first thing to do is to get a local copy of this repository, so open up a terminal in the directory where you want to save the project and clone the repository:

$ git clone https://github.com/ClaudiuGeorgiu/PythonADB.git
$ cd PythonADB

Make sure to execute the following commands in the previously created PythonADB/ directory:

$ # The usage of a virtual environment is highly recommended, e.g., virtualenv.
$ # If not using virtualenv (https://virtualenv.pypa.io/), skip the next 2 lines.
$ virtualenv -p python3 venv
$ source venv/bin/activate

$ # Install PythonADB requirements.
$ python3 -m pip install -r requirements.txt

Usage example (see start.py file for a complete example):

from adb.adb import ADB

adb = ADB()
adb.get_version()
adb.wait_for_device()
adb.shell(["ls"])
# The following commands will fail if not completed in 30 seconds.
adb.install_app("/path/to/file.apk", timeout=30)
adb.pull_file("/path/on/device", "/path/on/host", timeout=30)
# ... more ...

See adb/adb.py file for a complete list with all the implemented adb commands.

❱ Contributing

Questions, bug reports and pull requests are welcome on GitHub at https://github.com/ClaudiuGeorgiu/PythonADB.

❱ License

You are free to use this code under the MIT License.

pythonadb's People

Contributors

claudiugeorgiu avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.