Skip to content

Commit

Permalink
Ensure value exists before using in autojack
Browse files Browse the repository at this point in the history
  • Loading branch information
ovenwerks committed Aug 19, 2022
1 parent e4b04e0 commit 2a20f04
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 15 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
studio-controls version 2.3.7

[ Len Ovens ]
- Ensure value exists before using in auto_jack.py
- Ensure value exists before using in autojack
- Don't read empty lock file

studio-controls version 2.3.6

[ Len Ovens ]
Expand Down
29 changes: 15 additions & 14 deletions usr/bin/autojack
Original file line number Diff line number Diff line change
Expand Up @@ -1795,8 +1795,6 @@ def jack_info(mesg):
def ses_cb_command(*args, **kwargs):
''' Generic signal receiver '''
global control_signal
rec_string = f"args: {str(args[0])}"
# logging.debug(f"got signal - {rec_string}")
control_signal = args


Expand All @@ -1807,6 +1805,7 @@ def command_run():
global phones
global control_signal
args = control_signal
rec_string = f"args: {str(args[0])}"
logging.debug(f"got signal - {rec_string}")
if 'start' in args:
logging.info("Got start signal.")
Expand Down Expand Up @@ -1919,18 +1918,20 @@ def main():
new_pid = str(os.getpid())
old_pid = new_pid
if os.path.isfile(lock_file):
# other instance still hasn't gone maybe hung
with open(lock_file, "r") as lk_file:
for line in lk_file:
# only need one line
old_pid = line.rstrip()
if new_pid != old_pid:
print("old lock file found, killing old pid")
try:
os.kill(int(old_pid), 9)
except Exception:
print("")
time.sleep(1)
file_stats = os.stat(lock_file)
if int(file_stats.st_size):
# other instance still hasn't gone maybe hung
with open(lock_file, "r") as lk_file:
for line in lk_file:
# only need one line
old_pid = line.rstrip()
if new_pid != old_pid:
print("old lock file found, killing old pid")
try:
os.kill(int(old_pid), 9)
except Exception:
print("")
time.sleep(1)
with open(lock_file, "w") as lk_file:
lk_file.write(new_pid)
print("Lock file created")
Expand Down
3 changes: 3 additions & 0 deletions usr/lib/python3/dist-packages/auto_jack.py
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,7 @@ def check_devices(our_db):
sub_db['description'] = "unknown"

# now find the real number
ndevs = -1
if os.path.exists("/proc/asound/cards"):
with open("/proc/asound/cards", "r") as cards_file:
for line in cards_file:
Expand All @@ -592,6 +593,8 @@ def check_devices(our_db):
ndevs = int(first_el)
else:
return our_db
if ndevs == -1:
return our_db
ndevs += 1
for x in range(0, ndevs):
# card loop
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.3.6
2.3.7

0 comments on commit 2a20f04

Please sign in to comment.