Skip to content

Commit

Permalink
Test path correctly (issue #76)
Browse files Browse the repository at this point in the history
  • Loading branch information
ovenwerks committed Feb 23, 2022
1 parent 8a554c4 commit 35e554e
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 64 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
studio-controls version 2.3.0

[ Len Ovens ]
-Test path correctly (issue #76)

studio-controls version 2.2.9

[ Len Ovens ]
Expand Down
66 changes: 33 additions & 33 deletions usr/bin/autojack
Original file line number Diff line number Diff line change
Expand Up @@ -332,14 +332,14 @@ def net_bridge():
return
# no use checking anything else
kla = shutil.which("killall")
if kla:
if kla == None:
logging.warning("unable to kill old bridges missing killall")
else:
cp = subprocess.run([kla, "zita-n2j"],
universal_newlines=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=False)
cp1 = subprocess.run([kla, "zita-j2n"],
universal_newlines=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=False)
logging.debug(f"kill old zita-njbridge: {cp.stdout.strip()}{cp1.stdout.strip()}")
else:
logging.warning("unable to kill old bridges missing killall")

for bridge in conf_db['znet']:
br_db = conf_db['znet'][bridge]
Expand All @@ -362,7 +362,7 @@ def net_bridge():
logging.warning(f"audio network bridge {bridge} invalid")
continue
fcmd = shutil.which(cmd)
if not fcmd:
if fcmd == None:
logging.warning(f"command {cmd} not found, bridge: {bridge} can not be started")
continue
cmd = f"{fcmd} --jname {bridge} {cnt_str} {late_bits} {br_db['ip']} {str(br_db['port'])}"
Expand Down Expand Up @@ -456,7 +456,7 @@ def reconfig():
pulse_dirty = False
if [old_conf_db['pulse']['inputs'], old_conf_db['pulse']['outputs']] != [conf_db['pulse']['inputs'], conf_db['pulse']['outputs']]:
pc = shutil.which("pactl")
if not pc:
if pc == None:
logging.warning("pactl is missing... unable to control pulseaudio\n reconfigure failed")
return

Expand Down Expand Up @@ -514,15 +514,15 @@ def reconfig():
if conf_db['extra']['a2j']:
# Can't add logging for background processes. Will show up in syslog
ajc = shutil.which("a2jmidid")
if ajc:
if ajc == None:
logging.Warning("a2jmidid not found, is it installed? Starting MIDI-JACK bridge failed.")
else:
up = ""
if 'a2j_u' in conf_db['extra']:
if conf_db['extra']['a2j_u']:
up = "-u"
cmd = f"{ajc} -e {up}"
midiproc = subprocess.Popen(shlex.split(cmd), shell=False)
else:
logging.Warning("a2jmidid not found, is it installed? Starting MIDI-JACK bridge failed.")

if [old_conf_db['mnet']['count'], old_conf_db['mnet']['type']] != [conf_db['mnet']['count'], conf_db['mnet']['type']]:
logging.debug("reconfiguring MIDI network")
Expand All @@ -531,14 +531,14 @@ def reconfig():
logging.debug(f"kill old qmidinet: {cp.stdout.strip()}")
if conf_db['mnet']['count']:
mint = shutil.which("qmidinet")
if mint:
if mint == None:
logging.Warning("qmidinet not found, is it installed? Starting networked midi failed.")
else:
mtype = ""
if conf_db['mnet']['type'] == 'jack':
mtype = "--alsa-midi=no --jack-midi=yes"
cmd = f"{mint} --num-ports={str(conf_db['mnet']['count'])} --no-gui {mtype}"
subprocess.Popen(shlex.split(cmd), shell=False).pid
else:
logging.Warning("qmidinet not found, is it installed? Starting networked midi failed.")


# extra devices compares what is to config and fixes things
Expand Down Expand Up @@ -618,12 +618,12 @@ def config_start():

# Stop jack if running
kla = shutil.which("killall")
if kla:
if kla == None:
logging.warning("killall not found, audio controls may fail to work")
else:
cp = subprocess.run([kla, "-q", "-9", "jackdbus", "jackd", "a2jmidid"],
universal_newlines=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=False)
logging.debug(f"Kill old Procs: {cp.stdout.strip()}")
else:
logging.warning("killall not found, audio controls may fail to work")

jack_stat("Stopped")
last_master = 'none'
Expand All @@ -638,31 +638,31 @@ def config_start():
if (conf_db['jack']['driver'] == "firewire") or fw_exists:
time.sleep(3)
# this is a firewire device, A busreset makes for stability
ftst = shutil.which("killall")
if ftst:
ftst = shutil.which("ffado-test")
if ftst == None:
logging.warning("ffado-test not found, fire wire device may lock up. ffado-tools not installed?")
else:
cp = subprocess.run([ftst, "BusReset"],
universal_newlines=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=False)
logging.debug(f"reset firewire bus: {cp.stdout.strip()}")
time.sleep(3)
else:
logging.warning("ffado-test not found, fire wire device may lock up. ffado-tools not installed?")

if kla:
if kla == None:
logging.warning("killall not found, audio controls may fail to work")
else:
cp = subprocess.run([kla, "-q", "ffado-dbus-server", "ffado-mixer"],
universal_newlines=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=False)
logging.debug(f"Kill ffado mixer because busreset needed: {cp.stdout.strip()}")
else:
logging.warning("killall not found, audio controls may fail to work")

if not conf_db['jack']['on']:
pa = shutil.which("pulseaudio")
# restart Pulse
if pa:
if pa == None:
logging.warning("pulseaudio not found, audio controls may fail to work")
else:
cp = subprocess.run([pa, "-k"],
universal_newlines=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=False)
logging.debug(f"JACK is {str(conf_db['jack']['on'])} restart pulse: {cp.stdout.strip()}")
else:
logging.warning("pulseaudio not found, audio controls may fail to work")
return
logging.debug(f"JACK is {str(conf_db['jack']['on'])} start up jack")
jack_stat("Config Pulse")
Expand Down Expand Up @@ -795,7 +795,9 @@ def config_start():

jack_stat("Adding Bridges")
pc = shutil.which("pactl")
if pc:
if pc == None:
logging.warning("pactl is missing... unable to control pulseaudio\n configure failed")
else:
if len(conf_db['pulse']['inputs']) or len(conf_db['pulse']['outputs']):
cp = subprocess.run([pc, "unload-module", "module-udev-detect"],
universal_newlines=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=False)
Expand All @@ -820,8 +822,6 @@ def config_start():
universal_newlines=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=False)
logging.debug(f"Pulseaudio: {cp.stdout.strip()}")
time.sleep(1)
else:
logging.warning("pactl is missing... unable to control pulseaudio\n configure failed")

extra_devices()
net_bridge()
Expand All @@ -846,27 +846,27 @@ def config_start():

if conf_db['extra']['a2j']:
ajc = shutil.which("a2jmidid")
if ajc:
if ajc == None:
logging.Warning("a2jmidid not found, is it installed? Starting MIDI-JACK bridge failed.")
else:
up = ""
if 'a2j_u' in conf_db['extra']:
if conf_db['extra']['a2j_u']:
up = "-u"
cmd = f"{ajc} -e {up}"
midiproc = subprocess.Popen(shlex.split(cmd), shell=False)
#logging not possible without extra thread
else:
logging.Warning("a2jmidid not found, is it installed? Starting MIDI-JACK bridge failed.")

if conf_db['mnet']['count']:
mint = shutil.which("qmidinet")
if mint:
if mint == None:
logging.Warning("qmidinet not found, is it installed? Starting networked midi failed.")
else:
mtype = ""
if conf_db['mnet']['type'] == 'jack':
mtype = "--alsa-midi=no --jack-midi=yes"
cmd = f"{mint} --num-ports={str(conf_db['mnet']['count'])} --no-gui {mtype}"
subprocess.Popen(shlex.split(cmd), shell=False).pid
else:
logging.Warning("qmidinet not found, is it installed? Starting networked midi failed.")

jack_stat("Postbridge")
fpath = expanduser('~/.config/autojack/postbridge')
Expand Down
58 changes: 28 additions & 30 deletions usr/bin/studio-controls
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class RTSetup:
self.disabled_path = "/etc/security/limits.d/audio.conf.disabled"
self.backup_file = f"{install_path}/share/studio-controls/audio.conf"
self.pke = shutil.which("pkexec")
if not self.pke:
if self.pke == None:
print ("no pkexec, Fail")
def set_governor(self, enable):
if enable:
Expand Down Expand Up @@ -991,7 +991,7 @@ class StudioControls:

def rt_button_hit(self, button):
pke = shutil.which("pkexec")
if not self.pke:
if self.pke == None:
print ("no pkexec, Fail")
return
subprocess.run([pke, f"{install_path}/sbin/studio-system", "fix"], shell=False)
Expand Down Expand Up @@ -1032,7 +1032,7 @@ class StudioControls:
newval = widget.get_active_id()
if newval == "alsa" or newval == "ffado":
pke = shutil.which("pkexec")
if not self.pke:
if self.pke == None:
print ("no pkexec, Fail")
return
subprocess.run([pke, f"{install_path}/sbin/studio-system", newval], shell=False)
Expand Down Expand Up @@ -1470,7 +1470,7 @@ class StudioControls:
self.mnet_count.set_sensitive(False)
self.mnet_type.set_sensitive(False)
qmn = shutil.which("qmidinet")
if not (os.path.isfile(qmn) and os.access(qmn, os.X_OK)):
if qmn == None:
self.mnet_warn.set_text("Please Install qmidinet First")
self.mnet_count.set_value(0)
else:
Expand All @@ -1491,7 +1491,7 @@ class StudioControls:
self.znet_name.set_sensitive(False)
self.znet_late.set_sensitive(False)
znj = shutil.which("zita-n2j")
if not (os.path.isfile(znj) and os.access(znj, os.X_OK)):
if znj == None:
self.znet_warn.set_text("Please Install zita-njbridge First")
else:
self.znet_warn.set_text("")
Expand Down Expand Up @@ -1685,67 +1685,65 @@ class StudioControls:
return
if widget.get_active_id() == "ffado":
ffm = shutil.which("ffado-mixer")
if ffm:
if ffm == None:
print("ffado-mixer not installed")
else:
try:
subprocess.Popen([ffm], shell=False).pid
except:
print("ffado-mixer errors are normal :P")
else:
print("ffado-mixer not installed")
else:
mixdevice = widget.get_active_id()
qasm=shutil.which("qasmixer")
if qasm:
subprocess.Popen([qasm, "-n", f"--device=hw:{str(mixdevice)}"], shell=False).pid
else:
if qasm == None:
print("qasmixer not installed")
else:
subprocess.Popen([qasm, "-n", f"--device=hw:{str(mixdevice)}"], shell=False).pid
widget.set_active_id("none")
widget.set_sensitive(True)


def pavucontrol_cb(self, button):
'''callback for pulse control button, opens pavucontrol'''
pvc = shutil.which("pavucontrol")
if not pvc:
if pvc == None:
pvc = shutil.which("pavucontrol-qt")

subprocess.Popen([pvc], shell=False).pid
if pvc == None:
print("pavucontrol not installed")
else:
subprocess.Popen([pvc], shell=False).pid

def carla_cb(self, button):
'''callback for carla button, opens carla'''
crla = shutil.which("carla")
if os.path.isfile(crla) and os.access(crla, os.X_OK):
subprocess.Popen([crla], shell=False).pid
else:
if crla == None:
button.set_label("Please Install Carla First")
button.set_sensitive(False)
else:
subprocess.Popen([crla], shell=False).pid

def ray_cb(self, button):
'''callback for raysession button, opens raysession'''
rays = shutil.which("raysession")
if os.path.isfile(rays) and os.access(rays, os.X_OK):
subprocess.Popen([rays], shell=False).pid
else:
if rays == None:
button.set_label("Please Install RaySession First")
button.set_sensitive(False)
else:
subprocess.Popen([rays], shell=False).pid

def nsm_cb(self, button):
'''callback for nsm button, opens New Session Manager'''
ns = shutil.which("nsm-legacy-gui")
if os.path.isfile(ns) and os.access(ns, os.X_OK):
subprocess.Popen([ns], shell=False).pid
else:
if ns == None:
button.set_label("Please Install New Session Manager First")
button.set_sensitive(False)
else:
subprocess.Popen([ns], shell=False).pid

def agordejo_cb(self, button):
'''callback for agordejo button, opens agordejo'''
agdo = shutil.which("agordejo")
if os.path.isfile(agdo) and os.access(agdo, os.X_OK):
subprocess.Popen([agdo], shell=False).pid
else:
if agdo == None:
button.set_label("Please Install Agordejo First")
button.set_sensitive(False)
else:
subprocess.Popen([agdo], shell=False).pid

# Autojack signalling calls

Expand Down
2 changes: 1 addition & 1 deletion usr/share/studio-controls/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.2.9
2.3.0

0 comments on commit 35e554e

Please sign in to comment.