コード例 #1
0
ファイル: levels.py プロジェクト: super11/hplip
    log.info("%s%s%s%s (approx. %d%%)%s" %
             ("|", bar_char * bar, " " *
              (size - bar - 2), "|", agent_level, color))

    color = ''
    if use_colors:
        color = log.codes['reset']

    log.info(("-" * size) + color)


log.set_module('hp-levels')

try:
    mod = module.Module(__mod__, __title__, __version__, __doc__, None,
                        (INTERACTIVE_MODE, ))

    mod.setUsage(module.USAGE_FLAG_DEVICE_ARGS,
                 extra_options=[
                     ("Bar graph size:",
                      "-s<size> or --size=<size> (current default=%d)" %
                      DEFAULT_BAR_GRAPH_SIZE, "option", False),
                     ("Use colored bar graphs:",
                      "-c or --color (default is colorized)", "option", False),
                     ("Bar graph character:",
                      "-a<char> or --char=<char> (default is '/')", "option",
                      False)
                 ])


    opts, device_uri, printer_name, mode, ui_toolkit, lang = \
コード例 #2
0
from base import utils, device, tui, module
from prnt import cups

log.set_module('hp-print')

try:
    from importlib import import_module
except ImportError as e:
    log.debug(e)
    from base.utils import dyn_import_mod as import_module

app = None
printdlg = None

mod = module.Module(__mod__, __title__, __version__, __doc__, None,
                    (GUI_MODE, ),
                    (UI_TOOLKIT_QT3, UI_TOOLKIT_QT4, UI_TOOLKIT_QT5))

mod.setUsage(module.USAGE_FLAG_DEVICE_ARGS | module.USAGE_FLAG_FILE_ARGS,
             see_also_list=['hp-printsettings'])

opts, device_uri, printer_name, mode, ui_toolkit, loc = \
    mod.parseStdOpts()

sts, printer_name, device_uri = mod.getPrinterName(printer_name, device_uri)
if not sts:
    sys.exit(1)

if ui_toolkit == 'qt3':
    if not utils.canEnterGUIMode():
        log.error(
コード例 #3
0
ファイル: setup.py プロジェクト: dhirajpatra/lti_tool
          ("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),
          ("2. Using 'lsusb' to obtain USB IDs: (example)", "", 'note', False),
          ("   $ lsusb", "", 'note', False),
          ("         Bus 003 Device 011: ID 03f0:c202 Hewlett-Packard", "", 'note', False),
          ("   $ hp-setup --auto 003:011", "", 'note', False),
          ("   (Note: You may have to run 'lsusb' from /sbin or another location. Use '$ locate lsusb' to determine this.)", "", 'note', True),
          ("3. Parameters -a, -f, -p, or -t are not valid in GUI (-u) mode.", "", 'note', True),
          utils.USAGE_SPACE,
          utils.USAGE_SEEALSO,
          ("hp-makeuri", "", "seealso", False),
          ("hp-probe", "", "seealso", False),
        ]


mod = module.Module(__mod__, __title__, __version__, __doc__, USAGE,
                    (INTERACTIVE_MODE, GUI_MODE),
                    (UI_TOOLKIT_QT3, UI_TOOLKIT_QT4, UI_TOOLKIT_QT5),
                    run_as_root_ok=True)

opts, device_uri, printer_name, mode, ui_toolkit, loc = \
    mod.parseStdOpts('axp:P:f:t:b:d:rq',
                     ['ttl=', 'filter=', 'search=', 'find=',
                      'method=', 'time-out=', 'timeout=',
                      'printer=', 'fax=', 'type=', 'port=',
                       'auto', 'device=', 'rm', 'remove'],
                      handle_device_printer=False)

selected_device_name = None
printer_name = None
fax_name = None
bus = None
setup_print = True
コード例 #4
0
ファイル: unload.py プロジェクト: csteacherd22/hplip
    def do_about(self, args):
        utils.log_title(__title__, __version__)


def status_callback(src, trg, size):
    if size == 1:
        print()
        print(log.bold("Copying %s..." % src))
    else:
        print("\nCopied %s to %s (%s)..." %
              (src, trg, utils.format_bytes(size)))


mod = module.Module(__mod__, __title__, __version__, __doc__, None,
                    (GUI_MODE, INTERACTIVE_MODE, NON_INTERACTIVE_MODE),
                    (UI_TOOLKIT_QT3, ), False, False, True)

mod.setUsage(
    module.USAGE_FLAG_DEVICE_ARGS,
    extra_options=
    [("Output directory:",
      "-o<dir> or --output=<dir> (Defaults to current directory)(Only used for non-GUI modes)",
      "option", False)],
    see_also_list=['hp-toolbox'])

opts, device_uri, printer_name, mode, ui_toolkit, loc = \
    mod.parseStdOpts('o', ['output='])

from pcard import photocard
コード例 #5
0
    else:
        log.note(msg)

    log.info("Press enter 'q' to quit or <enter> to do a level 3 cleaning.")
    log.warn("Level 3 uses a lot of ink.")
    return CleanUIx(3)

def CleanUI3(msg =""):
    if msg:
        log.info(msg)
    else:
        log.info("\nLevel 3 cleaning complete. Check this page to see if the problem was fixed. If the test page was not printed OK, replace the print cartridge(s).")


try:
    mod = module.Module(__mod__, __title__, __version__, __doc__, None,
                        (INTERACTIVE_MODE, GUI_MODE), (UI_TOOLKIT_QT4,))

    mod.setUsage(module.USAGE_FLAG_DEVICE_ARGS,
                 see_also_list=['hp-align', 'hp-clean', 'hp-linefeedcal',
                                'hp-pqdiag'])

    opts, device_uri, printer_name, mode, ui_toolkit, lang = \
        mod.parseStdOpts()

    device_uri = mod.getDeviceUri(device_uri, printer_name,
       filter={'clean-type': (operator.ne, CLEAN_TYPE_NONE)})

    if mode == GUI_MODE:
        if not utils.canEnterGUIMode4():
            log.error("%s -u/--gui requires Qt4 GUI support. Entering interactive mode." % __mod__)
            mode = INTERACTIVE_MODE
コード例 #6
0
try:
    from importlib import import_module
except ImportError as e:
    log.debug(e)
    from base.utils import dyn_import_mod as import_module


username = prop.username
faxnum_list = []
recipient_list = []
group_list = []
prettyprint = False

mod = module.Module(__mod__, __title__, __version__, __doc__, None,
                    (GUI_MODE, NON_INTERACTIVE_MODE),
                    (UI_TOOLKIT_QT3, UI_TOOLKIT_QT4, UI_TOOLKIT_QT5))

mod.setUsage(module.USAGE_FLAG_DEVICE_ARGS | module.USAGE_FLAG_SUPRESS_G_DEBUG_FLAG,
    extra_options=[
    ("Specify the fax number(s):", "-f<number(s)> or --faxnum=<number(s)> or --fax-num=<number(s)>  or --num=<number(s)>(-n only)", "option", False),
    ("Specify the recipient(s):", "-r<recipient(s)> or --recipient=<recipient(s)> (-n only)", "option", False),
    ("Specify the groups(s):", "--group=<group(s)> or --groups=<group(s)> (-n only)", "option", False) ],
    see_also_list=['hp-faxsetup', 'hp-fab'])

opts, device_uri, printer_name, mode, ui_toolkit, loc = \
    mod.parseStdOpts('f:r:g:',
                     ['faxnum=', 'fax-num=', 'recipient=', 'group=',
                      'groups=', 'gg'],
                      supress_g_debug_flag=True)
コード例 #7
0
#Std Lib
import sys
import re
import getopt
import time
import operator
import os

# Local
from base.g import *
from base import device, utils, maint, tui, module
from prnt import cups


try:
    mod = module.Module(__mod__, __title__, __version__, __doc__, None,
                        (GUI_MODE,), (UI_TOOLKIT_QT4,), False, False, True)

    mod.setUsage(module.USAGE_FLAG_DEVICE_ARGS,
                 see_also_list=['hp-align', 'hp-clean', 'hp-colorcal',
                                'hp-linefeedcal'])

    opts, device_uri, printer_name, mode, ui_toolkit, lang = \
        mod.parseStdOpts()

    device_uri = mod.getDeviceUri(device_uri, printer_name)

    if not device_uri:
        sys.exit(1)
    log.info("Using device : %s\n" % device_uri)
    if not utils.canEnterGUIMode4():
        log.error("%s -u/--gui requires Qt4 GUI support. Exiting." % __mod__)
コード例 #8
0
ファイル: pkservice.py プロジェクト: dhirajpatra/lti_tool
    (__doc__, "", "name", True),
    ("Usage: %s [MODE] [OPTIONS]" % __mod__, "", "summary", True),
    utils.USAGE_MODE,
    utils.USAGE_INTERACTIVE_MODE,
    utils.USAGE_LANGUAGE,
    utils.USAGE_OPTIONS,
    utils.USAGE_LOGGING1,
    utils.USAGE_LOGGING2,
    utils.USAGE_LOGGING3,
    utils.USAGE_HELP,
    utils.USAGE_SPACE,
]

mod = module.Module(__mod__,
                    __title__,
                    __version__,
                    __doc__,
                    USAGE, (INTERACTIVE_MODE, ),
                    run_as_root_ok=True)

mod.setUsage(module.USAGE_FLAG_NONE,
             extra_options=[
                 utils.USAGE_SPACE,
                 ("[OPTIONS] (General)", "", "header", False),
                 ("PolicyKit version:", "-v<version> or --version=<version>",
                  "option", False)
             ])

opts, device_uri, printer_name, mode, ui_toolkit, loc = \
    mod.parseStdOpts('v:', ["version="])

user_pkit_version = None
コード例 #9
0
ファイル: diagnose_plugin.py プロジェクト: Distrotech/hplip
    (__doc__, "", "name", True),
    ("Usage: %s [OPTIONS]" % __mod__, "", "summary", True),
    utils.USAGE_OPTIONS,
    utils.USAGE_LOGGING1,
    utils.USAGE_LOGGING2,
    utils.USAGE_LOGGING3,
    utils.USAGE_HELP,
    utils.USAGE_SPACE,
    utils.USAGE_SEEALSO,
    ("hp-plugin", "", "seealso", False),
    ("hp-setup", "", "seealso", False),
    ("hp-firmware", "", "seealso", False),
]

mod = module.Module(__mod__, __title__, __version__, __doc__, USAGE,
                    (INTERACTIVE_MODE, GUI_MODE),
                    (UI_TOOLKIT_QT3, UI_TOOLKIT_QT4), True)

opts, device_uri, printer_name, mode, ui_toolkit, loc = \
    mod.parseStdOpts( handle_device_printer=False)

plugin_path = None
install_mode = PLUGIN_REQUIRED
plugin_reason = PLUGIN_REASON_NONE

if mode == GUI_MODE:
    if ui_toolkit == 'qt3':
        log.error("Unable to load Qt3. Please use Qt4")

    else:  #qt4
        if not utils.canEnterGUIMode4():
コード例 #10
0
ファイル: makeuri.py プロジェクト: csteacherd22/hplip
     "example", False),
    utils.USAGE_SPACE,
    utils.USAGE_NOTES,
    ("1. Example using 'lsusb' to obtain USB bus ID and USB device ID (example only, the values you obtain will differ) :",
     "", 'note', False),
    ("   $ lsusb", "", 'note', False),
    ("   Bus 003 Device 011: ID 03f0:c202 Hewlett-Packard", "", 'note', False),
    ("   $ hp-makeuri 003:011", "", 'note', False),
    ("   (Note: You may have to run 'lsusb' from /sbin or another location. Use '$ locate lsusb' to determine this.)",
     "", 'note', True),
    utils.USAGE_SPACE,
    utils.USAGE_SEEALSO,
    ("hp-setup", "", "seealso", False),
]

mod = module.Module(__mod__, __title__, __version__, __doc__, USAGE,
                    (INTERACTIVE_MODE, ), None, True, True)

opts, device_uri, printer_name, mode, ui_toolkit, lang = \
    mod.parseStdOpts('p:csf', ['port', 'cups', 'sane', 'fax'],
                     handle_device_printer=False)

try:
    cups_quiet_mode = False
    sane_quiet_mode = False
    fax_quiet_mode = False
    jd_port = 1

    for o, a in opts:
        if o in ('-c', '--cups'):
            cups_quiet_mode = True
コード例 #11
0
ファイル: query.py プロジェクト: csteacherd22/hplip
__title__ = 'Model Query Utility'
__mod__ = 'hp-query'
__doc__ = "Query a printer model for static model information. Designed to be called from other processes."

# Std Lib
import sys

# Local
from base.g import *
from base import device, models, module

try:

    mod = module.Module(__mod__,
                        __title__,
                        __version__,
                        __doc__,
                        None, (NON_INTERACTIVE_MODE, ),
                        quiet=True)

    mod.setUsage(
        0,
        extra_options=[
            ("Specify model by device URI:",
             "-d<device_uri> or --device=<device_uri>", "option", False),
            ("Specify normalized model name:",
             "-m<model_name> or --model=<model_name> (normalized models.dat format)",
             "option", False),
            ("Specify raw model name:",
             "-r<model_name> or --raw=<model_name> (raw model name from MDL: field of device ID)",
             "option", False),
            ("Specify key to query:",
コード例 #12
0
try:
    from importlib import import_module
except ImportError as e:
    log.debug(e)
    from base.utils import dyn_import_mod as import_module

try:
    restrict = True

    devid_mode = '--id' in sys.argv  # hack
    if devid_mode:
        log.set_level("none")

    mod = module.Module(__mod__, __title__, __version__, __doc__, None,
                        (INTERACTIVE_MODE, GUI_MODE),
                        (UI_TOOLKIT_QT4, UI_TOOLKIT_QT5), False, devid_mode)

    mod.setUsage(
        module.USAGE_FLAG_DEVICE_ARGS,
        extra_options=
        [("Device ID mode:",
          "--id (prints device ID only and exits.) (interactive (-i) mode only.)",
          "option", False),
         ("Allow device URIs of uninstalled printers:",
          "-x (interactive (-i) mode only.)", "option", False)],
        see_also_list=['hp-toolbox'])

    opts, device_uri, printer_name, mode, ui_toolkit, lang = \
        mod.parseStdOpts('x', ['id'])