Skip to content

Commit

Permalink
SYSTEMD: make get_property() with older 'systemctl'
Browse files Browse the repository at this point in the history
On centos-8 systemctl doesn't support '-P'
'--value --property' should work with both older and modern versions.
  • Loading branch information
alexey-tikhonov committed Feb 12, 2024
1 parent 4fa6a09 commit f3fbf79
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pytest_mh/utils/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ def async_get_property(self, service: str, prop: str) -> SSHProcess:
:return: Running SSH process.
:rtype: SSHProcess
"""
return self.host.ssh.async_run(f'systemctl show "{service}" -P "{prop}"')
return self.host.ssh.async_run(f'systemctl show "{service}" --value --property "{prop}"')

def get_property(self, service: str, prop: str, raise_on_error: bool = True) -> str:
"""
Expand All @@ -241,7 +241,9 @@ def get_property(self, service: str, prop: str, raise_on_error: bool = True) ->
:return: property value as string.
:rtype: str
"""
result = self.host.ssh.run(f'systemctl show "{service}" -P "{prop}"', raise_on_error=raise_on_error)
result = self.host.ssh.run(
f'systemctl show "{service}" --value --property "{prop}"', raise_on_error=raise_on_error
)
return result.stdout.strip()

def async_reload_daemon(self) -> SSHProcess:
Expand Down

0 comments on commit f3fbf79

Please sign in to comment.