class ProcessConfig: argv = dbus_attr(List(Str())) monitor = dbus_attr(Bool(), default=False) restart = dbus_attr(Bool(), default=False) cleanup = dbus_attr(Bool(), default=False) env = dbus_attr(Dict(Str(), Str())) cwd = dbus_attr(Str())
class BaseConfig: applications = subconfig(ApplicationsConfig) autostart = subconfig(AutostartConfig) dbus = subconfig(DBusConfig) executors = subconfig(ExecutorsConfig) format = subconfig(FormatConfig) logger = subconfig(LoggerConfig) menu = subconfig(MenuConfig) meta = subconfig(MetaConfig) mime = subconfig(MimeConfig) urls = dbus_attr(Dict(Str(), Str()))
def dbus_service(thing_cls): svc = Service("some.namespace") a = svc.object("/thing/A") @a.method([Str()], Bool()) def method_one(s): assert type(s) == str return s == "numberwang" @a.method([thing_cls], thing_cls) def method_two(thing): assert isinstance(thing, thing_cls) return thing_cls("pong") a.signal("signal_a", Str()) a.signal("signal_b", thing_cls) a.property("property_u", Str(), "pony", writeable=True) a.property("property_v", Bool(), True) b = svc.object("/thing/B") @b.method([thing_cls], Str()) def method_three(thing): assert isinstance(thing, thing_cls) return "that's right" @b.method([Bool()], Str()) def method_four(b): assert type(b) == bool return "that's not it chief" b.signal("signal_c", Bool()) b.signal("signal_d", thing_cls) b.property("property_w", Int32(), 12) return dict( svc=svc, a=a, b=b, method_one=method_one, method_two=method_two, method_three=method_three, method_four=method_four, )
class ProcessState: name = dbus_attr(Str(), default="???") state = dbus_attr(Str(), default="UNKNOWN") restart = dbus_attr(Bool(), default=False) threshold = dbus_attr(Int64()) killTime = dbus_attr(Int64()) minRestartDelay = dbus_attr(Int64()) maxRestartDelay = dbus_attr(Int64()) @classmethod def from_procmon_state(cls, state): return cls( name=state.name, state=state.state.value, restart=state.settings.restart, threshold=state.settings.threshold or -1, killTime=state.settings.killTime or -1, minRestartDelay=state.settings.minRestartDelay or -1, maxRestartDelay=state.settings.maxRestartDelay or -1, )
def attach(self, service): obj = service.object("/korbenware/Session") @obj.method([], SessionState) def get_state(): return SessionState.from_session(self) @obj.method([Str()], Bool()) def run_xdg_application(name): self.primary_executor.run_xdg_application_by_name(name) return True @obj.method([Str()], Bool()) def stop_xdg_application(name): self.primary_executor.stop_process(name) return True @obj.method([Str()], Bool()) def start_xdg_application(name): self.primary_executor.start_process(name) return True @obj.method([Str()], Bool()) def restart_xdg_application(name): self.primary_executor.restart_process(name) return True @obj.method([Str()], Bool()) def restart_critical_process(name): self.critical_executor.restart_process(name) return True @obj.method([], Bool()) def shutdown(): self.stop() return True return obj
class Thing: string = dbus_attr(Str())
class MimeConfig: cache = dbus_attr(Str(), default="/usr/share/applications/mimeinfo.cache") environment = dbus_attr(Str(), default=XDG_CURRENT_DESKTOP)
class MetaConfig: config_filename = dbus_attr(Str(), default="????")
class MenuConfig: filename = dbus_attr(Str())
class LoggerConfig: level = dbus_attr(Str(), default="debug")
class FormatConfig: pygments_formatter = dbus_attr(Str(), default="trac")
class DBusConfig: namespace = dbus_attr(Str(), default="org.jfhbrook.korbenware")
class AutostartConfig: directories = dbus_attr(List(Str()), default=XDG_AUTOSTART_DIRS) environment_name = dbus_attr(Str(), default=XDG_CURRENT_DESKTOP) skip_unparsed = dbus_attr(Bool(), default=False) skip_invalid = dbus_attr(Bool(), default=False)
class ApplicationsConfig: directories = dbus_attr(List(Str()), default=XDG_APPLICATIONS_DIRS) skip_unparsed = dbus_attr(Bool(), default=False) skip_invalid = dbus_attr(Bool(), default=False)
class ExecutorsConfig: primary = dbus_attr(Dict(Str(), ProcessConfig)) critical = dbus_attr(Dict(Str(), CriticalProcessConfig))