Skip to content

Commit 8d8ac9a

Browse files
committed
Added adb and logcat commands to cl entry_point
1 parent 7b15133 commit 8d8ac9a

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

pythonforandroid/toolchain.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from __future__ import print_function
1010

1111
import sys
12-
from sys import stdout
12+
from sys import stdout, platform
1313
from os.path import (join, dirname, realpath, exists, isdir, basename,
1414
expanduser)
1515
from os import listdir, unlink, makedirs, environ, chdir, getcwd, walk, uname
@@ -2520,6 +2520,27 @@ def delete_dist(self, args):
25202520
info('No dist exists that matches your specifications, exiting without deleting.')
25212521
shutil.rmtree(dist.dist_dir)
25222522

2523+
def adb(self, args):
2524+
'''Runs the adb binary from the detected SDK directory, passing all
2525+
arguments straight to it.'''
2526+
ctx = self.ctx
2527+
ctx.prepare_build_environment(user_sdk_dir=self.sdk_dir,
2528+
user_ndk_dir=self.ndk_dir,
2529+
user_android_api=self.android_api,
2530+
user_ndk_ver=self.ndk_version)
2531+
if platform in ('win32', 'cygwin'):
2532+
adb = sh.Command(join(ctx.sdk_dir, 'platform-tools', 'adb.exe'))
2533+
else:
2534+
adb = sh.Command(join(ctx.sdk_dir, 'platform-tools', 'adb'))
2535+
info_notify('Starting adb...')
2536+
output = adb(args, _iter=True, _out_bufsize=1, _err_to_out=True)
2537+
for line in output:
2538+
print(line)
2539+
2540+
def logcat(self, args):
2541+
'''Runs ``adb logcat`` using the adb binary from the detected SDK
2542+
directory. All extra args are passed as arguments to logcat.'''
2543+
self.adb(['logcat'] + args)
25232544

25242545
if __name__ == "__main__":
25252546

0 commit comments

Comments
 (0)