def install_Plugin(systray_running_status, run_directly=False): if run_directly: if not utils.canEnterGUIMode4(): log.error("%s requires GUI support . Is Qt4 installed?" % __mod__) sys.exit(1) try: from PyQt4.QtGui import QApplication, QMessageBox from ui4.plugindiagnose import PluginDiagnose from installer import core_install except ImportError: log.error("Unable to load Qt4 support. Is it installed?") sys.exit(1) app = QApplication(sys.argv) plugin = PLUGIN_REQUIRED plugin_reason = PLUGIN_REASON_NONE ok, sudo_ok = pkit.run_plugin_command(plugin == PLUGIN_REQUIRED, plugin_reason) if not ok or not sudo_ok: log.error("Failed to install plug-in.") elif systray_running_status: send_message( device_uri, "", EVENT_AUTO_CONFIGURE, username, 0, "AutoConfig") log.debug("Event EVENT_AUTO_CONFIGURE sent to hp-systray to invoke hp-plugin") else: log.error("Run hp-systray manually and re-plugin printer")
def install_Plugin(systray_running_status, run_directly=False): if run_directly: if not utils.canEnterGUIMode4(): log.error("%s requires GUI support . Is Qt4 installed?" % __mod__) sys.exit(1) try: from PyQt4.QtGui import QApplication, QMessageBox from ui4.plugindiagnose import PluginDiagnose from installer import core_install except ImportError: log.error("Unable to load Qt4 support. Is it installed?") sys.exit(1) app = QApplication(sys.argv) plugin = PLUGIN_REQUIRED plugin_reason = PLUGIN_REASON_NONE ok, sudo_ok = pkit.run_plugin_command(plugin == PLUGIN_REQUIRED, plugin_reason) if not ok or not sudo_ok: log.error("Failed to install plug-in.") elif systray_running_status: send_message(device_uri, "", EVENT_AUTO_CONFIGURE, username, 0, "AutoConfig") log.debug( "Event EVENT_AUTO_CONFIGURE sent to hp-systray to invoke hp-plugin" ) else: log.error("Run hp-systray manually and re-plugin printer")
try: mod = module.Module(__mod__, __title__, __version__, __doc__, None, (GUI_MODE,), (UI_TOOLKIT_QT4,)) mod.setUsage(module.USAGE_FLAG_DEVICE_ARGS, see_also_list=['hp-align', 'hp-clean', 'hp-colorcal', 'hp-pqdiag']) opts, device_uri, printer_name, mode, ui_toolkit, lang = \ mod.parseStdOpts() device_uri = mod.getDeviceUri(device_uri, printer_name, filter={'linefeed-cal-type': (operator.gt, 0)}) if not utils.canEnterGUIMode4(): log.error("%s -u/--gui requires Qt4 GUI support. Exiting." % __mod__) sys.exit(1) try: from PyQt4.QtGui import QApplication from ui4.linefeedcaldialog import LineFeedCalDialog except ImportError: log.error("Unable to load Qt4 support. Is it installed?") sys.exit(1) #try: if 1: app = QApplication(sys.argv)
if printer_name is not None: selected_device_name = printer_name else: if fax_name is not None: selected_device_name = fax_name log.debug("selected_device_name=%s" % selected_device_name) if mode == GUI_MODE: if selected_device_name is not None: log.warning("-p or -f option is not supported") if ui_toolkit == 'qt3': if not utils.canEnterGUIMode(): log.error("%s requires GUI support (try running with --qt4). Also, try using interactive (-i) mode." % __mod__) clean_exit(1) else: if not utils.canEnterGUIMode4(): log.error("%s requires GUI support (try running with --qt3). Also, try using interactive (-i) mode." % __mod__) clean_exit(1) if mode == GUI_MODE: if ui_toolkit == 'qt3': try: from qt import * from ui import setupform except ImportError: log.error("Unable to load Qt3 support. Is it installed?") clean_exit(1) if remove: log.warn("-r/--rm/--remove not supported in qt3 mode.")
def disable(mode, ui_toolkit='qt4', dialog=None, app=None, passwordObj = None): dev_list = get_smartinstall_enabled_devices() if not dev_list: log.debug("No Smart Install Device found") return ERROR_NO_SI_DEVICE, queryString(ERROR_NO_SI_DEVICE) return_val = ERROR_FAILED_TO_DISABLE_SI return_error_str = queryString(ERROR_FAILED_TO_DISABLE_SI) url, file_name = get_SmartInstall_tool_info() printer_names = utils.list_to_string(dev_list) try: if mode == GUI_MODE: if ui_toolkit == 'qt3': try: from ui.setupform import FailureMessageUI except ImportError: log.error("Smart Install is enabled in %s device(s).\nAuto Smart Install disable is not supported in QT3.\nPlease refer link \'%s\' to disable manually"%(printer_names,url)) else: FailureMessageUI("Smart Install is enabled in %s device(s).\n\nAuto Smart Install disable is not supported in QT3.\nPlease refer link \'%s\' to disable manually"%(printer_names,url)) else: #qt4 if not utils.canEnterGUIMode4(): log.error("%s requires GUI support . Is Qt4 installed?" % __mod__) return ERROR_FAILED_TO_DISABLE_SI, queryString(ERROR_FAILED_TO_DISABLE_SI) if dialog and app: # If QT app already opened, re-using same object dialog.init(printer_names, "", QUEUES_SMART_INSTALL_ENABLED) else: # If QT object is not created, creating QT app try: from ui4.queuesconf import QueuesDiagnose except ImportError: log.error("Unable to load Qt4 support. Is it installed?") else: # app = QApplication(sys.argv) # caller needs to inoke this, if already QApplication object is not created. dialog = QueuesDiagnose(None, printer_names ,"",QUEUES_SMART_INSTALL_ENABLED) log.debug("Starting GUI loop...") dialog.exec_() if check_SmartInstall(): dialog.showMessage("Failed to disable smart install.\nPlease refer link \'%s\' for more information" %url) else: dialog.showSuccessMessage("Smart install disabled successfully.") #Interaction mode else: log.error("Smart Install is enabled in %s device(s). "%printer_names) response, value = tui.enter_choice("Do you want to download and disable smart install?(y=yes*, n=no):",['y', 'n'], 'y') if not response or value != 'y': #User exit return_val = ERROR_FAILED_TO_DISABLE_SI return_error_str = queryString(ERROR_FAILED_TO_DISABLE_SI) else: sts, smart_install_run, smart_install_asc, error_str = download(mode, passwordObj) disable_si = False return_val = sts if sts == ERROR_SUCCESS: disable_si = True elif sts in (ERROR_UNABLE_TO_RECV_KEYS, ERROR_DIGITAL_SIGN_NOT_FOUND): response, value = tui.enter_yes_no("Digital Sign verification failed, Do you want to continue?") if not response or not value: sys.exit(0) else: # Continue without validation succes. disable_si = True else: return_error_str = queryString(sts) if disable_si: sts, out = utils.run("sh %s"%smart_install_run) # Once smart install disabler installation completed, cross verifying to ensure no smart install devices found if sts or check_SmartInstall(): log.error("Failed to disable smart install .") log.error("Please refer link \'%s\' to disable manually"%url) return_val = ERROR_FAILED_TO_DISABLE_SI return_error_str = queryString(ERROR_FAILED_TO_DISABLE_SI) else: log.info("Smart install disabled successfully.") return_val = ERROR_SUCCESS return_error_str = "" except KeyboardInterrupt: log.error("User exit") sys.exit(0) return return_val ,return_error_str
def disable(mode, ui_toolkit='qt4', dialog=None, app=None, passwordObj=None): dev_list = get_smartinstall_enabled_devices() if not dev_list: log.debug("No Smart Install Device found") return ERROR_NO_SI_DEVICE, queryString(ERROR_NO_SI_DEVICE) return_val = ERROR_FAILED_TO_DISABLE_SI return_error_str = queryString(ERROR_FAILED_TO_DISABLE_SI) url, file_name = get_SmartInstall_tool_info() printer_names = utils.list_to_string(dev_list) try: if mode == GUI_MODE: if ui_toolkit == 'qt3': try: from ui.setupform import FailureMessageUI except ImportError: log.error( "Smart Install is enabled in %s device(s).\nAuto Smart Install disable is not supported in QT3.\nPlease refer link \'%s\' to disable manually" % (printer_names, url)) else: FailureMessageUI( "Smart Install is enabled in %s device(s).\n\nAuto Smart Install disable is not supported in QT3.\nPlease refer link \'%s\' to disable manually" % (printer_names, url)) else: #qt4 if not utils.canEnterGUIMode4(): log.error("%s requires GUI support . Is Qt4 installed?" % __mod__) return ERROR_FAILED_TO_DISABLE_SI, queryString( ERROR_FAILED_TO_DISABLE_SI) if dialog and app: # If QT app already opened, re-using same object dialog.init(printer_names, "", QUEUES_SMART_INSTALL_ENABLED) else: # If QT object is not created, creating QT app try: from ui4.queuesconf import QueuesDiagnose except ImportError: log.error( "Unable to load Qt4 support. Is it installed?") else: # app = QApplication(sys.argv) # caller needs to inoke this, if already QApplication object is not created. dialog = QueuesDiagnose(None, printer_names, "", QUEUES_SMART_INSTALL_ENABLED) log.debug("Starting GUI loop...") dialog.exec_() if check_SmartInstall(): dialog.showMessage( "Failed to disable smart install.\nPlease refer link \'%s\' for more information" % url) else: dialog.showSuccessMessage( "Smart install disabled successfully.") #Interaction mode else: log.error("Smart Install is enabled in %s device(s). " % printer_names) response, value = tui.enter_choice( "Do you want to download and disable smart install?(y=yes*, n=no):", ['y', 'n'], 'y') if not response or value != 'y': #User exit return_val = ERROR_FAILED_TO_DISABLE_SI return_error_str = queryString(ERROR_FAILED_TO_DISABLE_SI) else: sts, smart_install_run, smart_install_asc, error_str = download( mode, passwordObj) disable_si = False return_val = sts if sts == ERROR_SUCCESS: disable_si = True elif sts in (ERROR_UNABLE_TO_RECV_KEYS, ERROR_DIGITAL_SIGN_NOT_FOUND): response, value = tui.enter_yes_no( "Digital Sign verification failed, Do you want to continue?" ) if not response or not value: sys.exit(0) else: # Continue without validation succes. disable_si = True else: return_error_str = queryString(sts) if disable_si: sts, out = utils.run("sh %s" % smart_install_run) # Once smart install disabler installation completed, cross verifying to ensure no smart install devices found if sts or check_SmartInstall(): log.error("Failed to disable smart install .") log.error( "Please refer link \'%s\' to disable manually" % url) return_val = ERROR_FAILED_TO_DISABLE_SI return_error_str = queryString( ERROR_FAILED_TO_DISABLE_SI) else: log.info("Smart install disabled successfully.") return_val = ERROR_SUCCESS return_error_str = "" except KeyboardInterrupt: log.error("User exit") sys.exit(0) return return_val, return_error_str