Example #1
0
    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)
Example #2
0
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()