@@ -68,6 +68,7 @@ def __init__(self, k_app, **kwargs):
68
68
self .remove_widget (self .pbase_button )
69
69
self .remove_widget (self .shutdown_button )
70
70
self .remove_widget (self .popup )
71
+ self .remove_widget (self .install_updates_buttons )
71
72
72
73
#init dbus client
73
74
self .bus = dbus .SessionBus ()
@@ -158,6 +159,23 @@ def request_shutdown(self, *kwargs):
158
159
'''
159
160
self .popup .open ()
160
161
162
+ def request_installation (self , * kwargs ):
163
+ '''This function displays the information for the user which should
164
+ decide if he is willing to install the updates
165
+ '''
166
+ if self .install_updates_buttons not in self .children :
167
+ self .add_widget (self .install_updates_buttons )
168
+
169
+ def install_updates (self , * kwargs ):
170
+ '''This function informs PBUpdater to install all softwares
171
+ '''
172
+ server = self .try_reach_dbus_PBUpdater ()
173
+ if server :
174
+ try :
175
+ server .install_updates (dbus_interface = 'org.PB.PBUpdater' )
176
+ except dbus .exceptions .DBusException , e :
177
+ log .warning ('PBase: DBUS Error(PBUpdater.close_prog): ' + str (e ))
178
+
161
179
def shutdown (self , reboot ):
162
180
'''This function should inform the controller to shutdown the device.
163
181
It calls the function shutdown() on PBController session bus.
@@ -247,6 +265,18 @@ def try_reach_dbus_PBController(self):
247
265
return False
248
266
return server
249
267
268
+ def try_reach_dbus_PBUpdater (self ):
269
+ '''Int this function we try to reach the PBController via dbus.
270
+
271
+ :return server: the server instance from dbus.
272
+ '''
273
+ try :
274
+ server = self .bus .get_object ('org.PB.PBUpdater' , '/PBUpdater' )
275
+ except dbus .exceptions .DBusException :
276
+ log .exception ('try reaching dbus PBupdater failed:' )
277
+ return False
278
+ return server
279
+
250
280
def get_prog_info (self , prog_id ):
251
281
'''This function gets all the informations from the DB.
252
282
@@ -295,6 +325,13 @@ def prog_closed(self, prog_id):
295
325
Clock .schedule_once (partial (self .switch .prog_closed , prog_id ), 0 )
296
326
return
297
327
328
+ @dbus .service .method ('org.PB.PBSwitch' )
329
+ def request_installation (self ):
330
+ '''This function gets called when the PBUpdater requests installing updaes
331
+ '''
332
+ Clock .schedule_once (self .switch .request_installation , 0 )
333
+ return
334
+
298
335
DBusGMainLoop (set_as_default = True )
299
336
300
337
class SwitchApp (App ):
0 commit comments