def start_systray(): Systray_Is_Running = False status, output = utils.Is_Process_Running('hp-systray') if status is False: log.debug("hp-systray is not running.") if os.getuid() == 0: log.error("Run \'hp-systray &\' in a terminal. ") else: log.debug("Starting hp-systray service") child_pid = os.fork() if child_pid == 0: status, output = utils.run('hp-systray &', True, None, 1, False) if status is not 0: log.error( "Failed to start \'hp-systray\' service. Manually run \'hp-sysray &\' from terminal as non-root user." ) sys.exit() else: time.sleep(1) status, output = utils.Is_Process_Running('hp-systray') if status is True: Systray_Is_Running = True else: Systray_Is_Running = True log.debug("hp-systray service is running\n") return Systray_Is_Running
def install_firmware(pluginObj, Plugin_Installation_Completed, USB_param): #timeout check for plugin installation sleep_timeout = 6000 # 10 mins time out while Plugin_Installation_Completed is False and sleep_timeout != 0: time.sleep(0.3) #0.3 sec delay sleep_timeout = sleep_timeout - 3 ps_plugin, output = utils.Is_Process_Running('hp-plugin') ps_diagnose_plugin, output = utils.Is_Process_Running( 'hp-diagnose_plugin') if ps_plugin is False and ps_diagnose_plugin is False: Plugin_Installation_Completed = True if pluginObj.getStatus() == PLUGIN_INSTALLED: break else: log.error( "Failed to download firmware required files. manually run hp-plugin command in terminal fisrt" ) sys.exit(1) execmd = "hp-firmware" options = "" if USB_param is not None: options += " -y3 %s" % (USB_param) if log_level is 'debug': options += " -g" cmd = execmd + options log.info("Starting Firmware installation.") log.debug("Running command : %s " % cmd) Status, out = utils.run(cmd)
def close_running_hp_processes(): # check systray is running? status, output = utils.Is_Process_Running('hp-systray') if status is True: ok, choice = tui.enter_choice( "\nSome HPLIP applications are running. Press 'y' to close applications or press 'n' to quit upgrade(y=yes*, n=no):", ['y', 'n'], 'y') if not ok or choice == 'n': log.info( "Manually close HPLIP applications and run hp-upgrade again.") return False try: # dBus from dbus import SystemBus, lowlevel except ImportError: log.error("Unable to load DBus.") pass else: try: args = [ '', '', EVENT_SYSTEMTRAY_EXIT, prop.username, 0, '', '' ] msg = lowlevel.SignalMessage('/', 'com.hplip.StatusService', 'Event') msg.append(signature='ssisiss', *args) log.debug("Sending close message to hp-systray ...") SystemBus().send_message(msg) time.sleep(0.5) except: log.error( "Failed to send DBus message to hp-systray/hp-toolbox.") pass toolbox_status, output = utils.Is_Process_Running('hp-toolbox') if toolbox_status is True: log.error( "Failed to close either HP-Toolbox/HP-Systray. Manually close and run hp-upgrade again." ) return False return True
def start_systray(): if DBUS_AVIALABLE == False: return False Systray_Is_Running = False status, output = utils.Is_Process_Running('hp-systray') if status is False: if os.getuid() == 0: log.error( " hp-systray must be running.\n Run \'hp-systray &\' in a terminal. " ) else: log.info("Starting hp-systray service") services.run_systray() status, output = utils.Is_Process_Running('hp-systray') if status == True: Systray_Is_Running = True log.debug("hp-systray service is running\n") return Systray_Is_Running
def check_ps(process_list): if process_list is not None: log.debug("Searching for '%s' in running processes..." % process_list) try: for p in process_list: update_spinner() status, process = utils.Is_Process_Running(p) if status is True: for p in process: log.debug("Found: %s (%s)" % (process[p], p)) return True log.debug("Not found") return False finally: cleanup_spinner()
def get_ps_pid(process_name_list): processes_list = {} if process_name_list is not None: log.debug("Searching for '%s' in running processes..." % process_name_list) try: for p in process_name_list: update_spinner() status,processes = utils.Is_Process_Running(p) if status is True: log.debug("Found: %d processes" % len(processes)) for pid in processes: processes_list[pid] =processes[pid] else: log.debug("Not found") finally: cleanup_spinner() return processes_list
mq = device.queryModelByURI(device_uri) if not mq or mq.get('support-type', SUPPORT_TYPE_NONE) == SUPPORT_TYPE_NONE: log.error("Unsupported printer model.") sys.exit(1) plugin = mq.get('plugin', PLUGIN_NONE) if plugin == PLUGIN_NONE: log.debug("This is not a plugin device.") sys.exit() if not Plugin_option_Enabled: Systray_Msg_Enabled = True # checking whether HP-systray is running or not. Invokes, if systray is not running Systray_Is_Running = False status, output = utils.Is_Process_Running('hp-systray') if status is False: if os.getuid() == 0: log.error( " hp-systray must be running.\n Run \'hp-systray &\' in a terminal. " ) else: log.info("Starting hp-systray service") services.run_systray() status, output = utils.Is_Process_Running('hp-systray') if status == True: Systray_Is_Running = True log.debug("hp-systray service is running\n") pluginObj = pluginhandler.PluginHandle()
"Recommended to install latesr version of HPLIP-%s" % HPLIP_latest_ver) clean_exit(0, False) else: log.info("Latest version of HPLIP is already installed.") clean_exit(0, False) # check distro information. if not core.is_auto_installer_support(): log.info( "Please install HPLIP manually as mentioned in 'http://hplipopensource.com/hplip-web/install/manual/index.html' site" ) clean_exit(0) # check systray is running? status, output = utils.Is_Process_Running('hp-systray') if status is True: ok, choice = tui.enter_choice( "\nSome HPLIP applications are running. Press 'y' to close applications or press 'n' to quit upgrade(y=yes*, n=no):", ['y', 'n'], 'y') if not ok or choice == 'n': log.info( "Manually close HPLIP applications and run hp-upgrade again." ) clean_exit(0, False) try: # dBus #import dbus from dbus import SystemBus, lowlevel except ImportError: