Merge lp:~alexlauni/update-manager/dbus into lp:update-manager

Proposed by Alex Launi
Status: Merged
Merged at revision: 1989
Proposed branch: lp:~alexlauni/update-manager/dbus
Merge into: lp:update-manager
Diff against target: 75 lines (+31/-3)
1 file modified
UpdateManager/UpdateManager.py (+31/-3)
To merge this branch: bzr merge lp:~alexlauni/update-manager/dbus
Reviewer Review Type Date Requested Status
Ubuntu Core Development Team Pending
Review via email: mp+42827@code.launchpad.net

Description of the change

Adds update and upgrade methods to dbus

To post a comment you must log in.
Revision history for this message
Michael Vogt (mvo) wrote :

Thanks, that looks excellent! I'm happy to merge it, but in order to do that I need to ask
you for signing the canonical contributors agreement. Signing the single-page agreement is very easy and is typically done with a single email. For more information about this agreement, look here: http://www.canonical.com/contributors

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'UpdateManager/UpdateManager.py'
2--- UpdateManager/UpdateManager.py 2010-11-12 15:55:48 +0000
3+++ UpdateManager/UpdateManager.py 2010-12-06 12:09:54 +0000
4@@ -1,6 +1,6 @@
5 # UpdateManager.py
6 #
7-# Copyright (c) 2004-2008 Canonical
8+# Copyright (c) 2004-2010 Canonical
9 # 2004 Michiel Sikkes
10 # 2005 Martin Willemoes Hansen
11 # 2010 Mohamed Amine IL Idrissi
12@@ -9,6 +9,7 @@
13 # Michael Vogt <mvo@debian.org>
14 # Martin Willemoes Hansen <mwh@sysrq.dk>
15 # Mohamed Amine IL Idrissi <ilidrissiamine@gmail.com>
16+# Alex Launi <alex.launi@canonical.com>
17 #
18 # This program is free software; you can redistribute it and/or
19 # modify it under the terms of the GNU General Public License as
20@@ -124,18 +125,45 @@
21 dialog.destroy()
22
23
24-class UpdateManagerDbusControler(dbus.service.Object):
25+class UpdateManagerDbusController(dbus.service.Object):
26 """ this is a helper to provide the UpdateManagerIFace """
27 def __init__(self, parent, bus_name,
28 object_path='/org/freedesktop/UpdateManagerObject'):
29 dbus.service.Object.__init__(self, bus_name, object_path)
30 self.parent = parent
31+ self.alert_watcher = AlertWatcher ()
32+ self.alert_watcher.connect("network-alert", self._on_network_alert)
33+ self.connected = False
34
35 @dbus.service.method('org.freedesktop.UpdateManagerIFace')
36 def bringToFront(self):
37 self.parent.window_main.present()
38 return True
39
40+ @dbus.service.method('org.freedesktop.UpdateManagerIFace')
41+ def update(self):
42+ try:
43+ self.alert_watcher.check_alert_state ()
44+ self.parent.invoke_manager(UPDATE)
45+ return self.connected
46+ except:
47+ return False
48+
49+ @dbus.service.method('org.freedesktop.UpdateManagerIFace')
50+ def upgrade(self):
51+ try:
52+ self.parent.cache.checkFreeSpace()
53+ self.parent.invoke_manager(INSTALL)
54+ return True
55+ except:
56+ return False
57+
58+ def _on_network_alert(self, watcher, state):
59+ if state == NM_STATE_CONNECTED:
60+ self.connected = True
61+ else:
62+ self.connected = False
63+
64 class UpdateManager(SimpleGtkbuilderApp):
65
66 # how many days until u-m warns about manual pressing "check"
67@@ -316,7 +344,7 @@
68 except dbus.DBusException, e:
69 #print "no listening object (%s) "% e
70 bus_name = dbus.service.BusName('org.freedesktop.UpdateManager',bus)
71- self.dbusControler = UpdateManagerDbusControler(self, bus_name)
72+ self.dbusControler = UpdateManagerDbusController(self, bus_name)
73
74
75 def on_checkbutton_reminder_toggled(self, checkbutton):

Subscribers

People subscribed via source and target branches

to status/vote changes: