Created
November 10, 2015 18:43
-
-
Save gmorell/c1cec4fbcefae6c63e5a to your computer and use it in GitHub Desktop.
:<
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import os, sys | |
def get_state(): | |
val = os.popen("adb shell dumpsys battery | grep level").read() | |
if val: | |
output = val.strip().rsplit("level: ")[1] | |
output = "%s%% \n" % output | |
else: | |
output = "Phone Disconnected \n" | |
return output | |
if __name__ == "__main__": | |
val = get_state() | |
sys.stdout.write(val) | |
sys.stderr.write(val) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment