-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathedlink.py
More file actions
33 lines (24 loc) · 742 Bytes
/
Copy pathedlink.py
File metadata and controls
33 lines (24 loc) · 742 Bytes
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
import os
import sys
import platform
import subprocess
import shutil
USBTOOL = "edlink.exe"
def main():
script_dir = os.path.dirname(os.path.abspath(__file__))
app_path = os.path.join(script_dir, USBTOOL)
if not os.path.isfile(app_path):
print("error: edlink.exe not found: " + app_path, file=sys.stderr)
sys.exit(1)
args = sys.argv[1:]
if platform.system() == "Windows":
cmd = [app_path] + args
else:
if shutil.which("mono") is None:
print("error: mono runtime is not installed", file=sys.stderr)
sys.exit(1)
cmd = ["mono", app_path] + args
result = subprocess.run(cmd)
sys.exit(result.returncode)
if __name__ == "__main__":
main()