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')
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')
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
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')
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
def closeEvent(self, e): if self.lock_file is not None: utils.unlock(self.lock_file) e.accept()
def closeEvent(self, event): #print "close" #print self.FaxView.lock_file utils.unlock(self.FaxView.lock_file) event.accept()
def unlock(self): utils.unlock(self.lock_file)