/usr/lib/python3/dist-packages/systemimage/bindings.py is in system-image-common 2.2-0ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | # Copyright (C) 2013-2014 Canonical Ltd.
# Author: Barry Warsaw <barry@ubuntu.com>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 3 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
"""Helpers for when the command line script is used as a DBus client."""
__all__ = [
'DBusClient',
]
import dbus
import logging
from systemimage.reactor import Reactor
log = logging.getLogger('systemimage')
class DBusClient(Reactor):
"""Python bindings to be used as a DBus client."""
def __init__(self):
super().__init__(dbus.SystemBus())
service = self._bus.get_object('com.canonical.SystemImage', '/Service')
self.iface = dbus.Interface(service, 'com.canonical.SystemImage')
self.react_to('UpdateAvailableStatus')
self.react_to('UpdateDownloaded')
self.react_to('UpdateFailed')
self.failed = False
self.is_available = False
self.downloaded = False
def _do_UpdateAvailableStatus(
self, signal, path,
is_available, downloading, available_version, update_size,
last_update_date,
#descriptions,
error_reason):
if error_reason != '':
# Cancel the download, set the failed flag and log the reason.
log.error('CheckForUpdate returned an error: {}', error_reason)
self.failed = True
self.quit()
return
if not is_available:
log.info('No update available')
self.quit()
return
if not downloading:
# We should be in auto download mode, so why aren't we downloading
# the update? Do it manually.
log.info('Update available, downloading manually')
self.iface.DownloadUpdate()
self.is_available = True
def _do_UpdateDownloaded(self, signal, path):
self.downloaded = True
self.quit()
def _do_UpdateFailed(self, signal, path,
consecutive_failure_count, last_reason):
log.error('UpdateFailed: {}', last_reason)
self.failed = True
self.quit()
def check_for_update(self):
# Switch to auto-download mode for this run.
old_value = self.iface.GetSetting('auto_download')
self.iface.SetSetting('auto_download', '2')
self.schedule(self.iface.CheckForUpdate)
self.run()
self.iface.SetSetting('auto_download', old_value)
def _do_Rebooting(self, signal, path, status):
self.quit()
def reboot(self):
self.react_to('Rebooting')
self.schedule(self.iface.ApplyUpdate)
self.run()
|