2 # -*- coding: utf-8 -*-
4 # (c) Copyright 2003-2009 Hewlett-Packard Development Company, L.P.
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.
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.
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
25 __title__ = 'Printer/Fax Setup Utility'
27 __doc__ = "Installs HPLIP printers and faxes in the CUPS spooler. Tries to automatically determine the correct PPD file to use. Allows the printing of a testpage. Performs basic fax parameter setup."
45 from base import device, utils, tui, models, module
50 def plugin_download_callback(c, s, t):
51 pm.update(int(100*c*s/t),
52 utils.format_bytes(c*s))
55 nickname_pat = re.compile(r'''\*NickName:\s*\"(.*)"''', re.MULTILINE)
57 USAGE = [ (__doc__, "", "name", True),
58 ("Usage: %s [MODE] [OPTIONS] [SERIAL NO.|USB bus:device|IP|DEVNODE]" % __mod__, "", "summary", True),
61 utils.USAGE_INTERACTIVE_MODE,
64 ("Automatic mode:", "-a or --auto (-i mode only)", "option", False),
65 ("To specify the port on a multi-port JetDirect:", "--port=<port> (Valid values are 1\*, 2, and 3. \*default)", "option", False),
66 ("No testpage in automatic mode:", "-x (-i mode only)", "option", False),
67 ("To specify a CUPS printer queue name:", "-p<printer> or --printer=<printer> (-i mode only)", "option", False),
68 ("To specify a CUPS fax queue name:", "-f<fax> or --fax=<fax> (-i mode only)", "option", False),
69 ("Type of queue(s) to install:", "-t<typelist> or --type=<typelist>. <typelist>: print*, fax\* (\*default) (-i mode only)", "option", False),
70 ("To specify the device URI to install:", "-d<device> or --device=<device> (--qt4 mode only)", "option", False),
71 ("Remove printers or faxes instead of setting-up:", "-r or --rm or --remove (-u only)", "option", False),
73 utils.USAGE_LOGGING1, utils.USAGE_LOGGING2, utils.USAGE_LOGGING3,
75 ("[SERIAL NO.|USB ID|IP|DEVNODE]", "", "heading", False),
76 ("USB bus:device (usb only):", """"xxx:yyy" where 'xxx' is the USB bus and 'yyy' is the USB device. (Note: The ':' and all leading zeros must be present.)""", 'option', False),
77 ("", "Use the 'lsusb' command to obtain this information.", "option", False),
78 ("IPs (network only):", 'IPv4 address "a.b.c.d" or "hostname"', "option", False),
79 ("DEVNODE (parallel only):", '"/dev/parportX", X=0,1,2,...', "option", False),
80 ("SERIAL NO. (usb and parallel only):", '"serial no."', "option", True),
82 ("Setup using GUI mode:", "$ hp-setup", "example", False),
83 ("Setup using GUI mode, specifying usb:", "$ hp-setup -b usb", "example", False),
84 ("Setup using GUI mode, specifying an IP:", "$ hp-setup 192.168.0.101", "example", False),
85 ("One USB printer attached, automatic:", "$ hp-setup -i -a", "example", False),
86 ("USB, IDs specified:", "$ hp-setup -i 001:002", "example", False),
87 ("Network:", "$ hp-setup -i 66.35.250.209", "example", False),
88 ("Network, Jetdirect port 2:", "$ hp-setup -i --port=2 66.35.250.209", "example", False),
89 ("Parallel:", "$ hp-setup -i /dev/parport0", "example", False),
90 ("USB or parallel, using serial number:", "$ hp-setup -i US12345678A", "example", False),
91 ("USB, automatic:", "$ hp-setup -i --auto 001:002", "example", False),
92 ("Parallel, automatic, no testpage:", "$ hp-setup -i -a -x /dev/parport0", "example", False),
93 ("Parallel, choose device:", "$ hp-setup -i -b par", "example", False),
96 ("1. If no serial number, USB ID, IP, or device node is specified, the USB and parallel busses will be probed for devices.", "", 'note', False),
97 ("2. Using 'lsusb' to obtain USB IDs: (example)", "", 'note', False),
98 (" $ lsusb", "", 'note', False),
99 (" Bus 003 Device 011: ID 03f0:c202 Hewlett-Packard", "", 'note', False),
100 (" $ hp-setup --auto 003:011", "", 'note', False),
101 (" (Note: You may have to run 'lsusb' from /sbin or another location. Use '$ locate lsusb' to determine this.)", "", 'note', True),
102 ("3. Parameters -a, -f, -p, or -t are not valid in GUI (-u) mode.", "", 'note', True),
105 ("hp-makeuri", "", "seealso", False),
106 ("hp-probe", "", "seealso", False),
110 def showPasswordUI(prompt):
113 print log.bold(prompt)
114 username = raw_input("Username: ")
115 password = getpass.getpass("Password: ")
117 return (username, password)
121 if os.path.exists('/etc/init.d/cups'):
122 return '/etc/init.d/cups restart'
124 elif os.path.exists('/etc/init.d/cupsys'):
125 return '/etc/init.d/cupsys restart'
128 return 'killall -HUP cupsd'
131 mod = module.Module(__mod__, __title__, __version__, __doc__, USAGE,
132 (INTERACTIVE_MODE, GUI_MODE),
133 (UI_TOOLKIT_QT3, UI_TOOLKIT_QT4),
136 opts, device_uri, printer_name, mode, ui_toolkit, loc = \
137 mod.parseStdOpts('axp:P:f:t:b:d:rq',
138 ['ttl=', 'filter=', 'search=', 'find=',
139 'method=', 'time-out=', 'timeout=',
140 'printer=', 'fax=', 'type=', 'port=',
141 'auto', 'device=', 'rm', 'remove'],
142 handle_device_printer=False)
144 selected_device_name = None
152 testpage_in_auto_mode = True
155 ignore_plugin_check = False
159 testpage_in_auto_mode = False
161 elif o in ('-P', '-p', '--printer'):
164 elif o in ('-f', '--fax'):
167 elif o in ('-d', '--device'):
170 elif o in ('-b', '--bus'):
171 bus = [x.lower().strip() for x in a.split(',')]
172 if not device.validateBusList(bus, False):
173 mod.usage(error_msg=['Invalid bus name'])
175 elif o in ('-t', '--type'):
176 setup_fax, setup_print = False, False
177 a = a.strip().lower()
178 for aa in a.split(','):
179 if aa.strip() not in ('print', 'fax'):
180 mod.usage(error_msg=['Invalid type.'])
182 if aa.strip() == 'print':
185 elif aa.strip() == 'fax':
186 if not prop.fax_build:
187 log.error("Cannot enable fax setup - HPLIP not built with fax enabled.")
195 #log.error("Invalid port number. Must be between 1 and 3 inclusive.")
196 mod.usage(error_msg=['Invalid port number. Must be between 1 and 3 inclusive.'])
198 elif o in ('-a', '--auto'):
201 elif o in ('-r', '--rm', '--remove'):
204 ignore_plugin_check = True
212 log.debug("param=%s" % param)
214 if printer_name is not None:
215 selected_device_name = printer_name
217 if fax_name is not None:
218 selected_device_name = fax_name
219 log.debug("selected_device_name=%s" % selected_device_name)
222 if selected_device_name is not None:
223 log.warning("-p or -f option is not supported")
224 if ui_toolkit == 'qt3':
225 if not utils.canEnterGUIMode():
226 log.error("%s requires GUI support (try running with --qt4). Also, try using interactive (-i) mode." % __mod__)
229 if not utils.canEnterGUIMode4():
230 log.error("%s requires GUI support (try running with --qt3). Also, try using interactive (-i) mode." % __mod__)
234 if ui_toolkit == 'qt3':
237 from ui import setupform
239 log.error("Unable to load Qt3 support. Is it installed?")
243 log.warn("-r/--rm/--remove not supported in qt3 mode.")
245 app = QApplication(sys.argv)
246 QObject.connect(app, SIGNAL("lastWindowClosed()"), app, SLOT("quit()"))
249 loc = user_conf.get('ui', 'loc', 'system')
250 if loc.lower() == 'system':
251 loc = str(QTextCodec.locale())
252 log.debug("Using system locale: %s" % loc)
254 if loc.lower() != 'c':
257 l, x = loc.split('.')
258 loc = '.'.join([l, e])
261 loc = '.'.join([loc, e])
263 log.debug("Trying to load .qm file for %s locale." % loc)
264 trans = QTranslator(None)
266 qm_file = 'hplip_%s.qm' % l
267 log.debug("Name of .qm file: %s" % qm_file)
268 loaded = trans.load(qm_file, prop.localization_dir)
271 app.installTranslator(trans)
276 log.debug("Using default 'C' locale")
278 log.debug("Using locale: %s" % loc)
279 QLocale.setDefault(QLocale(loc))
282 locale.setlocale(locale.LC_ALL, locale.normalize(loc))
287 w = setupform.SetupForm(bus, param, jd_port)
289 log.error("Unable to connect to HPLIP I/O. Please (re)start HPLIP and try again.")
299 from PyQt4.QtGui import QApplication, QMessageBox
300 from ui4.setupdialog import SetupDialog
302 log.error("Unable to load Qt4 support. Is it installed?")
305 app = QApplication(sys.argv)
306 log.debug("Sys.argv=%s printer_name=%s param=%s jd_port=%s device_uri=%s remove=%s" % (sys.argv, printer_name, param, jd_port, device_uri, remove))
307 dlg = SetupDialog(None, param, jd_port, device_uri, remove)
310 log.debug("Starting GUI loop...")
312 except KeyboardInterrupt:
316 else: # INTERACTIVE_MODE
319 cups.setPasswordCallback(showPasswordUI)
322 log.error("-r/--rm/--remove not supported in -i mode.")
326 log.info("(Note: Defaults for each question are maked with a '*'. Press <enter> to accept the default.)")
329 # ******************************* MAKEURI
331 device_uri, sane_uri, fax_uri = device.makeURI(param, jd_port)
333 # ******************************* CONNECTION TYPE CHOOSER
334 if not device_uri and bus is None:
335 bus = tui.connection_table()
340 log.info("\nUsing connection type: %s" % bus[0])
344 # ******************************* DEVICE CHOOSER
347 log.debug("\nDEVICE CHOOSER setup_fax=%s, setup_print=%s" % (setup_fax, setup_print))
348 device_uri = mod.getDeviceUri(device_uri, selected_device_name, devices = device.probeDevices(bus))
351 # ******************************* QUERY MODEL AND COLLECT PPDS
352 log.info(log.bold("\nSetting up device: %s\n" % device_uri))
355 print_uri = device_uri.replace("hpfax:", "hp:")
356 fax_uri = device_uri.replace("hp:", "hpfax:")
358 back_end, is_hp, bus, model, \
359 serial, dev_file, host, zc, port = \
360 device.parseDeviceURI(device_uri)
362 log.debug("Model=%s" % model)
363 mq = device.queryModelByURI(device_uri)
365 if not mq or mq.get('support-type', SUPPORT_TYPE_NONE) == SUPPORT_TYPE_NONE:
366 log.error("Unsupported printer model.")
369 if mq.get('fax-type', FAX_TYPE_NONE) in (FAX_TYPE_NONE, FAX_TYPE_NOT_SUPPORTED) and setup_fax:
370 #log.warning("Cannot setup fax - device does not have fax feature.")
373 # ******************************* PLUGIN
375 norm_model = models.normalizeModelName(model).lower()
376 plugin = mq.get('plugin', PLUGIN_NONE)
378 plugin_installed = utils.to_bool(sys_state.get('plugin', 'installed', '0'))
379 if ignore_plugin_check is False and plugin > PLUGIN_NONE and not plugin_installed:
380 tui.header("PLUG-IN INSTALLATION")
382 hp_plugin = utils.which('hp-plugin')
386 os.system("hp-plugin -i")
388 os.system("hp-plugin")
390 ppds = cups.getSystemPPDs()
392 default_model = utils.xstrip(model.replace('series', '').replace('Series', ''), '_')
393 stripped_model = cups.stripModel2(default_model)
395 installed_print_devices = device.getSupportedCUPSDevices(['hp'])
396 for d in installed_print_devices.keys():
397 for p in installed_print_devices[d]:
398 log.debug("found print queue '%s'" % p)
400 installed_fax_devices = device.getSupportedCUPSDevices(['hpfax'])
401 for d in installed_fax_devices.keys():
402 for f in installed_fax_devices[d]:
403 log.debug("found fax queue '%s'" % f)
405 # ******************************* PRINT QUEUE SETUP
408 tui.header("PRINT QUEUE SETUP")
410 if not auto and print_uri in installed_print_devices:
411 log.warning("One or more print queues already exist for this device: %s." %
412 ', '.join(installed_print_devices[print_uri]))
414 ok, setup_print = tui.enter_yes_no("\nWould you like to install another print queue for this device", 'n')
415 if not ok: sys.exit(0)
419 printer_name = default_model
421 printer_default_model = default_model
423 installed_printer_names = device.getSupportedCUPSPrinterNames(['hp'])
424 # Check for duplicate names
425 if (device_uri in installed_print_devices and printer_default_model in installed_print_devices[device_uri]) \
426 or (printer_default_model in installed_printer_names):
429 t = printer_default_model + "_%d" % i
430 if (t not in installed_printer_names) and(device_uri not in installed_print_devices or t not in installed_print_devices[device_uri]):
431 printer_default_model += "_%d" % i
436 if printer_name is None:
438 printer_name = raw_input(log.bold("\nPlease enter a name for this print queue (m=use model name:'%s'*, q=quit) ?" % printer_default_model))
440 if printer_name.lower().strip() == 'q':
441 log.info("OK, done.")
444 if not printer_name or printer_name.lower().strip() == 'm':
445 printer_name = printer_default_model
449 for d in installed_print_devices.keys():
450 for p in installed_print_devices[d]:
451 if printer_name == p:
452 log.error("A print queue with that name already exists. Please enter a different name.")
456 for d in installed_fax_devices.keys():
457 for f in installed_fax_devices[d]:
458 if printer_name == f:
459 log.error("A fax queue with that name already exists. Please enter a different name.")
463 for c in printer_name:
464 if c in cups.INVALID_PRINTER_NAME_CHARS:
465 log.error("Invalid character '%s' in printer name. Please enter a name that does not contain this character." % c)
471 printer_name = printer_default_model
473 log.info("Using queue name: %s" % printer_name)
475 default_model = utils.xstrip(model.replace('series', '').replace('Series', ''), '_')
476 stripped_model = default_model.lower().replace('hp-', '').replace('hp_', '')
478 log.info("Locating PPD file... Please wait.")
479 print_ppd = cups.getPPDFile2(stripped_model, ppds)
482 if print_ppd is None:
484 log.error("Unable to find an appropriate PPD file.")
487 print_ppd, desc = print_ppd
488 log.info("\nFound PPD file: %s" % print_ppd)
491 log.info("Description: %s" % desc)
494 log.info("\nNote: The model number may vary slightly from the actual model number on the device.")
495 ok, ans = tui.enter_yes_no("\nDoes this PPD file appear to be the correct one")
496 if not ok: sys.exit(0)
497 if not ans: enter_ppd = True
503 ok, enter_ppd = tui.enter_yes_no("\nWould you like to specify the path to the correct PPD file to use", 'n')
504 if not ok: sys.exit(0)
510 user_input = raw_input(log.bold("\nPlease enter the full filesystem path to the PPD file to use (q=quit) :"))
512 if user_input.lower().strip() == 'q':
513 log.info("OK, done.")
516 file_path = user_input
518 if os.path.exists(file_path) and os.path.isfile(file_path):
520 if file_path.endswith('.gz'):
521 nickname = gzip.GzipFile(file_path, 'r').read(4096)
523 nickname = file(file_path, 'r').read(4096)
526 desc = nickname_pat.search(nickname).group(1)
527 except AttributeError:
531 log.info("Description for the file: %s" % desc)
533 log.error("No PPD 'NickName' found. This file may not be a valid PPD file.")
535 ok, ans = tui.enter_yes_no("\nUse this file")
536 if not ok: sys.exit(0)
537 if ans: print_ppd = file_path
540 log.error("File not found or not an appropriate (PPD) file.")
545 log.error("PPD file required. Setup cannot continue. Exiting.")
549 location, info = '', 'Automatically setup by HPLIP'
552 location = raw_input(log.bold("Enter a location description for this printer (q=quit) ?"))
554 if location.strip().lower() == 'q':
555 log.info("OK, done.")
558 # TODO: Validate chars
562 info = raw_input(log.bold("Enter additonal information or notes for this printer (q=quit) ?"))
564 if info.strip().lower() == 'q':
565 log.info("OK, done.")
568 # TODO: Validate chars
571 log.info(log.bold("\nAdding print queue to CUPS:"))
572 log.info("Device URI: %s" % print_uri)
573 log.info("Queue name: %s" % printer_name)
574 log.info("PPD file: %s" % print_ppd)
575 log.info("Location: %s" % location)
576 log.info("Information: %s" % info)
578 log.debug("Restarting CUPS...")
579 status, output = utils.run(restart_cups())
580 log.debug("Restart CUPS returned: exit=%d output=%s" % (status, output))
582 cups.setPasswordPrompt("You do not have permission to add a printer.")
583 if not os.path.exists(print_ppd): # assume foomatic: or some such
584 status, status_str = cups.addPrinter(printer_name.encode('utf8'), print_uri,
585 location, '', print_ppd, info)
587 status, status_str = cups.addPrinter(printer_name.encode('utf8'), print_uri,
588 location, print_ppd, '', info)
590 log.debug("addPrinter() returned (%d, %s)" % (status, status_str))
592 installed_print_devices = device.getSupportedCUPSDevices(['hp'])
594 if print_uri not in installed_print_devices or \
595 printer_name not in installed_print_devices[print_uri]:
597 log.error("Printer queue setup failed. Please restart CUPS and try again.")
602 #service.sendEvent(hpssd_sock, EVENT_CUPS_QUEUES_CHANGED, device_uri=print_uri)
605 # ******************************* FAX QUEUE SETUP
606 if setup_fax and not prop.fax_build:
607 log.error("Cannot setup fax - HPLIP not built with fax enabled.")
615 # This can fail on Python < 2.3 due to the datetime module
617 log.warning("Fax setup disabled - Python 2.3+ required.")
623 tui.header("FAX QUEUE SETUP")
625 if not auto and fax_uri in installed_fax_devices:
626 log.warning("One or more fax queues already exist for this device: %s." % ', '.join(installed_fax_devices[fax_uri]))
627 ok, setup_fax = tui.enter_yes_no("\nWould you like to install another fax queue for this device", 'n')
628 if not ok: sys.exit(0)
631 if auto: # or fax_name is None:
632 fax_name = default_model + '_fax'
634 fax_default_model = default_model + '_fax'
636 installed_fax_names = device.getSupportedCUPSPrinterNames(['hpfax'])
637 # Check for duplicate names
638 if (fax_uri in installed_fax_devices and fax_default_model in installed_fax_devices[fax_uri]) \
639 or (fax_default_model in installed_fax_names):
642 t = fax_default_model + "_%d" % i
643 if (t in installed_fax_names) and (fax_uri not in installed_fax_devices or t not in installed_fax_devices[fax_uri]):
644 fax_default_model += "_%d" % i
651 fax_name = raw_input(log.bold("\nPlease enter a name for this fax queue (m=use model name:'%s'*, q=quit) ?" % fax_default_model))
653 if fax_name.lower().strip() == 'q':
654 log.info("OK, done.")
657 if not fax_name or fax_name.lower().strip() == 'm':
658 fax_name = fax_default_model
662 for d in installed_print_devices.keys():
663 for p in installed_print_devices[d]:
665 log.error("A print queue with that name already exists. Please enter a different name.")
669 for d in installed_fax_devices.keys():
670 for f in installed_fax_devices[d]:
672 log.error("A fax queue with that name already exists. Please enter a different name.")
677 if c in (' ', '#', '/', '%'):
678 log.error("Invalid character '%s' in fax name. Please enter a name that does not contain this character." % c)
685 fax_name = fax_default_model
687 log.info("Using queue name: %s" % fax_name)
689 fax_type = mq.get('fax-type', FAX_TYPE_NONE)
691 if prop.hpcups_build:
692 if fax_type == FAX_TYPE_SOAP or fax_type == FAX_TYPE_LEDMSOAP:
693 fax_ppd_name = 'HP-Fax2-hpcups'
695 fax_ppd_name = 'HP-Fax-hpcups'
697 if fax_type == FAX_TYPE_SOAP or fax_type == FAX_TYPE_LEDMSOAP:
698 fax_ppd_name = 'HP-Fax2-hpijs'
700 fax_ppd_name = 'HP-Fax-hpijs'
703 if f.find(fax_ppd_name) >= 0:
705 log.debug("Found PDD file: %s" % fax_ppd)
708 log.error("Unable to find HP fax PPD file! Please check you HPLIP installation and try again.")
712 location, info = '', 'Automatically setup by HPLIP'
715 location = raw_input(log.bold("Enter a location description for this printer (q=quit) ?"))
717 if location.strip().lower() == 'q':
718 log.info("OK, done.")
721 # TODO: Validate chars
725 info = raw_input(log.bold("Enter additonal information or notes for this printer (q=quit) ?"))
727 if info.strip().lower() == 'q':
728 log.info("OK, done.")
731 # TODO: Validate chars
734 log.info(log.bold("\nAdding fax queue to CUPS:"))
735 log.info("Device URI: %s" % fax_uri)
736 log.info("Queue name: %s" % fax_name)
737 log.info("PPD file: %s" % fax_ppd)
738 log.info("Location: %s" % location)
739 log.info("Information: %s" % info)
741 cups.setPasswordPrompt("You do not have permission to add a fax device.")
742 if not os.path.exists(fax_ppd): # assume foomatic: or some such
743 status, status_str = cups.addPrinter(fax_name.encode('utf8'), fax_uri,
744 location, '', fax_ppd, info)
746 status, status_str = cups.addPrinter(fax_name.encode('utf8'), fax_uri,
747 location, fax_ppd, '', info)
749 log.debug("addPrinter() returned (%d, %s)" % (status, status_str))
751 installed_fax_devices = device.getSupportedCUPSDevices(['hpfax'])
753 log.debug(installed_fax_devices)
755 if fax_uri not in installed_fax_devices or \
756 fax_name not in installed_fax_devices[fax_uri]:
758 log.error("Fax queue setup failed. Please restart CUPS and try again.")
763 #service.sendEvent(hpssd_sock, EVENT_CUPS_QUEUES_CHANGED, device_uri=fax_uri)
766 # ******************************* FAX HEADER SETUP
767 tui.header("FAX HEADER SETUP")
773 user_input = raw_input(log.bold("\nWould you like to perform fax header setup (y=yes*, n=no, q=quit) ?")).strip().lower()
775 if user_input == 'q':
776 log.info("OK, done.")
782 setup_fax = (user_input == 'y')
784 if user_input in ('y', 'n', 'q'):
787 log.error("Please enter 'y' or 'n'")
790 d = fax.getFaxDevice(fax_uri, disable_dbus=True)
795 log.error("Unable to communicate with the device. Please check the device and try again.")
805 current_phone_num = str(d.getPhoneNum())
806 current_station_name = str(d.getStationName())
808 log.error("Could not communicate with device. Device may be busy. Please wait for retry...")
821 if current_phone_num:
822 phone_num = raw_input(log.bold("\nEnter the fax phone number for this device (c=use current:'%s'*, q=quit) ?" % current_phone_num))
824 phone_num = raw_input(log.bold("\nEnter the fax phone number for this device (q=quit) ?"))
825 if phone_num.strip().lower() == 'q':
826 log.info("OK, done.")
829 if current_phone_num and (not phone_num or phone_num.strip().lower() == 'c'):
830 phone_num = current_phone_num
832 if len(phone_num) > 50:
833 log.error("Phone number length is too long (>50 characters). Please enter a shorter number.")
838 if x not in '0123456789-(+) ':
839 log.error("Invalid characters in phone number. Please only use 0-9, -, (, +, and )")
849 if current_station_name:
850 station_name = raw_input(log.bold("\nEnter the name and/or company for this device (c=use current:'%s'*, q=quit) ?" % current_station_name))
852 station_name = raw_input(log.bold("\nEnter the name and/or company for this device (q=quit) ?"))
853 if station_name.strip().lower() == 'q':
854 log.info("OK, done.")
857 if current_station_name and (not station_name or station_name.strip().lower() == 'c'):
858 station_name = current_station_name
861 if len(station_name) > 50:
862 log.error("Name/company length is too long (>50 characters). Please enter a shorter name/company.")
867 d.setStationName(station_name)
868 d.setPhoneNum(phone_num)
870 log.error("Could not communicate with device. Device may be busy.")
872 log.info("\nParameters sent to device.")
877 # ******************************* TEST PAGE
879 print_test_page = False
881 tui.header("PRINTER TEST PAGE")
884 if testpage_in_auto_mode:
885 print_test_page = True
887 ok, print_test_page = tui.enter_yes_no("\nWould you like to print a test page")
888 if not ok: sys.exit(0)
891 path = utils.which('hp-testpage')
894 param = "-p%s" % printer_name
896 param = "-d%s" % print_uri
899 cmd = 'hp-testpage %s' % param
901 cmd = 'python ./testpage.py %s' % param
907 except KeyboardInterrupt:
908 log.error("User exit")