dbus_mock.py 730 B

1234567891011121314151617181920212223242526272829
  1. #!/usr/bin/env python3
  2. import os
  3. import subprocess
  4. import sys
  5. from dbusmock import DBusTestCase
  6. from lib.config import is_verbose_mode
  7. def stop():
  8. DBusTestCase.stop_dbus(DBusTestCase.system_bus_pid)
  9. DBusTestCase.stop_dbus(DBusTestCase.session_bus_pid)
  10. def start():
  11. with sys.stdout if is_verbose_mode() \
  12. else open(os.devnull, 'w', encoding='utf-8') as log:
  13. DBusTestCase.start_system_bus()
  14. DBusTestCase.spawn_server_template('logind', None, log)
  15. DBusTestCase.start_session_bus()
  16. DBusTestCase.spawn_server_template('notification_daemon', None, log)
  17. if __name__ == '__main__':
  18. start()
  19. try:
  20. subprocess.check_call(sys.argv[1:])
  21. finally:
  22. stop()