Skip to content

Commit

Permalink
resync to upstream 1:16.02.12
Browse files Browse the repository at this point in the history
  • Loading branch information
reynhout committed Feb 25, 2018
1 parent 55945d1 commit 1b89eca
Show file tree
Hide file tree
Showing 36 changed files with 371 additions and 187 deletions.
20 changes: 15 additions & 5 deletions UpdateManager/ChangelogViewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,10 +213,15 @@ def button_press_event(self, text_view, event):
# get the iter at the mouse position
(x, y) = self.window_to_buffer_coords(Gtk.TextWindowType.WIDGET,
int(event.x), int(event.y))
iter = self.get_iter_at_location(x, y)

# call open_url or menu.popup if an URL is assigned to the iter
tags = iter.get_tags()
try:
iter = self.get_iter_at_location(x, y)
tags = iter.get_tags()
except AttributeError:
# GTK > 3.20 added a return type to this function
(over_text, iter) = self.get_iter_at_location(x, y)
tags = iter.get_tags()

for tag in tags:
if hasattr(tag, "url"):
if event.button == 1:
Expand Down Expand Up @@ -253,10 +258,15 @@ def check_hovering(self, x, y):
a hand cursor"""
_hovering = False
# get the iter at the mouse position
iter = self.get_iter_at_location(x, y)
try:
iter = self.get_iter_at_location(x, y)
tags = iter.get_tags()
except AttributeError:
# GTK > 3.20 added a return type to this function
(over_text, iter) = self.get_iter_at_location(x, y)
tags = iter.get_tags()

# set _hovering if the iter has the tag "url"
tags = iter.get_tags()
for tag in tags:
if hasattr(tag, "url"):
_hovering = True
Expand Down
78 changes: 41 additions & 37 deletions UpdateManager/Core/MetaRelease.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,42 +236,46 @@ def parse(self):

# parse the metarelease_information file
index_tag = apt_pkg.TagFile(self.metarelease_information)
while index_tag.step():
for required_key in ("Dist", "Version", "Supported", "Date"):
if required_key not in index_tag.section:
raise MetaReleaseParseError(
"Required key '%s' missing" % required_key)
name = index_tag.section["Dist"]
self._debug("found distro name: '%s'" % name)
rawdate = index_tag.section["Date"]
parseddate = list(email.utils.parsedate(rawdate))
parseddate[8] = 0 # assume no DST
date = time.mktime(tuple(parseddate))
supported = int(index_tag.section["Supported"])
version = index_tag.section["Version"]
# add the information to a new date object
dist = Dist(name, version, date, supported)
if "ReleaseNotes" in index_tag.section:
dist.releaseNotesURI = index_tag.section["ReleaseNotes"]
lang = get_lang()
if lang:
dist.releaseNotesURI += "?lang=%s" % lang
if "ReleaseNotesHtml" in index_tag.section:
dist.releaseNotesHtmlUri = index_tag.section[
"ReleaseNotesHtml"]
query = self._get_release_notes_uri_query_string(dist)
if query:
dist.releaseNotesHtmlUri += query
if "UpgradeTool" in index_tag.section:
dist.upgradeTool = index_tag.section["UpgradeTool"]
if "UpgradeToolSignature" in index_tag.section:
dist.upgradeToolSig = index_tag.section[
"UpgradeToolSignature"]
if "UpgradeBroken" in index_tag.section:
dist.upgrade_broken = index_tag.section["UpgradeBroken"]
dists.append(dist)
if name == current_dist_name:
current_dist = dist
try:
while index_tag.step():
for required_key in ("Dist", "Version", "Supported", "Date"):
if required_key not in index_tag.section:
raise MetaReleaseParseError(
"Required key '%s' missing" % required_key)
name = index_tag.section["Dist"]
self._debug("found distro name: '%s'" % name)
rawdate = index_tag.section["Date"]
parseddate = list(email.utils.parsedate(rawdate))
parseddate[8] = 0 # assume no DST
date = time.mktime(tuple(parseddate))
supported = int(index_tag.section["Supported"])
version = index_tag.section["Version"]
# add the information to a new date object
dist = Dist(name, version, date, supported)
if "ReleaseNotes" in index_tag.section:
dist.releaseNotesURI = index_tag.section["ReleaseNotes"]
lang = get_lang()
if lang:
dist.releaseNotesURI += "?lang=%s" % lang
if "ReleaseNotesHtml" in index_tag.section:
dist.releaseNotesHtmlUri = index_tag.section[
"ReleaseNotesHtml"]
query = self._get_release_notes_uri_query_string(dist)
if query:
dist.releaseNotesHtmlUri += query
if "UpgradeTool" in index_tag.section:
dist.upgradeTool = index_tag.section["UpgradeTool"]
if "UpgradeToolSignature" in index_tag.section:
dist.upgradeToolSig = index_tag.section[
"UpgradeToolSignature"]
if "UpgradeBroken" in index_tag.section:
dist.upgrade_broken = index_tag.section["UpgradeBroken"]
dists.append(dist)
if name == current_dist_name:
current_dist = dist
except SystemError:
raise MetaReleaseParseError("Unable to parse %s" %
self.METARELEASE_URI)

self.metarelease_information.close()
self.metarelease_information = None
Expand Down Expand Up @@ -366,7 +370,7 @@ def download(self):
self._debug("have self.metarelease_information")
try:
self.parse()
except:
except Exception as e:
logging.exception("parse failed for '%s'" %
self.METARELEASE_FILE)
# no use keeping a broken file around
Expand Down
14 changes: 7 additions & 7 deletions UpdateManager/Core/MyCache.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,9 @@ def saveDistUpgrade(self):

def _strip_epoch(self, verstr):
" strip of the epoch "
l = verstr.split(":")
if len(l) > 1:
verstr = "".join(l[1:])
vers_no_epoch = verstr.split(":")
if len(vers_no_epoch) > 1:
verstr = "".join(vers_no_epoch[1:])
return verstr

def _get_changelog_or_news(self, name, fname, strict_versioning=False,
Expand All @@ -199,9 +199,9 @@ def _get_changelog_or_news(self, name, fname, strict_versioning=False,
srcver = self._strip_epoch(srcver_epoch)
#print("bin: %s" % binver)

l = section.split("/")
if len(l) > 1:
src_section = l[0]
split_section = section.split("/")
if len(split_section) > 1:
src_section = split_section[0]

# lib is handled special
prefix = srcpkg[0]
Expand Down Expand Up @@ -302,7 +302,7 @@ def get_news_and_changelog(self, name, lock):
self.get_changelog(name)
try:
lock.release()
except:
except Exception as e:
pass

def get_news(self, name):
Expand Down
10 changes: 5 additions & 5 deletions UpdateManager/Core/UpdateList.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ def _add_deps(self, pkg, cache, eventloop_callback):
# This shouldn't really happen. If we land here often, it's a sign
# that something has gone wrong. Unless all pkgs are None it's not
# a critical issue - a hit to the performance at most.
reason = ((not pkg or not pkg.candidate)
and "Package was None or didn't have a candidate."
or "%s already in _deps." % pkg.name)
reason = ((not pkg or not pkg.candidate) and
"Package was None or didn't have a candidate." or
"%s already in _deps." % pkg.name)
logging.debug("Useless call to _add_deps. %s" % reason)
return
if len(self._deps) % 200 == 0 and callable(eventloop_callback):
Expand Down Expand Up @@ -273,8 +273,8 @@ def _get_application_for_package(self, pkg):
desktop_file)
application.set_desktop_env(self.current_desktop)
except Exception as e:
print("Error loading .desktop file %s: %s" %
(desktop_file, e))
logging.warning("Error loading .desktop file %s: %s" %
(desktop_file, e))
continue
score = self._rate_application_for_package(application, pkg)
if score > 0:
Expand Down
1 change: 1 addition & 0 deletions UpdateManager/Core/roam.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ def is_active_connection_gsm_or_cdma_roaming(self):
res |= mmhelper.is_cdma_roaming()
return res


if __name__ == "__main__":

# test code
Expand Down
23 changes: 11 additions & 12 deletions UpdateManager/Core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def is_unity_running():
import dbus
bus = dbus.SessionBus()
unity_running = bus.name_has_owner("com.canonical.Unity")
except:
except Exception as e:
logging.exception("could not check for Unity dbus service")
return unity_running

Expand Down Expand Up @@ -370,23 +370,22 @@ def inhibit_sleep():
from gi.repository import Gio, GLib
connection = Gio.bus_get_sync(Gio.BusType.SYSTEM)

var, fdlist = connection.call_with_unix_fd_list_sync('org.freedesktop.login1',
'/org/freedesktop/login1',
'org.freedesktop.login1.Manager',
'Inhibit',
GLib.Variant('(ssss)',
('shutdown:sleep',
'UpdateManager',
'Updating System',
'block')),
None, 0, -1, None, None)
var, fdlist = connection.call_with_unix_fd_list_sync(
'org.freedesktop.login1', '/org/freedesktop/login1',
'org.freedesktop.login1.Manager', 'Inhibit',
GLib.Variant('(ssss)',
('shutdown:sleep',
'UpdateManager', 'Updating System',
'block')),
None, 0, -1, None, None)
inhibitor = Gio.UnixInputStream(fd=fdlist.steal_fds()[var[0]])

return inhibitor
except Exception:
#print("could not send the dbus Inhibit signal: %s" % e)
return False


def str_to_bool(str):
if str == "0" or str.upper() == "FALSE":
return False
Expand Down Expand Up @@ -502,7 +501,7 @@ def is_port_already_listening(port):
STATE_LISTENING = '0A'
# read the data
with open("/proc/net/tcp") as net_tcp:
for line in net_tcp:
for line in net_tcp.readlines():
line = line.strip()
if not line:
continue
Expand Down
4 changes: 2 additions & 2 deletions UpdateManager/Dialogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ def _request_reboot_via_session_manager(self):
iface.RequestReboot()
except dbus.DBusException:
self._request_reboot_via_consolekit()
except:
except Exception as e:
pass

def _request_reboot_via_consolekit(self):
Expand All @@ -315,7 +315,7 @@ def _request_reboot_via_consolekit(self):
iface.Restart()
except dbus.DBusException:
self._request_reboot_via_logind()
except:
except Exception as e:
pass

def _request_reboot_via_logind(self):
Expand Down
4 changes: 2 additions & 2 deletions UpdateManager/UpdateManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ def _setup_dbus(self):
# listening on dbus
try:
bus = dbus.SessionBus()
except:
except Exception as e:
print("warning: could not initiate dbus")
return
try:
Expand Down Expand Up @@ -403,7 +403,7 @@ def upgrade(self):
try:
self.parent.start_install()
return True
except:
except Exception as e:
return False

def _on_network_alert(self, watcher, state):
Expand Down
57 changes: 44 additions & 13 deletions UpdateManager/UpdatesAvailable.py
Original file line number Diff line number Diff line change
Expand Up @@ -821,25 +821,56 @@ def activate_desc(self, expander, data):

def on_button_install_clicked(self):
self.unity.set_install_menuitem_visible(False)
#print("on_button_install_clicked")
# print("on_button_install_clicked")
err_sum = _("Not enough free disk space")
err_long = _("The upgrade needs a total of %s free space on "
"disk '%s'. "
"Please free at least an additional %s of disk "
"space on '%s'. "
"Empty your trash and remove temporary "
"packages of former installations using "
"'sudo apt-get clean'.")
err_msg = _("The upgrade needs a total of %s free space on "
"disk '%s'. "
"Please free at least an additional %s of disk "
"space on '%s'. %s")
# specific ways to resolve lack of free space
remedy_archivedir = _("Remove temporary packages of former "
"installations using 'sudo apt clean'.")
remedy_boot = _("You can remove old kernels using "
"'sudo apt autoremove', and you could also "
"set COMPRESS=xz in "
"/etc/initramfs-tools/initramfs.conf to "
"reduce the size of your initramfs.")
remedy_root = _("Empty your trash and remove temporary "
"packages of former installations using "
"'sudo apt clean'.")
remedy_tmp = _("Reboot to clean up files in /tmp.")
remedy_usr = _("")
# check free space and error if its not enough
try:
self.cache.checkFreeSpace()
except NotEnoughFreeSpaceError as e:
# CheckFreeSpace examines where packages are cached
archivedir = apt_pkg.config.find_dir("Dir::Cache::archives")
err_long = ""
for req in e.free_space_required_list:
self.window_main.start_error(False, err_sum,
err_long % (req.size_total,
req.dir,
req.size_needed,
req.dir))
if err_long != "":
err_long += " "
if req.dir == archivedir:
err_long += err_msg % (req.size_total, req.dir,
req.size_needed, req.dir,
remedy_archivedir)
elif req.dir == "/boot":
err_long += err_msg % (req.size_total, req.dir,
req.size_needed, req.dir,
remedy_boot)
elif req.dir == "/":
err_long += err_msg % (req.size_total, req.dir,
req.size_needed, req.dir,
remedy_root)
elif req.dir == "/tmp":
err_long += err_msg % (req.size_total, req.dir,
req.size_needed, req.dir,
remedy_tmp)
elif req.dir == "/usr":
err_long += err_msg % (req.size_total, req.dir,
req.size_needed, req.dir,
remedy_usr)
self.window_main.start_error(False, err_sum, err_long)
return
except SystemError as e:
logging.exception("free space check failed")
Expand Down
2 changes: 1 addition & 1 deletion UpdateManager/backend/InstallBackendAptdaemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def update(self):
self._action_done(self.ACTION_UPDATE,
authorized=False, success=False,
error_string=None, error_desc=None)
except:
except Exception as e:
self._action_done(self.ACTION_UPDATE,
authorized=True, success=False,
error_string=None, error_desc=None)
Expand Down
1 change: 1 addition & 0 deletions UpdateManagerText/UpdateManagerText.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ def main(self, options):
res = self.cache.commit(apt.progress.text.AcquireProgress(),
apt.progress.base.InstallProgress())


if __name__ == "__main__":

umt = UpdateManagerText()
Expand Down
2 changes: 1 addition & 1 deletion data/com.ubuntu.update-manager.gschema.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
<summary>make check-new-release-gtk ignore a given new release</summary>
<description>This will permanently hide the new release prompt from check-new-release-gtk. Note that the small button in the main update-manager UI will still be there.</description>
</key>
<key name="launch-time" type="i">
<key name="launch-time" type="x">
<default>0</default>
<summary>Time when update-manager got launched last</summary>
<description>The last time update-manager was run.</description>
Expand Down
2 changes: 1 addition & 1 deletion data/update-manager.8
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Directory that contains the data files
Check if a new distribution release is available
.TP
\fB-d\fR, \fB\-\-devel-release\fR
Check if upgrading to the latest devel release is possible
If using the latest supported release, upgrade to the development release
.TP
\fB-p\fR, \fB\-\-proposed\fR
Upgrade using the latest proposed version of the release upgrader
Expand Down
Loading

0 comments on commit 1b89eca

Please sign in to comment.