def get_printers(): bus = get_bus() printers = {} for namespace in _common.list_printers(): printer_uuid = uuid.UUID(namespace.split(".")[-1][1:].replace("_", "-")) object_path = "/" + namespace.replace(".", "/") proxy = bus.get_object(namespace, object_path) printers[printer_uuid] = PrinterInterface(printer_uuid, proxy) return printers
def get_printers(): bus = get_bus() printers = {} for namespace in _common.list_printers(): printer_uuid = uuid.UUID( namespace.split(".")[-1][1:].replace("_", "-")) object_path = "/" + namespace.replace(".", "/") proxy = bus.get_object(namespace, object_path) printers[printer_uuid] = PrinterInterface(printer_uuid, proxy) return printers
def on_disconnect(handler, *event_args): """Worker subprocess to handle on_disconnect events generated by hardware monitors.""" bus = common.get_bus() for name in list_printers(): path = "/org/voxelpress/hardware/" + name.split(".")[-1] prox = bus.get_object(name, path) if prox.verify_disconnect(event_args[0]): break
def on_disconnect(handler, *event_args): """Worker subprocess to handle on_disconnect events generated by hardware monitors.""" bus = common.get_bus() for name in list_printers(): path = "/org/voxelpress/hardware/"+name.split(".")[-1] prox = bus.get_object(name, path) if prox.verify_disconnect(event_args[0]): break
def __init__(self, device_path, printer_uuid, driver): self.__device_path = device_path self.__driver = driver self.status = None self.__path = path_from_uuid(printer_uuid) self.__name = name_from_uuid(printer_uuid) bus_name = dbus.service.BusName(self.__name, bus=common.get_bus()) print "Printer Online:", self.__name dbus.service.Object.__init__(self, bus_name, self.__path) self.on_state_change("ready") self.__driver.connect_events(self)
def start_server_loop(device_path, printer_uuid, driver): # do this before creating any bus object! main_loop = gobject.MainLoop() DBusGMainLoop(set_as_default=True) bus = common.get_bus() printers = list_printers() check_name = name_from_uuid(printer_uuid) if printers.count(check_name): reconnect_args = json.dumps(driver.inform_reconnect()) path = "/" + check_name.replace(".", "/") prox = bus.get_object(check_name, path) prox.force_reconnect(device_path, reconnect_args) else: server = PrintServer(device_path, printer_uuid, driver) # notify the main process that a new printer exists switchboard = bus.get_object( "org.voxelpress.hardware", "/org/voxelpress/hardware") switchboard.worker_new_printer(str(printer_uuid)) main_loop.run()
def __init__(self): self.__bus = common.get_bus() bus_name = dbus.service.BusName( "org.voxelpress.hardware", bus=self.__bus) dbus.service.Object.__init__( self, bus_name, "/org/voxelpress/hardware")
def list_printers(): """List all currently existing Printer Servers.""" return [str(v) for v in common.get_bus().list_names() if str(v).startswith("org.voxelpress.hardware.")]
def __init__(self): self.__bus = common.get_bus() bus_name = dbus.service.BusName("org.voxelpress.hardware", bus=self.__bus) dbus.service.Object.__init__(self, bus_name, "/org/voxelpress/hardware")