Merge pull request #63 from brennantaylor/catfile

When there is data on stdin we use it instead of adb
This commit is contained in:
Jake Wharton
2014-07-15 15:34:58 -07:00
+11 -1
View File
@@ -22,11 +22,11 @@ limitations under the License.
# Package filtering and output improvements by Jake Wharton, http://jakewharton.com # Package filtering and output improvements by Jake Wharton, http://jakewharton.com
import argparse import argparse
import sys
import re import re
import subprocess import subprocess
from subprocess import PIPE from subprocess import PIPE
LOG_LEVELS = 'VDIWEF' LOG_LEVELS = 'VDIWEF'
LOG_LEVELS_MAP = dict([(LOG_LEVELS[i], i) for i in range(len(LOG_LEVELS))]) LOG_LEVELS_MAP = dict([(LOG_LEVELS[i], i) for i in range(len(LOG_LEVELS))])
parser = argparse.ArgumentParser(description='Filter logcat by package name') parser = argparse.ArgumentParser(description='Filter logcat by package name')
@@ -164,7 +164,17 @@ if args.clear_logcat:
while adb_clear.poll() is None: while adb_clear.poll() is None:
pass pass
# This is a ducktype of the subprocess.Popen object
class FakeStdinProcess():
def __init__(self):
self.stdout = sys.stdin
def poll(self):
return None
if sys.stdin.isatty():
adb = subprocess.Popen(adb_command, stdin=PIPE, stdout=PIPE, stderr=PIPE) adb = subprocess.Popen(adb_command, stdin=PIPE, stdout=PIPE, stderr=PIPE)
else:
adb = FakeStdinProcess()
pids = set() pids = set()
last_tag = None last_tag = None
app_pid = None app_pid = None