File tree Expand file tree Collapse file tree 2 files changed +23
-8
lines changed
Expand file tree Collapse file tree 2 files changed +23
-8
lines changed Original file line number Diff line number Diff line change 1+ import dataclasses
12import functools
23import subprocess
34
1011 from output_helper import print_error , print_error_and_exit , print_verbose
1112
1213
14+ @dataclasses .dataclass
15+ class _Settings :
16+ adb_prefix : str = "adb"
17+
18+
19+ __settings = _Settings ()
20+
1321_adb_prefix = "adb"
1422_IGNORED_LINES = [
1523 "WARNING: linker: libdvm.so has text relocations. This is wasting memory and is a security risk. Please fix." ,
2028
2129
2230def get_adb_prefix () -> str :
23- return _adb_prefix
31+ return __settings . adb_prefix
2432
2533
2634def set_adb_prefix (adb_prefix : str ) -> None :
27- # pylint: disable=global-statement
28- global _adb_prefix
29- _adb_prefix = adb_prefix
35+ __settings .adb_prefix = adb_prefix
3036
3137
3238def get_adb_shell_property (property_name : str , device_serial = None ) -> str | None :
Original file line number Diff line number Diff line change 1+ import dataclasses
2+ import functools
13import sys
24
3- __VERBOSE_MODE : bool = False
5+
6+ @dataclasses .dataclass
7+ class _Settings :
8+ """Settings for the output helper."""
9+ verbose : bool = False
10+
11+
12+ __settings = _Settings ()
413
514
615def set_verbose (* , enabled : bool ) -> None :
7- global __VERBOSE_MODE
8- __VERBOSE_MODE = enabled
16+ __settings .verbose = enabled
917
1018
1119def print_message (message : str ) -> None :
@@ -25,12 +33,13 @@ def print_error(error_string: str) -> None:
2533
2634
2735def print_verbose (message : str ) -> None :
28- if __VERBOSE_MODE and _is_interactive_terminal ():
36+ if __settings . verbose and _is_interactive_terminal ():
2937 print (f"{ BashColors .WARNING } { message } { BashColors .ENDC } " )
3038 else :
3139 print (message )
3240
3341
42+ @functools .lru_cache
3443def _is_interactive_terminal () -> bool :
3544 return sys .stdout .isatty ()
3645
You can’t perform that action at this time.
0 commit comments