Android: fix warnings in runner script
Remove f-format prints that uses no placeholders. Check if logcat_process is initialized before accessing it. Remove unused import. Pick-to: 6.8 Change-Id: I72cc34666460300b3b6b58174b3c7cefac27da7d Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
This commit is contained in:
parent
df3f5d88d3
commit
2eeb35539c
@ -10,8 +10,6 @@ import time
|
||||
import signal
|
||||
import argparse
|
||||
|
||||
from datetime import datetime
|
||||
|
||||
def status(msg):
|
||||
print(f"\n-- {msg}")
|
||||
|
||||
@ -70,10 +68,10 @@ try:
|
||||
serial = line.split('\t')[0]
|
||||
devices.append(serial)
|
||||
if not devices:
|
||||
die(f"No devices are connected.")
|
||||
die("No devices are connected.")
|
||||
|
||||
if args.serial and not args.serial in devices:
|
||||
die(f"No connected devices with the specified serial number.")
|
||||
die("No connected devices with the specified serial number.")
|
||||
except Exception as e:
|
||||
die(f"Failed to check for running devices, received error: {e}")
|
||||
|
||||
@ -174,11 +172,12 @@ def terminate_app(signum, frame):
|
||||
signal.signal(signal.SIGINT, terminate_app)
|
||||
|
||||
# Show app's logs
|
||||
logcat_process = None;
|
||||
try:
|
||||
format_arg = "-v brief -v color"
|
||||
time_arg = f"-T '{start_timestamp}'"
|
||||
# escape char and color followed with fatal tag
|
||||
fatal_regex = f"-e $'^\x1b\\[[0-9]*mF/'"
|
||||
fatal_regex = "-e $'^\x1b\\[[0-9]*mF/'"
|
||||
pid_regex = f"-e '([ ]*{pid}):'"
|
||||
logcat_cmd = f"{adb} shell \"logcat {time_arg} {format_arg} | grep {pid_regex} {fatal_regex}\""
|
||||
logcat_process = subprocess.Popen(logcat_cmd, shell=True)
|
||||
@ -199,6 +198,7 @@ try:
|
||||
status(f"The app \"{package_name}\" has exited")
|
||||
break
|
||||
finally:
|
||||
if logcat_process:
|
||||
logcat_process.terminate()
|
||||
|
||||
if interrupted:
|
||||
|
Loading…
x
Reference in New Issue
Block a user