-
Notifications
You must be signed in to change notification settings - Fork 4
/
helper.py
35 lines (28 loc) · 875 Bytes
/
helper.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/env python3
# helper.py
import os
import subprocess
from colorama import Fore, Style
def repopick(command):
try:
subprocess.run(command, check=True)
except subprocess.CalledProcessError as e:
die(f"Command '{e.cmd}' returned non-zero exit status {e.returncode}.")
def _adb_connected():
try:
subprocess.run(['adb', 'devices'], check=True)
return True
except subprocess.CalledProcessError:
return False
def init_adb_connection():
if not _adb_connected():
die("No ADB connection detected. Please connect your device and enable ADB.")
def header(msg):
print(Fore.CYAN + msg + Style.RESET_ALL)
def die(msg):
print(Fore.RED + msg + Style.RESET_ALL)
exit(1)
def success(msg):
print(Fore.GREEN + msg + Style.RESET_ALL)
def info(msg):
print(Fore.YELLOW + msg + Style.RESET_ALL)