Exemplo n.º 1
0
    def toolboxTriggered(self):
        try:
            os.waitpid(-1, os.WNOHANG)
        except OSError:
            pass

        # See if it is already running...
        ok, lock_file = utils.lock_app('hp-toolbox', True)

        if ok: # able to lock, not running...
            utils.unlock(lock_file)

            path = utils.which('hp-toolbox')
            if path:
                path = os.path.join(path, 'hp-toolbox')
            else:
                self.tray_icon.showMessage(self.__tr("HPLIP Status Service"),
                                self.__tr("Unable to locate hp-toolbox on system PATH."),
                                QSystemTrayIcon.Critical, TRAY_MESSAGE_DELAY)

                log.error("Unable to find hp-toolbox on PATH.")
                return

            #log.debug(path)
            log.debug("Running hp-toolbox: hp-toolbox")
            os.spawnlp(os.P_NOWAIT, path, 'hp-toolbox')

        else: # ...already running, raise it
            self.sendMessage('', '', EVENT_RAISE_DEVICE_MANAGER, interface='com.hplip.Toolbox')
Exemplo n.º 2
0
    def toolbox_triggered(self):
        try:
            os.waitpid(-1, os.WNOHANG)
        except OSError:
            pass

        # See if it is already running...
        ok, lock_file = utils.lock_app('hp-toolbox', True)

        if ok:  # able to lock, not running...
            utils.unlock(lock_file)

            path = utils.which('hp-toolbox')
            if path:
                path = os.path.join(path, 'hp-toolbox')
            else:
                log.error("Unable to find hp-toolbox on PATH.")

                self.tray_icon.showMessage(
                    "HPLIP Status Service",
                    self.__tr("Unable to locate hp-toolbox on system PATH."),
                    self.icon_error, 5000)

                return

            log.debug(path)
            os.spawnlp(os.P_NOWAIT, path, 'hp-toolbox')

        else:  # ...already running, raise it
            device.Event('', '', EVENT_RAISE_DEVICE_MANAGER).send_via_dbus(
                SessionBus(), 'com.hplip.Toolbox')
Exemplo n.º 3
0
    def toolboxTriggered(self):
        try:
            os.waitpid(-1, os.WNOHANG)
        except OSError:
            pass

        # See if it is already running...
        ok, lock_file = utils.lock_app('hp-toolbox', True)

        if ok: # able to lock, not running...
            utils.unlock(lock_file)

            path = utils.which('hp-toolbox')
            if path:
                path = os.path.join(path, 'hp-toolbox')
            else:
                self.tray_icon.showMessage(self.__tr("HPLIP Status Service"),
                                self.__tr("Unable to locate hp-toolbox on system PATH."),
                                QSystemTrayIcon.Critical, TRAY_MESSAGE_DELAY)

                log.error("Unable to find hp-toolbox on PATH.")
                return

            #log.debug(path)
            log.debug("Running hp-toolbox: hp-toolbox")
            os.spawnlp(os.P_NOWAIT, path, 'hp-toolbox')

        else: # ...already running, raise it
            self.sendMessage('', '', EVENT_RAISE_DEVICE_MANAGER, interface='com.hplip.Toolbox')
Exemplo n.º 4
0
def handle_fax_event(event, pipe_name):
    if event.event_code == EVENT_FAX_RENDER_COMPLETE and \
        event.username == prop.username:

        fax_file_fd, fax_file_name = tempfile.mkstemp(prefix="hpfax-")
        pipe = os.open(pipe_name, os.O_RDONLY)
        bytes_read = 0
        while True:
            data = os.read(pipe, PIPE_BUF)
            if not data:
                break

            os.write(fax_file_fd, data)
            bytes_read += len(data)

        log.debug("Saved %d bytes to file %s" % (bytes_read, fax_file_name))

        os.close(pipe)
        os.close(fax_file_fd)

        devices[event.device_uri].faxes[(event.username, event.job_id)] = \
            device.FaxEvent(fax_file_name, event)

        show_waiting_faxes(event.device_uri)

        try:
            os.waitpid(-1, os.WNOHANG)
        except OSError:
            pass

        # See if hp-sendfax is already running for this queue
        ok, lock_file = utils.lock_app('hp-sendfax-%s' % event.printer_name,
                                       True)

        if ok:
            # able to lock, not running...
            utils.unlock(lock_file)

            path = utils.which('hp-sendfax')
            if path:
                path = os.path.join(path, 'hp-sendfax')
            else:
                log.error("Unable to find hp-sendfax on PATH.")
                return

            log.debug("Running hp-sendfax: %s --printer=%s" %
                      (path, event.printer_name))
            os.spawnlp(os.P_NOWAIT, path, 'hp-sendfax',
                       '--printer=%s' % event.printer_name)

        else:
            # cannot lock file - hp-sendfax is running
            # no need to do anything... hp-sendfax is polling
            log.debug(
                "hp-sendfax is running. Waiting for CheckForWaitingFax() call."
            )

    else:
        log.warn("Not handled!")
        pass
Exemplo n.º 5
0
    def toolbox_triggered(self):
        try:
            os.waitpid(-1, os.WNOHANG)
        except OSError:
            pass

        # See if it is already running...
        ok, lock_file = utils.lock_app('hp-toolbox', True)

        if ok: # able to lock, not running...
            utils.unlock(lock_file)

            path = utils.which('hp-toolbox')
            if path:
                path = os.path.join(path, 'hp-toolbox')
            else:
                log.error("Unable to find hp-toolbox on PATH.")

                self.tray_icon.showMessage("HPLIP Status Service",
                                self.__tr("Unable to locate hp-toolbox on system PATH."),
                                self.icon_error, 5000)

                return

            log.debug(path)
            os.spawnlp(os.P_NOWAIT, path, 'hp-toolbox')

        else: # ...already running, raise it
            device.Event('', '', EVENT_RAISE_DEVICE_MANAGER).send_via_dbus(SessionBus(), 'com.hplip.Toolbox')
Exemplo n.º 6
0
def handle_fax_event(event, pipe_name):
    if event.event_code == EVENT_FAX_RENDER_COMPLETE and \
        event.username == prop.username:

        fax_file_fd, fax_file_name = tempfile.mkstemp(prefix="hpfax-")
        pipe = os.open(pipe_name, os.O_RDONLY)
        bytes_read = 0
        while True:
            data = os.read(pipe, PIPE_BUF)
            if not data:
                break

            os.write(fax_file_fd, data)
            bytes_read += len(data)

        log.debug("Saved %d bytes to file %s" % (bytes_read, fax_file_name))

        os.close(pipe)
        os.close(fax_file_fd)

        devices[event.device_uri].faxes[(event.username, event.job_id)] = \
            device.FaxEvent(fax_file_name, event)

        show_waiting_faxes(event.device_uri)

        try:
            os.waitpid(-1, os.WNOHANG)
        except OSError:
            pass

        # See if hp-sendfax is already running for this queue
        ok, lock_file = utils.lock_app('hp-sendfax-%s' % event.printer_name, True)

        if ok:
            # able to lock, not running...
            utils.unlock(lock_file)

            path = utils.which('hp-sendfax')
            if path:
                path = os.path.join(path, 'hp-sendfax')
            else:
                log.error("Unable to find hp-sendfax on PATH.")
                return

            log.debug("Running hp-sendfax: %s --printer=%s" % (path, event.printer_name))
            os.spawnlp(os.P_NOWAIT, path, 'hp-sendfax',
                '--printer=%s' % event.printer_name)

        else:
            # cannot lock file - hp-sendfax is running
            # no need to do anything... hp-sendfax is polling
            log.debug("hp-sendfax is running. Waiting for CheckForWaitingFax() call.")

    else:
        log.warn("Not handled!")
        pass
Exemplo n.º 7
0
    def lockAndLoad(self):
        # Start up check timer here, since the fax name is now known
        if self.CheckTimer is None:
            self.CheckTimer = QTimer(self)
            self.connect(self.CheckTimer, SIGNAL("timeout()"), self.CheckTimer_timeout)
            self.CheckTimer.start(3000)

        # Lock the app
        if self.printer_name and self.lock_file is None:
            ok, self.lock_file = utils.lock_app('hp-sendfax-%s' % self.printer_name, True)

            if not ok:
                log.error("hp-sendfax is already running for fax %s" % self.printer_name)
Exemplo n.º 8
0
    def lockAndLoad(self):
        # Start up check timer here, since the fax name is now known
        if self.CheckTimer is None:
            self.CheckTimer = QTimer(self)
            self.CheckTimer.timeout.connect(self.CheckTimer_timeout)
            self.CheckTimer.start(3000)

        # Lock the app
        if self.printer_name and self.lock_file is None:
            ok, self.lock_file = utils.lock_app(
                'hp-sendfax-%s' % self.printer_name, True)

            if not ok:
                log.error("hp-sendfax is already running for fax %s" %
                          self.printer_name)
Exemplo n.º 9
0
    def lock(self, printer_name=None):
        if printer_name is None:
            printer_name = self.cur_printer

        ok, self.lock_file = utils.lock_app('hp-sendfax-%s' % printer_name, True)