~ubuntu-branches/ubuntu/saucy/hplip/saucy-proposed

« back to all changes in this revision

Viewing changes to diagnose_plugin.py

  • Committer: Package Import Robot
  • Author(s): Mark Purcell
  • Date: 2012-05-26 11:20:39 UTC
  • mfrom: (1.5.6) (31.1.3 precise)
  • Revision ID: package-import@ubuntu.com-20120526112039-bevxczegxnbyr5m7
Tags: 3.12.4-1
* New upstream release
* Switch to source/format 3.0 (quilt) - drop dpatch
* Refreshed debian/patches
* dh_autoreconf debian/autogen.sh & set local-options single-debian-patch
* Update to debian/compat -> 9
* Fix "hardened build flags" patch from Moritz - thanks (Closes: #667828)
* Fix "duplex descriptor uninitialized" patch from Matej (Closes: #583273)
* Fix "please migrate to kde-runtime" patch from Pino (Closes: #666544)

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
from base.g import *
38
38
from base import utils, module
39
39
 
40
 
pm = None
41
 
 
42
 
 
43
 
 
44
40
USAGE = [ (__doc__, "", "name", True),
45
 
          ("Usage: %s [MODE] [OPTIONS]" % __mod__, "", "summary", True),
46
 
          utils.USAGE_MODE,
47
 
          ("Installation for required printer mode:", "--required (Qt4 only)", "option", False),
48
 
          ("Installation for optional printer mode:", "--optional (Qt4 only)", "option", False),
49
 
          #("Installation generic mode:", "--generic (default)", "option", False),
50
 
          utils.USAGE_LANGUAGE,
 
41
          ("Usage: %s [OPTIONS]" % __mod__, "", "summary", True),
51
42
          utils.USAGE_OPTIONS,
52
43
          utils.USAGE_LOGGING1, utils.USAGE_LOGGING2, utils.USAGE_LOGGING3,
53
44
          utils.USAGE_HELP,
67
58
    mod.parseStdOpts( handle_device_printer=False)
68
59
 
69
60
plugin_path = None
70
 
install_mode = PLUGIN_NONE # reuse plugin types for mode (PLUGIN_NONE = generic)
 
61
install_mode = PLUGIN_REQUIRED
71
62
plugin_reason = PLUGIN_REASON_NONE
72
63
 
73
 
for o, a in opts:
74
 
    if o == '--required':
75
 
        install_mode = PLUGIN_REQUIRED
76
 
        if ui_toolkit == 'qt3':
77
 
            log.warn("--required switch ignored.")
78
 
 
79
 
    elif o == '--optional':
80
 
        install_mode = PLUGIN_OPTIONAL
81
 
        if ui_toolkit == 'qt3':
82
 
            log.warn("--optional switch ignored.")
83
 
 
84
 
    elif o == '--reason':
85
 
        plugin_reason = int(a)
86
 
 
87
 
 
88
 
version = prop.installed_version
89
 
 
90
 
 
91
 
 
92
64
if mode == GUI_MODE:
93
65
    if ui_toolkit == 'qt3':
94
 
        if not utils.canEnterGUIMode():
95
 
            log.error("%s requires GUI support (try running with --qt4). Try using interactive (-i) mode." % __mod__)
96
 
            sys.exit(1)
97
 
    else:
 
66
        log.error("Unable to load Qt3. Please use Qt4")
 
67
 
 
68
    else: #qt4
98
69
        if not utils.canEnterGUIMode4():
99
 
            log.error("%s requires GUI support (try running with --qt3). Try using interactive (-i) mode." % __mod__)
 
70
            log.error("%s requires GUI support . Is Qt4 installed?" % __mod__)
100
71
            sys.exit(1)
101
72
 
102
 
 
103
 
if mode == GUI_MODE:
104
 
    if ui_toolkit == 'qt3':
105
 
        log.error("Unable to load Qt3. Please use qt4")
106
 
 
107
 
    else: # qt4
108
73
        try:
109
74
            from PyQt4.QtGui import QApplication, QMessageBox
110
75
            from ui4.plugindiagnose import PluginDiagnose
 
76
            from installer import core_install
111
77
        except ImportError:
112
78
            log.error("Unable to load Qt4 support. Is it installed?")
113
79
            sys.exit(1)
114
80
 
115
81
        app = QApplication(sys.argv)
 
82
        core = core_install.CoreInstall()
 
83
        plugin_sts = core.check_for_plugin()
 
84
        if plugin_sts == PLUGIN_INSTALLED:
 
85
            log.info("Device Plugin is already installed")
 
86
            sys.exit(0)
 
87
        elif plugin_sts == PLUGIN_VERSION_MISMATCH:
 
88
            dialog = PluginDiagnose(None, install_mode, plugin_reason, True)
 
89
        else:
 
90
            dialog = PluginDiagnose(None, install_mode, plugin_reason)
116
91
 
117
 
        dialog = PluginDiagnose(None, install_mode, plugin_reason)
118
92
        dialog.show()
119
 
 
120
93
        try:
121
94
            log.debug("Starting GUI loop...")
122
95
            app.exec_()
123
96
        except KeyboardInterrupt:
124
97
            log.error("User exit")
125
98
            sys.exit(0)
126
 
 
 
99
else: #Interaction mode
 
100
    log.error("Only Qt4 GUI mode is supported \n")
 
101
    usage()
127
102
 
128
103
log.info("")
129
104
log.info("Done.")
130