Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SYSTEMD: make get_property() with older 'systemctl' #45

Merged
merged 1 commit into from
Feb 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading