Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! @python3@/bin/python3
- from contextlib import ExitStack
- from pystemd.systemd1 import Manager, Unit
- def main():
- with Manager(_autoload=True) as manager:
- active_prev = manager.Manager.ListUnits()
- ids = [ unit[0] for unit in active_prev]
- with ExitStack() as stack:
- units = [stack.enter_context(Unit(external_id=id_, _autoload=True)) for id_ in ids]
- print(len(units))
- if __name__ == "__main__":
- main()
Add Comment
Please, Sign In to add comment