Skip to content
This repository has been archived by the owner on Oct 30, 2023. It is now read-only.

Systemd service call to the jukebox fails when no shell=True #50

Closed
PaulDance opened this issue May 14, 2019 · 1 comment
Closed

Systemd service call to the jukebox fails when no shell=True #50

PaulDance opened this issue May 14, 2019 · 1 comment
Labels
backend bug Something isn't working
Milestone

Comments

@PaulDance
Copy link

PaulDance commented May 14, 2019

When the jukebox is called in the shell "by hand" to be executed by python3.6, it runs just fine. But when setting up a systemd service as such:

# /etc/systemd/system/jukebox.service
[Unit]
Description=Jukebox service

[Service]
WorkingDirectory=/home/hackademint/jukebox-ultra-nrv/
ExecStart=/usr/bin/python3.6 run.py
Restart=always
User=hackademint
Group=hackademint

[Install]
WantedBy=default.target

then it seems to have a hard time getting the sound card's master control. The 41th line of the main.py script in jukebox/src/, which is:

amixer_out = subprocess.check_output(['amixer', 'get', "'Master',0"]).decode()

fails as the alsa mixer does not find the master control:

amixer: Unable to find simple control 'Master',0

while this definitely does not happen when ran "by hand". A fix that I found was to add the keyword argument shell=True to the check_output() function:

amixer_out = subprocess.check_output(['amixer', 'get', 'Master'], shell=True).decode()

This way, it seems that the subprocess call is made just like from an actual shell, so it works well.

Also, selecting the 'Master' control seems preferable to me, as alsamixer automatically resolves it to 'Master',0 when called, but I'm not too sure on that one.

@matthias4217 matthias4217 added backend bug Something isn't working labels May 14, 2019
@matthias4217 matthias4217 added this to the MkIII-v1.0 milestone May 14, 2019
@matthias4217
Copy link
Owner

The current systemd service I use indeed stopped to work (for another reason), so I plan to tackle the issue soon. I'll look Alsamixer too. Thank you for tge insight !

@PaulDance PaulDance changed the title Systemd service call to th jukebox fails when no shell=True Systemd service call to the jukebox fails when no shell=True May 15, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
backend bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants