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
=== modified file 'UpdateManager/UpdateManager.py'
--- UpdateManager/UpdateManager.py 2010-11-12 15:55:48 +0000
+++ UpdateManager/UpdateManager.py 2010-12-06 12:09:54 +0000
@@ -1,6 +1,6 @@
1# UpdateManager.py 1# UpdateManager.py
2# 2#
3# Copyright (c) 2004-2008 Canonical3# Copyright (c) 2004-2010 Canonical
4# 2004 Michiel Sikkes4# 2004 Michiel Sikkes
5# 2005 Martin Willemoes Hansen5# 2005 Martin Willemoes Hansen
6# 2010 Mohamed Amine IL Idrissi6# 2010 Mohamed Amine IL Idrissi
@@ -9,6 +9,7 @@
9# Michael Vogt <mvo@debian.org>9# Michael Vogt <mvo@debian.org>
10# Martin Willemoes Hansen <mwh@sysrq.dk>10# Martin Willemoes Hansen <mwh@sysrq.dk>
11# Mohamed Amine IL Idrissi <ilidrissiamine@gmail.com>11# Mohamed Amine IL Idrissi <ilidrissiamine@gmail.com>
12# Alex Launi <alex.launi@canonical.com>
12# 13#
13# This program is free software; you can redistribute it and/or 14# This program is free software; you can redistribute it and/or
14# modify it under the terms of the GNU General Public License as 15# modify it under the terms of the GNU General Public License as
@@ -124,18 +125,45 @@
124 dialog.destroy()125 dialog.destroy()
125126
126127
127class UpdateManagerDbusControler(dbus.service.Object):128class UpdateManagerDbusController(dbus.service.Object):
128 """ this is a helper to provide the UpdateManagerIFace """129 """ this is a helper to provide the UpdateManagerIFace """
129 def __init__(self, parent, bus_name,130 def __init__(self, parent, bus_name,
130 object_path='/org/freedesktop/UpdateManagerObject'):131 object_path='/org/freedesktop/UpdateManagerObject'):
131 dbus.service.Object.__init__(self, bus_name, object_path)132 dbus.service.Object.__init__(self, bus_name, object_path)
132 self.parent = parent133 self.parent = parent
134 self.alert_watcher = AlertWatcher ()
135 self.alert_watcher.connect("network-alert", self._on_network_alert)
136 self.connected = False
133137
134 @dbus.service.method('org.freedesktop.UpdateManagerIFace')138 @dbus.service.method('org.freedesktop.UpdateManagerIFace')
135 def bringToFront(self):139 def bringToFront(self):
136 self.parent.window_main.present()140 self.parent.window_main.present()
137 return True141 return True
138142
143 @dbus.service.method('org.freedesktop.UpdateManagerIFace')
144 def update(self):
145 try:
146 self.alert_watcher.check_alert_state ()
147 self.parent.invoke_manager(UPDATE)
148 return self.connected
149 except:
150 return False
151
152 @dbus.service.method('org.freedesktop.UpdateManagerIFace')
153 def upgrade(self):
154 try:
155 self.parent.cache.checkFreeSpace()
156 self.parent.invoke_manager(INSTALL)
157 return True
158 except:
159 return False
160
161 def _on_network_alert(self, watcher, state):
162 if state == NM_STATE_CONNECTED:
163 self.connected = True
164 else:
165 self.connected = False
166
139class UpdateManager(SimpleGtkbuilderApp):167class UpdateManager(SimpleGtkbuilderApp):
140168
141 # how many days until u-m warns about manual pressing "check"169 # how many days until u-m warns about manual pressing "check"
@@ -316,7 +344,7 @@
316 except dbus.DBusException, e:344 except dbus.DBusException, e:
317 #print "no listening object (%s) "% e345 #print "no listening object (%s) "% e
318 bus_name = dbus.service.BusName('org.freedesktop.UpdateManager',bus)346 bus_name = dbus.service.BusName('org.freedesktop.UpdateManager',bus)
319 self.dbusControler = UpdateManagerDbusControler(self, bus_name)347 self.dbusControler = UpdateManagerDbusController(self, bus_name)
320348
321349
322 def on_checkbutton_reminder_toggled(self, checkbutton):350 def on_checkbutton_reminder_toggled(self, checkbutton):

Subscribers

People subscribed via source and target branches

to status/vote changes: