Skip to content

Commit

Permalink
Fix subprocess call arguments for getting required services
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikhail Sandakov committed Mar 19, 2024
1 parent 3fbca95 commit 74cdb33
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/systemd.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,16 @@ def is_service_active(service: str):


def get_required_services(service: str) -> typing.List[str]:
res = subprocess.run([SYSTEMCTL_BIN_PATH, 'cat', service], capture_output=True, text=True)
output = res.stdout.strip()
res = subprocess.run(
[SYSTEMCTL_BIN_PATH, 'cat', service],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
check=True,
universal_newlines=True
)

required_services = []
for line in output.split('\n'):
for line in res.stdout.splitlines():
if line.startswith('Requires='):
required_services = line.split('s=')[1].split()
break
Expand Down

0 comments on commit 74cdb33

Please sign in to comment.