def __init__(self, context): self.bus = None try: self.upstart = UpstartSystem() except: self.bus = DirectUpstartBus() self.upstart = UpstartSystem(bus=self.bus)
def __verify__(cls): try: UpstartSystem() return True except: try: UpstartSystem(bus=DirectUpstartBus()) return True except: return False
def __verify__(cls): """ Test if upstart system is used. :return: Response from Python module upstart. :rtype: bool """ try: UpstartSystem() return True except Exception as e: try: UpstartSystem(bus=DirectUpstartBus()) return True except Exception as e: return False
def test_system(): from upstart.system import UpstartSystem s = UpstartSystem() print("Version: %s" % (s.get_version())) current_priority = s.get_log_priority() print("Current priority: %s" % (current_priority)) new_priority = 'debug' s.set_log_priority(new_priority) updated_priority = s.get_log_priority() print("Updated priority: %s" % (updated_priority)) s.set_log_priority(current_priority) restored_priority = s.get_log_priority() print("Restored priority: %s" % (restored_priority)) # print(list(s.get_all_jobs())) s.emit('foo', {'aa': 55})