2488.1.8
by Colin Watson
Switch #! lines over to python3, apart from dist-upgrader which needs to |
1 |
#!/usr/bin/python3
|
2076
by Michael Vogt
add tests around the distro end of life handling |
2 |
# check-new-release-gtk - this is called periodically in the background
|
3 |
# (currently by update-notifier every 48h) to
|
|
4 |
# gather information about new releases of Ubuntu
|
|
5 |
# or to nag about no longer supported versions
|
|
6 |
#
|
|
7 |
# Copyright (c) 2010,2011 Canonical
|
|
8 |
#
|
|
9 |
# Author: Michael Vogt <mvo@ubuntu.com>
|
|
10 |
#
|
|
11 |
# This program is free software; you can redistribute it and/or
|
|
12 |
# modify it under the terms of the GNU General Public License as
|
|
13 |
# published by the Free Software Foundation; either version 2 of the
|
|
14 |
# License, or (at your option) any later version.
|
|
15 |
#
|
|
16 |
# This program is distributed in the hope that it will be useful,
|
|
17 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
18 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
19 |
# GNU General Public License for more details.
|
|
20 |
#
|
|
21 |
# You should have received a copy of the GNU General Public License
|
|
22 |
# along with this program; if not, write to the Free Software
|
|
23 |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
24 |
# USA
|
|
1674
by Michael Vogt
* rename update-manager-support-status to ubuntu-support-status |
25 |
|
2394
by Colin Watson
Use Python 3-style print functions. |
26 |
from __future__ import print_function |
27 |
||
2153
by Michael Vogt
* UpdateManager/UpdateManager.py, check-new-release-gtk: |
28 |
from gi.repository import Gio |
2599
by Michael Vogt
fix GObject->GLib deprecation warnings |
29 |
from gi.repository import GLib |
2146.2.4
by Michael Vogt
convert check-new-release-gtk |
30 |
from gi.repository import Gtk |
1751
by Michael Vogt
* check-new-release-gtk, UpdateManager/Core/MetaRelease.py: |
31 |
import locale |
1674
by Michael Vogt
* rename update-manager-support-status to ubuntu-support-status |
32 |
import logging |
2693
by Brian Murray
Instead of using gksu to authenticate for the distribution upgrade, use |
33 |
import os |
2688
by Brian Murray
Call update-manager instead of raising it's UnsupportedDialog |
34 |
import subprocess |
1674
by Michael Vogt
* rename update-manager-support-status to ubuntu-support-status |
35 |
import sys |
36 |
import time |
|
37 |
||
2108.2.1
by Gabor Kelemen
Add gettext intialization, fixes LP:775659 |
38 |
import gettext |
1674
by Michael Vogt
* rename update-manager-support-status to ubuntu-support-status |
39 |
from optparse import OptionParser |
40 |
||
2444.1.21
by Michael Terry
more import fixes |
41 |
from UpdateManager.Core.utils import init_proxy |
1675
by Michael Vogt
basic fetching/upgrading support |
42 |
|
2515
by Michael Terry
add DistUpgradeFetcher code and related bits to this package instead of update-manager |
43 |
from DistUpgrade.DistUpgradeFetcher import DistUpgradeFetcherGtk |
1674
by Michael Vogt
* rename update-manager-support-status to ubuntu-support-status |
44 |
from UpdateManager.MetaReleaseGObject import MetaRelease |
2519.1.4
by Michael Terry
some further testing nits |
45 |
from DistUpgrade.SimpleGtk3builderApp import SimpleGtkbuilderApp |
1674
by Michael Vogt
* rename update-manager-support-status to ubuntu-support-status |
46 |
|
2469
by Colin Watson
Initialise _ earlier to fix tests. |
47 |
#FIXME: Workaround a bug in optparser which doesn't handle unicode/str
|
48 |
# correctly, see http://bugs.python.org/issue4391
|
|
2688
by Brian Murray
Call update-manager instead of raising it's UnsupportedDialog |
49 |
# Should be resolved by Python3
|
2444.1.13
by Michael Terry
merge from lp:update-manager |
50 |
gettext.bindtextdomain("ubuntu-release-upgrader", "/usr/share/locale") |
51 |
gettext.textdomain("ubuntu-release-upgrader") |
|
52 |
translation = gettext.translation("ubuntu-release-upgrader", fallback=True) |
|
2469
by Colin Watson
Initialise _ earlier to fix tests. |
53 |
if sys.version >= '3': |
54 |
_ = translation.gettext |
|
55 |
else: |
|
56 |
_ = translation.ugettext |
|
57 |
||
1690
by Michael Vogt
check-new-release-gtk: add --test-uri option |
58 |
# overwrite default upgrade fetcher and make it not show the
|
59 |
# release notes by default
|
|
1675
by Michael Vogt
basic fetching/upgrading support |
60 |
class DistUpgradeFetcher(DistUpgradeFetcherGtk): |
61 |
def showReleaseNotes(self): |
|
62 |
# nothing to do
|
|
63 |
return True |
|
64 |
||
1690
by Michael Vogt
check-new-release-gtk: add --test-uri option |
65 |
|
1689
by Michael Vogt
* check-new-release-gtk, data/glade/UpgradePromptDialog.ui: |
66 |
class CheckNewReleaseGtk(SimpleGtkbuilderApp): |
2660
by Brian Murray
Update release version in DistUpgradeQuirks.py (LP: #1202826) |
67 |
""" Gtk version of the release notes check/download """
|
1674
by Michael Vogt
* rename update-manager-support-status to ubuntu-support-status |
68 |
|
69 |
# the timeout until we give up
|
|
1741
by Michael Vogt
* check-new-release-gtk: |
70 |
FETCH_TIMEOUT = 20 |
1674
by Michael Vogt
* rename update-manager-support-status to ubuntu-support-status |
71 |
|
72 |
def __init__(self, options): |
|
2428.4.9
by Michael Terry
fix dist-upgrade dialog and release notes dialog to be enabled again; move their gtkbuilder xml to new .ui files |
73 |
self.options = options |
2428.4.12
by Michael Terry
further test fixes |
74 |
self.datadir = options.datadir |
1674
by Michael Vogt
* rename update-manager-support-status to ubuntu-support-status |
75 |
self.new_dist = None |
2333
by Brian Murray
fix a typo in check-new-release-gtk |
76 |
logging.debug("running with devel=%s proposed=%s" % ( |
1751
by Michael Vogt
* check-new-release-gtk, UpdateManager/Core/MetaRelease.py: |
77 |
options.devel_release, options.proposed_release)) |
1674
by Michael Vogt
* rename update-manager-support-status to ubuntu-support-status |
78 |
m = MetaRelease(useDevelopmentRelease=options.devel_release, |
79 |
useProposed=options.proposed_release) |
|
80 |
m.connect("new-dist-available", self.new_dist_available) |
|
2693
by Brian Murray
Instead of using gksu to authenticate for the distribution upgrade, use |
81 |
GLib.timeout_add_seconds(self.FETCH_TIMEOUT, self.timeout, None) |
1692
by Michael Vogt
check-new-release-gtk: do not exit if run in --test-uri mode |
82 |
|
2685
by Brian Murray
Properly raise UnsupportedDialog error (LP: #1210643) |
83 |
def _run_dialog(self, dialog): |
84 |
window = Gtk.Window() |
|
85 |
window.set_title(_("Software Updater")) |
|
86 |
window.set_icon_name("system-software-update") |
|
87 |
window.set_position(Gtk.WindowPosition.CENTER) |
|
88 |
window.set_resizable(False) |
|
89 |
||
90 |
window.add(dialog) |
|
91 |
dialog.start() |
|
92 |
window.show_all() |
|
93 |
Gtk.main() |
|
94 |
||
1674
by Michael Vogt
* rename update-manager-support-status to ubuntu-support-status |
95 |
def new_dist_available(self, meta_release, new_dist): |
1751
by Michael Vogt
* check-new-release-gtk, UpdateManager/Core/MetaRelease.py: |
96 |
logging.debug("new_dist_available: %s" % new_dist) |
1674
by Michael Vogt
* rename update-manager-support-status to ubuntu-support-status |
97 |
self.new_dist = new_dist |
2821
by Martin Pitt
check-new-release-gtk: Fix deprecated Gio.Settings constructor invocation. |
98 |
client = Gio.Settings.new("com.ubuntu.update-manager") |
2153
by Michael Vogt
* UpdateManager/UpdateManager.py, check-new-release-gtk: |
99 |
ignore_dist = client.get_string("check-new-release-ignore") |
1965
by Michael Vogt
* check-new-release-gtk: |
100 |
# only honor the ignore list if the distro is still supported, otherwise
|
101 |
# go into nag mode
|
|
102 |
if (ignore_dist == new_dist.name and |
|
103 |
meta_release.no_longer_supported is None): |
|
2857.1.2
by Dimitri John Ledkov
Fix resource warnings & logging.warn deprecation warning. |
104 |
logging.warning("found new dist '%s' but it is on the ignore list" % new_dist.name) |
2685
by Brian Murray
Properly raise UnsupportedDialog error (LP: #1210643) |
105 |
sys.exit() |
106 |
||
1965
by Michael Vogt
* check-new-release-gtk: |
107 |
# show alert on unsupported distros
|
108 |
if meta_release.no_longer_supported is not None: |
|
2688
by Brian Murray
Call update-manager instead of raising it's UnsupportedDialog |
109 |
subprocess.call(['update-manager', '--no-update']) |
110 |
Gtk.main_quit() |
|
2685
by Brian Murray
Properly raise UnsupportedDialog error (LP: #1210643) |
111 |
else: |
112 |
self.build_ui() |
|
113 |
self.window_main.set_title(_("Ubuntu %(version)s Upgrade Available") % {'version': new_dist.version}) |
|
114 |
self.window_main.show() |
|
115 |
||
2657.1.1
by Michael Terry
Fix test_end_of_life.py |
116 |
def close(self): |
117 |
self.window_main.destroy() |
|
118 |
Gtk.main_quit() |
|
119 |
||
1674
by Michael Vogt
* rename update-manager-support-status to ubuntu-support-status |
120 |
def build_ui(self): |
2685
by Brian Murray
Properly raise UnsupportedDialog error (LP: #1210643) |
121 |
SimpleGtkbuilderApp.__init__(self, self.datadir+"/gtkbuilder/UpgradePromptDialog.ui", "ubuntu-release-upgrader") |
1674
by Michael Vogt
* rename update-manager-support-status to ubuntu-support-status |
122 |
|
123 |
def on_button_upgrade_now_clicked(self, button): |
|
1741
by Michael Vogt
* check-new-release-gtk: |
124 |
logging.debug("upgrade now") |
3078.1.2
by Balint Reczey
* DistUpgrade/DistUpgradeFetcher.py, |
125 |
extra_args = [] |
2652
by Brian Murray
check-new-release-gtk also needs to pass devel-release |
126 |
if options.devel_release: |
3078.1.2
by Balint Reczey
* DistUpgrade/DistUpgradeFetcher.py, |
127 |
extra_args += ["--devel-release"] |
2693
by Brian Murray
Instead of using gksu to authenticate for the distribution upgrade, use |
128 |
if options.proposed_release: |
3078.1.2
by Balint Reczey
* DistUpgrade/DistUpgradeFetcher.py, |
129 |
extra_args += ["--proposed"] |
130 |
os.execv("/usr/bin/do-release-upgrade", |
|
131 |
["do-release-upgrade", |
|
132 |
"--frontend=DistUpgradeViewGtk3"] + extra_args) |
|
1674
by Michael Vogt
* rename update-manager-support-status to ubuntu-support-status |
133 |
|
134 |
def on_button_ask_me_later_clicked(self, button): |
|
1741
by Michael Vogt
* check-new-release-gtk: |
135 |
logging.debug("ask me later") |
1735
by Michael Vogt
* check-new-release-gtk: |
136 |
# check again in a week
|
137 |
next_check = time.time() + 7*24*60*60 |
|
2334
by Brian Murray
the release-check-time key exists in update-notifier not update-manager |
138 |
client = Gio.Settings("com.ubuntu.update-notifier") |
2611.1.1
by Michael Terry
make check-new-release-gtk work again |
139 |
client.set_uint("release-check-time", int(next_check)) |
2146.2.4
by Michael Vogt
convert check-new-release-gtk |
140 |
Gtk.main_quit() |
1674
by Michael Vogt
* rename update-manager-support-status to ubuntu-support-status |
141 |
|
1689
by Michael Vogt
* check-new-release-gtk, data/glade/UpgradePromptDialog.ui: |
142 |
def on_button_dont_upgrade_clicked(self, button): |
2394
by Colin Watson
Use Python 3-style print functions. |
143 |
#print("don't upgrade")
|
1696
by Michael Vogt
check-new-release-gtk: add decline upgrade question (as per spec) |
144 |
s = _("You have declined the upgrade to Ubuntu %s") % self.new_dist.version |
145 |
self.dialog_really_do_not_upgrade.set_markup("<b>%s</b>" % s) |
|
2146.2.4
by Michael Vogt
convert check-new-release-gtk |
146 |
if self.dialog_really_do_not_upgrade.run() == Gtk.ResponseType.OK: |
2146.2.11
by Michael Vogt
initial port from gconf -> gsettings, this needs some cleanup in the naming still |
147 |
client = Gio.Settings("com.ubuntu.update-manager") |
2153
by Michael Vogt
* UpdateManager/UpdateManager.py, check-new-release-gtk: |
148 |
client.set_string("check-new-release-ignore", self.new_dist.name) |
2146.2.4
by Michael Vogt
convert check-new-release-gtk |
149 |
Gtk.main_quit() |
1674
by Michael Vogt
* rename update-manager-support-status to ubuntu-support-status |
150 |
|
1689
by Michael Vogt
* check-new-release-gtk, data/glade/UpgradePromptDialog.ui: |
151 |
def on_linkbutton_release_notes_clicked(self, linkbutton): |
1694
by Michael Vogt
* check-new-release-gtk: |
152 |
# gtk will do the right thing if uri is set
|
153 |
pass
|
|
1689
by Michael Vogt
* check-new-release-gtk, data/glade/UpgradePromptDialog.ui: |
154 |
|
1751
by Michael Vogt
* check-new-release-gtk, UpdateManager/Core/MetaRelease.py: |
155 |
def window_delete_event_cb(self, window, event): |
2146.2.4
by Michael Vogt
convert check-new-release-gtk |
156 |
Gtk.main_quit() |
1751
by Michael Vogt
* check-new-release-gtk, UpdateManager/Core/MetaRelease.py: |
157 |
|
2152.1.1
by Michael Terry
fix a couple straggling references to glib instead of GLib |
158 |
def timeout(self, user_data): |
1674
by Michael Vogt
* rename update-manager-support-status to ubuntu-support-status |
159 |
if self.new_dist is None: |
2857.1.2
by Dimitri John Ledkov
Fix resource warnings & logging.warn deprecation warning. |
160 |
logging.warning("timeout reached, exiting") |
2146.2.4
by Michael Vogt
convert check-new-release-gtk |
161 |
Gtk.main_quit() |
1674
by Michael Vogt
* rename update-manager-support-status to ubuntu-support-status |
162 |
|
163 |
if __name__ == "__main__": |
|
2108.2.1
by Gabor Kelemen
Add gettext intialization, fixes LP:775659 |
164 |
|
2146.2.4
by Michael Vogt
convert check-new-release-gtk |
165 |
Gtk.init_check(sys.argv) |
2108.2.1
by Gabor Kelemen
Add gettext intialization, fixes LP:775659 |
166 |
|
167 |
try: |
|
168 |
locale.setlocale(locale.LC_ALL, "") |
|
169 |
except: |
|
170 |
pass
|
|
1674
by Michael Vogt
* rename update-manager-support-status to ubuntu-support-status |
171 |
|
172 |
init_proxy() |
|
173 |
||
174 |
parser = OptionParser() |
|
175 |
parser.add_option ("-d", "--devel-release", action="store_true", |
|
176 |
dest="devel_release", default=False, |
|
177 |
help=_("Check if upgrading to the latest devel release " |
|
2458
by Colin Watson
Rearrange the OptionParser workaround from 1:0.154.5 to work with Python |
178 |
"is possible")) |
1674
by Michael Vogt
* rename update-manager-support-status to ubuntu-support-status |
179 |
parser.add_option ("-p", "--proposed", action="store_true", |
180 |
dest="proposed_release", default=False, |
|
181 |
help=_("Try upgrading to the latest release using " |
|
2458
by Colin Watson
Rearrange the OptionParser workaround from 1:0.154.5 to work with Python |
182 |
"the upgrader from $distro-proposed")) |
1689
by Michael Vogt
* check-new-release-gtk, data/glade/UpgradePromptDialog.ui: |
183 |
# mostly useful for development
|
2444.1.2
by Michael Terry
first pass at converting update-manager source into ubuntu-release-upgrader |
184 |
parser.add_option ("", "--datadir", default="/usr/share/ubuntu-release-upgrader") |
1751
by Michael Vogt
* check-new-release-gtk, UpdateManager/Core/MetaRelease.py: |
185 |
parser.add_option ("", "--debug", action="store_true", default=False, |
2458
by Colin Watson
Rearrange the OptionParser workaround from 1:0.154.5 to work with Python |
186 |
help=_("Add debug output")) |
1674
by Michael Vogt
* rename update-manager-support-status to ubuntu-support-status |
187 |
(options, args) = parser.parse_args() |
1751
by Michael Vogt
* check-new-release-gtk, UpdateManager/Core/MetaRelease.py: |
188 |
if options.debug: |
189 |
logging.basicConfig(level=logging.DEBUG) |
|
190 |
||
1674
by Michael Vogt
* rename update-manager-support-status to ubuntu-support-status |
191 |
# create object
|
192 |
cnr = CheckNewReleaseGtk(options) |
|
2660
by Brian Murray
Update release version in DistUpgradeQuirks.py (LP: #1202826) |
193 |
|
2146.2.4
by Michael Vogt
convert check-new-release-gtk |
194 |
Gtk.main() |
1674
by Michael Vogt
* rename update-manager-support-status to ubuntu-support-status |
195 |