Skip to content

Commit df90ee2

Browse files
committed
add install updates function
1 parent 8377550 commit df90ee2

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

switch.py

+37
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ def __init__(self, k_app, **kwargs):
6868
self.remove_widget(self.pbase_button)
6969
self.remove_widget(self.shutdown_button)
7070
self.remove_widget(self.popup)
71+
self.remove_widget(self.install_updates_buttons)
7172

7273
#init dbus client
7374
self.bus = dbus.SessionBus()
@@ -158,6 +159,23 @@ def request_shutdown(self, *kwargs):
158159
'''
159160
self.popup.open()
160161

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+
161179
def shutdown(self, reboot):
162180
'''This function should inform the controller to shutdown the device.
163181
It calls the function shutdown() on PBController session bus.
@@ -247,6 +265,18 @@ def try_reach_dbus_PBController(self):
247265
return False
248266
return server
249267

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+
250280
def get_prog_info(self, prog_id):
251281
'''This function gets all the informations from the DB.
252282
@@ -295,6 +325,13 @@ def prog_closed(self, prog_id):
295325
Clock.schedule_once(partial(self.switch.prog_closed, prog_id), 0)
296326
return
297327

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+
298335
DBusGMainLoop(set_as_default=True)
299336

300337
class SwitchApp(App):

switcher.kv

+7
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
progs_layout: progs_layout
88
pbase_button: pbase_button
99
shutdown_button: shutdown_button
10+
install_updates_buttons: install_updates_buttons
1011
popup: popup
1112
height: 150
1213
y: Window.height-150
@@ -47,6 +48,12 @@
4748
text: 'Shutdown'
4849
pos: Window.width-350, pbase_button.y
4950
on_press: root.request_shutdown()
51+
Button:
52+
id: install_updates_buttons
53+
size: 100,50
54+
text: 'Install updates'
55+
pos: Window.width-490, pbase_button.y
56+
on_press: root.install_updates()
5057
BoxLayout:
5158
id: progs_layout
5259
orientation: 'horizontal'

0 commit comments

Comments
 (0)