|
13 | 13 | # If not, see <https://www.gnu.org/licenses/>.""" |
14 | 14 | # Author: Tobias Sterbak |
15 | 15 |
|
| 16 | +import sys |
16 | 17 | from pathlib import Path |
17 | 18 | from subprocess import STDOUT, CalledProcessError, call, check_output |
18 | 19 | from typing import Optional |
|
21 | 22 | from loguru import logger |
22 | 23 |
|
23 | 24 |
|
| 25 | +PLATFORM = sys.platform |
| 26 | + |
| 27 | + |
24 | 28 | def call_tool_with_command(command: str, bin_path: Path) -> bool: |
25 | 29 | """Call an executable with a specific command.""" |
26 | | - command = re.sub(r"^adb", re.escape(str(bin_path.joinpath(Path("adb")))), command) |
27 | | - command = re.sub(r"^fastboot", re.escape(str(bin_path.joinpath(Path("fastboot")))), command) |
28 | | - command = re.sub(r"^heimdall", re.escape(str(bin_path.joinpath(Path("heimdall")))), command) |
| 30 | + if PLATFORM == "win32": |
| 31 | + command = re.sub(r"^adb", re.escape(str(bin_path.joinpath(Path("adb.exe")))), command) |
| 32 | + command = re.sub(r"^fastboot", re.escape(str(bin_path.joinpath(Path("fastboot.exe")))), command) |
| 33 | + command = re.sub(r"^heimdall", re.escape(str(bin_path.joinpath(Path("heimdall.exe")))), command) |
| 34 | + else: |
| 35 | + command = re.sub(r"^adb", re.escape(str(bin_path.joinpath(Path("adb")))), command) |
| 36 | + command = re.sub(r"^fastboot", re.escape(str(bin_path.joinpath(Path("fastboot")))), command) |
| 37 | + command = re.sub(r"^heimdall", re.escape(str(bin_path.joinpath(Path("heimdall")))), command) |
29 | 38 |
|
30 | 39 | logger.info(f"Run command: {command}") |
31 | 40 | res = call(f"{command}", shell=True) |
|
0 commit comments