|
1640
by sebi at glatzor
Code cleanup in the backends |
1 |
#!/usr/bin/env python
|
2 |
# -*- coding: utf-8 -*-
|
|
|
1478
by Michael Vogt
* DistUpgrade/DistUpgradeQuirks.py: add check for ARMv6 or |
3 |
# (c) 2005-2009 Canonical, GPL
|
4 |
||
|
1639
by sebi at glatzor
Simplify the aptdaemon backend |
5 |
from aptdaemon import client, errors |
6 |
from aptdaemon.defer import inline_callbacks |
|
|
1637
by sebi at glatzor
Port AptDaemon backend to latest API of aptdaemon and UpdateManager |
7 |
from aptdaemon.gtkwidgets import AptProgressDialog |
|
1478
by Michael Vogt
* DistUpgrade/DistUpgradeQuirks.py: add check for ARMv6 or |
8 |
|
|
1640
by sebi at glatzor
Code cleanup in the backends |
9 |
from UpdateManager.backend import InstallBackend |
|
1478
by Michael Vogt
* DistUpgrade/DistUpgradeQuirks.py: add check for ARMv6 or |
10 |
|
11 |
||
12 |
class InstallBackendAptdaemon(InstallBackend): |
|
|
1637
by sebi at glatzor
Port AptDaemon backend to latest API of aptdaemon and UpdateManager |
13 |
|
14 |
"""Makes use of aptdaemon to refresh the cache and to install updates."""
|
|
15 |
||
|
1639
by sebi at glatzor
Simplify the aptdaemon backend |
16 |
def __init__(self, window_main): |
17 |
InstallBackend.__init__(self, window_main) |
|
18 |
self.client = client.AptClient() |
|
19 |
||
20 |
@inline_callbacks
|
|
|
1637
by sebi at glatzor
Port AptDaemon backend to latest API of aptdaemon and UpdateManager |
21 |
def update(self): |
|
1639
by sebi at glatzor
Simplify the aptdaemon backend |
22 |
"""Refresh the package list"""
|
23 |
try: |
|
24 |
trans = yield self.client.update_cache(defer=True) |
|
25 |
self._run_in_dialog(trans, self.UPDATE) |
|
26 |
except errors.NotAuthorizedError: |
|
27 |
self.emit("action-done", self.UPDATE) |
|
28 |
except: |
|
29 |
self.emit("action-done", self.UPDATE) |
|
30 |
raise
|
|
|
1637
by sebi at glatzor
Port AptDaemon backend to latest API of aptdaemon and UpdateManager |
31 |
|
|
1639
by sebi at glatzor
Simplify the aptdaemon backend |
32 |
@inline_callbacks
|
|
1637
by sebi at glatzor
Port AptDaemon backend to latest API of aptdaemon and UpdateManager |
33 |
def commit(self, pkgs_install, pkgs_upgrade, close_on_done): |
|
1478
by Michael Vogt
* DistUpgrade/DistUpgradeQuirks.py: add check for ARMv6 or |
34 |
"""Commit a list of package adds and removes"""
|
|
1639
by sebi at glatzor
Simplify the aptdaemon backend |
35 |
try: |
36 |
trans = yield self.client.commit_packages(pkgs_install, [], [], |
|
37 |
[], pkgs_upgrade, |
|
38 |
defer=True) |
|
39 |
self._run_in_dialog(trans, self.INSTALL) |
|
40 |
except errors.NotAuthorizedError: |
|
41 |
self.emit("action-done", self.INSTALL) |
|
42 |
except: |
|
43 |
self.emit("action-done", self.INSTALL) |
|
44 |
raise
|
|
|
1637
by sebi at glatzor
Port AptDaemon backend to latest API of aptdaemon and UpdateManager |
45 |
|
|
1639
by sebi at glatzor
Simplify the aptdaemon backend |
46 |
def _run_in_dialog(self, trans, action): |
|
1637
by sebi at glatzor
Port AptDaemon backend to latest API of aptdaemon and UpdateManager |
47 |
dia = AptProgressDialog(trans, parent=self.window_main) |
48 |
dia.set_icon_name("update-manager") |
|
|
1639
by sebi at glatzor
Simplify the aptdaemon backend |
49 |
dia.connect("finished", self._on_finished, action) |
50 |
dia.run() |
|
|
1637
by sebi at glatzor
Port AptDaemon backend to latest API of aptdaemon and UpdateManager |
51 |
|
|
1639
by sebi at glatzor
Simplify the aptdaemon backend |
52 |
def _on_finished(self, dialog, action): |
53 |
dialog.hide() |
|
|
1637
by sebi at glatzor
Port AptDaemon backend to latest API of aptdaemon and UpdateManager |
54 |
self.emit("action-done", action) |