mirror of
https://github.com/imcarlost/pidcat-repl.git
synced 2026-08-08 23:17:43 -04:00
Merge pull request #50 from LouisBVL/process_output
Display package:process_name in process birth/death messages
This commit is contained in:
@@ -162,23 +162,26 @@ def match_packages(token):
|
|||||||
|
|
||||||
def parse_death(tag, message):
|
def parse_death(tag, message):
|
||||||
if tag != 'ActivityManager':
|
if tag != 'ActivityManager':
|
||||||
return None
|
return None, None
|
||||||
kill = PID_KILL.match(message)
|
kill = PID_KILL.match(message)
|
||||||
if kill:
|
if kill:
|
||||||
pid = kill.group(1)
|
pid = kill.group(1)
|
||||||
if match_packages(kill.group(2)) and pid in pids:
|
package_line = kill.group(2)
|
||||||
return pid
|
if match_packages(package_line) and pid in pids:
|
||||||
|
return pid, package_line
|
||||||
leave = PID_LEAVE.match(message)
|
leave = PID_LEAVE.match(message)
|
||||||
if leave:
|
if leave:
|
||||||
pid = leave.group(2)
|
pid = leave.group(2)
|
||||||
if match_packages(leave.group(1)) and pid in pids:
|
package_line = leave.group(1)
|
||||||
return pid
|
if match_packages(package_line) and pid in pids:
|
||||||
|
return pid, package_line
|
||||||
death = PID_DEATH.match(message)
|
death = PID_DEATH.match(message)
|
||||||
if death:
|
if death:
|
||||||
pid = death.group(2)
|
pid = death.group(2)
|
||||||
if match_packages(death.group(1)) and pid in pids:
|
package_line = death.group(1)
|
||||||
return pid
|
if match_packages(package_line) and pid in pids:
|
||||||
return None
|
return pid, package_line
|
||||||
|
return None, None
|
||||||
|
|
||||||
while adb.poll() is None:
|
while adb.poll() is None:
|
||||||
try:
|
try:
|
||||||
@@ -209,19 +212,19 @@ while adb.poll() is None:
|
|||||||
|
|
||||||
linebuf = '\n'
|
linebuf = '\n'
|
||||||
linebuf += colorize(' ' * (header_size - 1), bg=WHITE)
|
linebuf += colorize(' ' * (header_size - 1), bg=WHITE)
|
||||||
linebuf += indent_wrap(' Process created for %s\n' % target)
|
linebuf += indent_wrap(' Process %s created for %s\n' % (line_package, target))
|
||||||
linebuf += colorize(' ' * (header_size - 1), bg=WHITE)
|
linebuf += colorize(' ' * (header_size - 1), bg=WHITE)
|
||||||
linebuf += ' PID: %s UID: %s GIDs: %s' % (line_pid, line_uid, line_gids)
|
linebuf += ' PID: %s UID: %s GIDs: %s' % (line_pid, line_uid, line_gids)
|
||||||
linebuf += '\n'
|
linebuf += '\n'
|
||||||
print(linebuf)
|
print(linebuf)
|
||||||
last_tag = None # Ensure next log gets a tag printed
|
last_tag = None # Ensure next log gets a tag printed
|
||||||
|
|
||||||
dead_pid = parse_death(tag, message)
|
dead_pid, dead_pname = parse_death(tag, message)
|
||||||
if dead_pid:
|
if dead_pid:
|
||||||
pids.remove(dead_pid)
|
pids.remove(dead_pid)
|
||||||
linebuf = '\n'
|
linebuf = '\n'
|
||||||
linebuf += colorize(' ' * (header_size - 1), bg=RED)
|
linebuf += colorize(' ' * (header_size - 1), bg=RED)
|
||||||
linebuf += ' Process %s ended' % dead_pid
|
linebuf += ' Process %s (PID: %s) ended' % (dead_pname, dead_pid)
|
||||||
linebuf += '\n'
|
linebuf += '\n'
|
||||||
print(linebuf)
|
print(linebuf)
|
||||||
last_tag = None # Ensure next log gets a tag printed
|
last_tag = None # Ensure next log gets a tag printed
|
||||||
|
|||||||
Reference in New Issue
Block a user