~ubuntu-branches/ubuntu/raring/hplip/raring

« back to all changes in this revision

Viewing changes to diagnose_plugin.py

  • Committer: Package Import Robot
  • Author(s): Mark Purcell
  • Date: 2012-10-06 15:03:44 UTC
  • mfrom: (1.6.1) (20.1.16 quantal)
  • Revision ID: package-import@ubuntu.com-20121006150344-2p3xz26br0t3hu2q
Tags: 3.12.10-1
* New upstream release
  - Fixes "Network scanning fails (Closes: #683033)
* quilt refresh hplip-syslog-fix-debug-messages-to-error.dpatch
* Fix "error in clean build env" updated debian/rules (Closes: #687129)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env python
 
2
# -*- coding: utf-8 -*-
 
3
#
 
4
# (c) Copyright 2011 Hewlett-Packard 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: Amarnath Chitumalla, Suma Byrappa
 
21
#
 
22
 
 
23
__version__ = '1.0'
 
24
__mod__ = 'hp-diagnose_plugin'
 
25
__title__ = 'Plugin Download and Install Utility'
 
26
__doc__ = ""
 
27
 
 
28
# Std Lib
 
29
import sys
 
30
import getopt
 
31
import time
 
32
import os.path
 
33
import re
 
34
import os
 
35
 
 
36
# Local
 
37
from base.g import *
 
38
from base import utils, module
 
39
 
 
40
USAGE = [ (__doc__, "", "name", True),
 
41
          ("Usage: %s [OPTIONS]" % __mod__, "", "summary", True),
 
42
          utils.USAGE_OPTIONS,
 
43
          utils.USAGE_LOGGING1, utils.USAGE_LOGGING2, utils.USAGE_LOGGING3,
 
44
          utils.USAGE_HELP,
 
45
          utils.USAGE_SPACE,
 
46
          utils.USAGE_SEEALSO,
 
47
          ("hp-plugin", "", "seealso", False),
 
48
          ("hp-setup", "", "seealso", False),
 
49
          ("hp-firmware", "", "seealso", False),
 
50
        ]
 
51
 
 
52
 
 
53
mod = module.Module(__mod__, __title__, __version__, __doc__, USAGE,
 
54
                    (INTERACTIVE_MODE, GUI_MODE),
 
55
                    (UI_TOOLKIT_QT3, UI_TOOLKIT_QT4), True)
 
56
 
 
57
opts, device_uri, printer_name, mode, ui_toolkit, loc = \
 
58
    mod.parseStdOpts( handle_device_printer=False)
 
59
 
 
60
plugin_path = None
 
61
install_mode = PLUGIN_REQUIRED
 
62
plugin_reason = PLUGIN_REASON_NONE
 
63
 
 
64
if mode == GUI_MODE:
 
65
    if ui_toolkit == 'qt3':
 
66
        log.error("Unable to load Qt3. Please use Qt4")
 
67
 
 
68
    else: #qt4
 
69
        if not utils.canEnterGUIMode4():
 
70
            log.error("%s requires GUI support . Is Qt4 installed?" % __mod__)
 
71
            sys.exit(1)
 
72
 
 
73
        try:
 
74
            from PyQt4.QtGui import QApplication, QMessageBox
 
75
            from ui4.plugindiagnose import PluginDiagnose
 
76
            from installer import core_install
 
77
        except ImportError:
 
78
            log.error("Unable to load Qt4 support. Is it installed?")
 
79
            sys.exit(1)
 
80
 
 
81
        app = QApplication(sys.argv)
 
82
        core = core_install.CoreInstall(core_install.MODE_CHECK)
 
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)
 
91
 
 
92
        dialog.show()
 
93
        try:
 
94
            log.debug("Starting GUI loop...")
 
95
            app.exec_()
 
96
        except KeyboardInterrupt:
 
97
            log.error("User exit")
 
98
            sys.exit(0)
 
99
else: #Interaction mode
 
100
    log.error("Only Qt4 GUI mode is supported \n")
 
101
    usage()
 
102
 
 
103
log.info("")
 
104
log.info("Done.")