2
# -*- coding: utf-8 -*-
4
# (c) Copyright 2001-2012 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
20
# Author: Don Welch, Goutam Korra, Naga Samrat Chowdary Narla,
30
from base import device, utils, models
31
from ui_utils import load_pixmap
35
from upgradeform_base import UpgradeForm_base
37
MANUAL_INSTALL_LINK = "http://hplipopensource.com/hplip-web/install/manual/index.html"
39
class UpgradeForm(UpgradeForm_base):
40
def __init__(self, parent=None, name="",modal=0, fl=0,distro_type= 1,msg=""):
41
UpgradeForm_base.__init__(self, parent, name, modal, fl,distro_type, msg)
44
self.distro_type = distro_type
45
self.setIcon(load_pixmap('hp_logo', '128x128'))
49
self.connect(self.NextButton,SIGNAL('clicked()'),self.NextButton_clicked)
50
self.connect(self.CancelButton, SIGNAL("clicked()"), self.CancelButton_clicked)
52
# self.connect(self.installRadioBtton, SIGNAL("toggled(bool)"), self.installRadioBtton_toggled)
53
# self.connect(self.remindRadioBtton, SIGNAL("toggled(bool)"), self.remindRadioBtton_toggled)
54
# self.connect(self.dontRemindRadioBtton, SIGNAL("toggled(bool)"), self.dontRemindRadioBtton_toggled)
57
def installRadioBtton_toggled(self, radio_enabled):
58
log.info("+++++++ installRadioBtton_toggled = %d" %radio_enabled)
59
if radio_enabled is True:
60
self.installRadioBtton.setChecked(True)
62
self.installRadioBtton.setChecked(False)
65
def remindRadioBtton_toggled(self, radio_enabled):
66
log.info("+++++++ remindRadioBtton_toggled = %d" %radio_enabled)
67
if radio_enabled is True:
68
self.remindRadioBtton.setChecked(True)
69
self.daysSpinBox.setEnabled(True)
71
self.remindRadioBtton.setChecked(False)
72
self.daysSpinBox.setEnabled(False)
75
def dontRemindRadioBtton_toggled(self, radio_enabled):
76
log.info("+++++++ dontRemindRadioBtton_toggled = %d" %radio_enabled)
77
if radio_enabled is True:
78
self.dontRemindRadioBtton.setChecked(True)
80
self.dontRemindRadioBtton.setChecked(False)
83
def NextButton_clicked (self):
84
if self.dontRemindRadioBtton.isChecked():
85
log.debug("HPLIP Upgrade, selected Don't remind again radiobutton")
86
user_conf.set('upgrade', 'notify_upgrade', 'false')
87
msg= "Check for HPLIP updates is disabled. To Upgrade again, check it in 'HP-toolbox' "
88
self.SuccessUI( self.__tr(msg))
89
elif self.remindRadioBtton.isChecked():
90
schedule_days = str(self.daysSpinBox.value())
91
log.debug("HPLIP Upgrade, selected remind later radiobutton days= %d" %(int(schedule_days)))
92
next_time = time.time() + (int(schedule_days) *24 * 60 *60)
93
user_conf.set('upgrade', 'pending_upgrade_time', str(int(next_time)))
95
log.debug("HPLIP Upgrade, selected Install radiobutton distro_type=%d" %self.distro_type)
96
self.NextButton.setEnabled(False)
97
if self.distro_type != 1: # not tier 1 distro
98
utils.openURL(MANUAL_INSTALL_LINK)
100
terminal_cmd = utils.get_terminal()
101
if terminal_cmd is not None and utils.which("hp-upgrade"):
102
cmd = terminal_cmd + " 'hp-upgrade '"
103
log.debug("cmd = %s " %cmd)
107
log.error("Failed to run hp-upgrade command from terminal =%s "%terminal_cmd)
108
self.FailureUI( self.__tr("Failed to run hp-upgrade"))
113
def CancelButton_clicked(self):
114
log.debug("User exit")
118
def FailureUI(self, error_text):
119
QMessageBox.critical(self,
123
QMessageBox.NoButton,
124
QMessageBox.NoButton)
126
def SuccessUI(self, text):
127
QMessageBox.information(self,
131
QMessageBox.NoButton,
132
QMessageBox.NoButton)
135
def __tr(self,s,c = None):
136
return qApp.translate("UpgradeDialog",s,c)