Guest User

Untitled

a guest
Oct 18th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. #! @python3@/bin/python3
  2.  
  3. from contextlib import ExitStack
  4. from pystemd.systemd1 import Manager, Unit
  5.  
  6.  
  7. def main():
  8. with Manager(_autoload=True) as manager:
  9. active_prev = manager.Manager.ListUnits()
  10. ids = [ unit[0] for unit in active_prev]
  11. with ExitStack() as stack:
  12. units = [stack.enter_context(Unit(external_id=id_, _autoload=True)) for id_ in ids]
  13. print(len(units))
  14.  
  15.  
  16. if __name__ == "__main__":
  17. main()
Add Comment
Please, Sign In to add comment