Merge lp:~mvo/aptdaemon/enable-component into lp:aptdaemon

Proposed by Michael Vogt
Status: Merged
Merge reported by: Michael Vogt
Merged at revision: not available
Proposed branch: lp:~mvo/aptdaemon/enable-component
Merge into: lp:aptdaemon
Diff against target: 69 lines (+41/-0)
2 files modified
aptdaemon/client.py (+12/-0)
aptdaemon/core.py (+29/-0)
To merge this branch: bzr merge lp:~mvo/aptdaemon/enable-component
Reviewer Review Type Date Requested Status
Sebastian Heinlein Approve
Review via email: mp+22386@code.launchpad.net

Description of the change

add a enable_component() functionality for apturl and software-properties

To post a comment you must log in.
lp:~mvo/aptdaemon/enable-component updated
339. By Michael Vogt

rename to EnableDistroComponent

Revision history for this message
Sebastian Heinlein (glatzor) wrote :

Merged some time ago

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'aptdaemon/client.py'
2--- aptdaemon/client.py 2010-03-17 05:29:47 +0000
3+++ aptdaemon/client.py 2010-03-30 07:39:29 +0000
4@@ -585,6 +585,18 @@
5 return self._run_transaction("InstallPackages", [package_names],
6 wait, reply_handler, error_handler)
7
8+ def enable_distro_component(self, component,
9+ reply_handler=None, error_handler=None):
10+ """Add component to the sources list.
11+
12+ Keyword arguments:
13+ component -- a components e.g. main or universe
14+ """
15+ daemon = get_aptdaemon()
16+ return daemon.EnableDistroComponent(component,
17+ reply_handler=reply_handler,
18+ error_handler=error_handler)
19+
20 def add_repository(self, src_type, uri, dist, comps=[], comment="",
21 sourcesfile="", reply_handler=None, error_handler=None):
22 """Add repository to the sources list.
23
24=== modified file 'aptdaemon/core.py'
25--- aptdaemon/core.py 2010-02-10 10:48:21 +0000
26+++ aptdaemon/core.py 2010-03-30 07:39:29 +0000
27@@ -52,6 +52,8 @@
28 from softwareproperties.AptAuth import AptAuth
29 from aptsources.sourceslist import SourcesList
30 import apt_pkg
31+import aptsources
32+import aptsources.distro
33
34 import errors
35 from enums import *
36@@ -1167,6 +1169,33 @@
37 sourcesfile))
38 return deferred
39
40+ def _enable_component(self, component):
41+ """Helper for the enable-component function"""
42+ old_umask = os.umask(0022)
43+ sourceslist = SourcesList()
44+ distro = aptsources.distro.get_distro()
45+ distro.get_sources(sourceslist)
46+ distro.enable_component(component)
47+ sourceslist.save()
48+ os.umask(old_umask)
49+ return True
50+
51+ @dbus_deferred_method(APTDAEMON_DBUS_INTERFACE,
52+ in_signature="s", out_signature="b",
53+ sender_keyword="sender")
54+ def EnableDistroComponent(self, component, sender):
55+ """Enable given component in the sources list.
56+
57+ Keyword arguments:
58+ component -- a components, e.g. main or universe
59+ sender -- the unique D-Bus name of the sender (provided by D-Bus)
60+ """
61+ log.info("EnableComponent() was called: component='%s' ", component)
62+ action = policykit1.PK_ACTION_CHANGE_REPOSITORY
63+ deferred = policykit1.check_authorization_by_name(sender, action)
64+ deferred.add_callback(lambda x: self._enable_component(component))
65+ return deferred
66+
67 @dbus_deferred_method(APTDAEMON_DBUS_INTERFACE,
68 in_signature="", out_signature="as",
69 sender_keyword="sender")

Subscribers

People subscribed via source and target branches

to status/vote changes: