Remove All Ads from XDA

[DEV][WiP][Python3] AndroPy - Library - It's like chatting with your phone!

580 posts
Thanks Meter: 307
Post Reply Email Thread
a python3 library to communicate with your phone


Hey there! In relation to THIS library written in JAVA I decided to write another library in Python3.
I try to reach the same functionality as that JAVA lib and maybe even more. "Why Python3?" you may ask..
Because it's the language I love the most, it's platform-independent and has got a beautiful syntax.
It's in early stage and there are only some functions working right now which I will explain in another block.


  • Install ADB-binary (only working on linux 64-bit for now)
  • Reboot (system, recovery, bootloader)
  • Execute shell commands and get output-lines as a list
  • Get list of connected devices
  • Get build.prop as a dictionary


I included a function called example wich will be automatically executed if you run
It shows what you can do with that library. The installer isn't fully working yet, only in Linux 64bit systems.

In order to use the adb-binary has to be in ~/.andropy/bin.

Install adb via on Linux 64-bit machines

Just execute it like:


Show content of /sdcard
import andropy

with andropy.ADBInterface() as ai:
    print(ai.exec_shell_cmd("ls /sdcard/"))
Get screen-resolution
import andropy

with andropy.ADBInterface() as ai:
    build_props = ai.get_build_props()

Samle output from
marco@mk-think:~/src/andropy$ python3 
# Welcome to AndroPy #
Number of devices detected: 1
Number of your downloaded apps: 41
Your phone's CPU: 1.7 GHz quad-core
Your phone's model: HTC m7ul


But as I mentioned it isn't nearly ready yet. Some of you maybe know how to use it in this state.
I will add features and more detailed instructions step by step.

The Following 10 Users Say Thank You to zantekk For This Useful Post: [ View ] Gift zantekk Ad-Free
17th December 2013, 04:09 PM |#2  
cybojenix's Avatar
Retired Forum Moderator / Retired Recognized Developer / XDA Portal Team
Thanks Meter: 1,936
Donate to Me
hey saw this pop up in the portal. after a quick glance this can become a good concept for users, such as timed logs, or a function to dump information (build prop, kmsg, logcat, bugreport, tombstones, you get the idea)

I'd like to bring your attention to this though. the prop parser
    def get_build_props(self):
        build_props = {}
        out = subprocess.check_output([ADB_EXE, "shell",
                                      "cat /system/build.prop"],
        for line in out.split('\n'):
            if line == '':
            prop = line.split('=')
            if not prop[0].startswith('#'):
                build_props[prop[0]] = prop[1]
        return build_props
you don't need to fetch the whole build prop (for most of the time). this is an extra function that you can use
def get_prop(self, prop):
    out = subprocess.check_output([ADB_EXE, "shell",
                          "getprop", "{}".format(prop)])
    return out
if you need any other help or tips, feel free to ping me on freenode, or drop a message here
The Following User Says Thank You to cybojenix For This Useful Post: [ View ] Gift cybojenix Ad-Free
17th December 2013, 05:22 PM |#3  
Grondinm's Avatar
Senior Member
Flag Moncton
Thanks Meter: 1,569
Donate to Me
This is great. Thank you. Will be using and might contribute.
17th December 2013, 07:34 PM |#5  
cybojenix's Avatar
Retired Forum Moderator / Retired Recognized Developer / XDA Portal Team
Thanks Meter: 1,936
Donate to Me
Originally Posted by Beatsleigher

Seems like I've started a trend here. Lol

seems so. I've got the base layer of a python package that plugs directly into the adb server. none of these wrappers needed
Post Reply Subscribe to Thread

Guest Quick Reply (no urls or BBcode)
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes