-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
there was a typo where self.remote should have been self.host ... I also added an example (also reformat run.py)
- Loading branch information
Showing
3 changed files
with
51 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import os | ||
|
||
from pystemd.dbuslib import DBusRemote | ||
from pystemd.systemd1 import Unit | ||
|
||
|
||
def full_example(): | ||
# DBusRemote will use ssh to connect to another bus, so whatever a valid ssh conection | ||
# string is, we can use it, you could also use DBusAddress, but thats harder | ||
with DBusRemote(b"localhost") as bus, Unit(b"postfix.service", bus=bus) as sd_unit: | ||
print("ConditionTimestamp", sd_unit.Unit.ConditionTimestamp) | ||
print("StopWhenUnneeded", sd_unit.Unit.StopWhenUnneeded) | ||
print("StartLimitAction", sd_unit.Unit.StartLimitAction) | ||
print("StartLimitBurst", sd_unit.Unit.StartLimitBurst) | ||
print("StartupBlockIOWeight", sd_unit.Service.StartupBlockIOWeight) | ||
print("SyslogPriority", sd_unit.Service.SyslogPriority) | ||
print("SyslogFacility", sd_unit.Service.SyslogFacility) | ||
print("SyslogLevelPrefix", sd_unit.Service.SyslogLevelPrefix) | ||
print("After", sd_unit.Unit.After) | ||
print("Conditions", sd_unit.Unit.Conditions) | ||
print("Job", sd_unit.Unit.Job) | ||
print("InvocationID", sd_unit.Unit.InvocationID) | ||
print("ExecStart", sd_unit.Service.ExecStart) | ||
|
||
# next one require sudo powers! | ||
if os.geteuid() == 0: | ||
print(".GetProcesses", sd_unit.Service.GetProcesses()) | ||
print(".Start(b'replace')", sd_unit.Unit.Start(b"replace")) | ||
else: | ||
print("no root user, no complex method for you!") | ||
|
||
|
||
if __name__ == "__main__": | ||
full_example() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters