1#!/usr/local/bin/python3.8 2# -*- coding: utf-8 -*- 3# 4# (c) Copyright 2003-2015 HP Development Company, L.P. 5# 6# This program is free software; you can redistribute it and/or modify 7# it under the terms of the GNU General Public License as published by 8# the Free Software Foundation; either version 2 of the License, or 9# (at your option) any later version. 10# 11# This program is distributed in the hope that it will be useful, 12# but WITHOUT ANY WARRANTY; without even the implied warranty of 13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14# GNU General Public License for more details. 15# 16# You should have received a copy of the GNU General Public License 17# along with this program; if not, write to the Free Software 18# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19# 20# Author: Don Welch 21# 22 23__version__ = '1.1' 24__title__ = 'Wifi Configuration Utility' 25__mod__ = 'hp-wificonfig' 26__doc__ = "Wifi/Wireless/802.11 configuration utility for HPLIP supported printers. (Note: Only select wireless capable printers are supported by this utility)." 27 28#Std Lib 29import sys 30import re 31import getopt 32import time 33import operator 34import os 35 36# Local 37from base.g import * 38from base import device, utils, maint, tui, module 39from prnt import cups 40 41try: 42 from importlib import import_module 43except ImportError as e: 44 log.debug(e) 45 from base.utils import dyn_import_mod as import_module 46 47 48try: 49 mod = module.Module(__mod__, __title__, __version__, __doc__, None, 50 (GUI_MODE,), (UI_TOOLKIT_QT4, UI_TOOLKIT_QT5)) 51 52 mod.setUsage(module.USAGE_FLAG_NONE, 53 see_also_list=['hp-setup']) 54 55 opts, device_uri, printer_name, mode, ui_toolkit, lang = \ 56 mod.parseStdOpts() 57#Commented as device_uri returned here is not used to configure the device currently 58 #device_uri = mod.getDeviceUri(device_uri, printer_name, 59 # filter={'wifi-config': (operator.gt, 0)}, 60 # restrict_to_installed_devices=False) 61 62 device_uri = None 63 if not utils.canEnterGUIMode4(): 64 log.error("%s -u/--gui requires Qt4 GUI support. Exiting." % __mod__) 65 sys.exit(1) 66 67 # try: 68 # from PyQt4.QtGui import QApplication 69 # from ui4.wifisetupdialog import WifiSetupDialog 70 # except ImportError: 71 # log.error("Unable to load Qt4 support. Is it installed?") 72 # sys.exit(1) 73 74 QApplication, ui_package = utils.import_dialog(ui_toolkit) 75 ui = import_module(ui_package + ".wifisetupdialog") 76 77 app = QApplication(sys.argv) 78 dlg = ui.WifiSetupDialog(None, device_uri, standalone=True) 79 dlg.show() 80 try: 81 log.debug("Starting GUI loop...") 82 app.exec_() 83 except KeyboardInterrupt: 84 sys.exit(0) 85 86except KeyboardInterrupt: 87 log.error("User exit") 88 89log.info("") 90log.info("Done.") 91 92