Skip to content

Use pydbus module for VPN enable/disable and log reading? #593

Description

@ra-at-diladele-com

After pip install pydbus use the following snippets for logs:

from systemd import journal

j = journal.Reader()
j.this_boot()
j.add_match(_SYSTEMD_UNIT="nginx.service")

for entry in j:
    print(entry["MESSAGE"])

And for systemctl:

from pydbus import SystemBus

bus = SystemBus()
systemd = bus.get(".systemd1")

# Start a service
systemd.StartUnit("nginx.service", "replace")

# Get unit state
unit = bus.get(".systemd1", "/org/freedesktop/systemd1/unit/nginx_2eservice")
print(unit.ActiveState)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions