-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrun_maschine.py
33 lines (23 loc) · 909 Bytes
/
run_maschine.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
import subprocess
import re
from setup_midi import get_local_file_path
binary_location = "./target/release/maschine"
def get_hdraw(regex):
regexResult = re.search(",.*hidraw.*:",regex)
return regexResult.group(0).replace(",","").replace(":","")
def find_hidraw():
results = subprocess.check_output("sudo -u pi dmesg", universal_newlines=True, shell=True).split('\n')
hdraw = ""
for device in results:
if "Native Instruments".lower() in device.lower() and "hidraw" in device.lower():
print(device)
hdraw = get_hdraw(device)
print("Using HID", hdraw )
return hdraw
def run_maschine():
subprocess.run("sudo " + binary_location + " /dev/" + find_hidraw(), shell=True, check=True, cwd = get_local_file_path("maschine.rs") )
if __name__ == "__main__":
try:
run_maschine()
except:
print("Maschine isn't setup")