[PATCH] Use tuple instead of list for SelectionOption

7 views
Skip to first unread message

Håkon Løvdal

unread,
Feb 9, 2013, 11:18:06 PM2/9/13
to yu...@googlegroups.com, Håkon Løvdal
Use tuple instead of list since it is immutable.

---

I have very little experience with python, but I think using
tuple rather than list is better here? And all other cases of
SelectionOption I found used that.

src/yumexbase/conf.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/yumexbase/conf.py b/src/yumexbase/conf.py
index 0dd99d3..c06d145 100644
--- a/src/yumexbase/conf.py
+++ b/src/yumexbase/conf.py
@@ -64,7 +64,7 @@ class YumexConf(BaseConfig):
no_gpg_check = BoolOption(False)
show_newest_only= BoolOption(True)
remove_requirements= BoolOption(False)
- exit_action = SelectionOption('ask',['ask', 'exit', 'reload'])
+ exit_action = SelectionOption('ask',('ask', 'exit', 'reload'))


class YumexOptions:
--
1.8.1.2

Håkon Løvdal

unread,
Feb 9, 2013, 11:18:05 PM2/9/13
to yu...@googlegroups.com, Håkon Løvdal
There is a polkit configuration example at
http://www.yumex.dk/2012/05/running-yumex-without-typing-password.html. I
really think that it ought to be installed as a template file from the rpm.

Also notice that polkit have changed from *.pkla to *.rules config files,
http://davidz25.blogspot.com/2012/06/authorization-rules-in-polkit.html.

Here is an updated version.

---
Makefile | 3 ++-
misc/10-yumex-without-pw.rules.template | 15 +++++++++++++++
yumex.spec | 1 +
3 files changed, 18 insertions(+), 1 deletion(-)
create mode 100644 misc/10-yumex-without-pw.rules.template

diff --git a/Makefile b/Makefile
index d805d96..52d5c8a 100644
--- a/Makefile
+++ b/Makefile
@@ -27,7 +27,7 @@ install:
mkdir -p $(DESTDIR)/usr/share/pixmaps/yumex
mkdir -p $(DESTDIR)/usr/share/applications
mkdir -p $(DESTDIR)/usr/bin
- mkdir -p $(DESTDIR)/etc
+ mkdir -p $(DESTDIR)/etc/polkit-1/rules.d
mkdir -p $(DESTDIR)/usr/share/polkit-1/actions/
install -m644 COPYING $(DESTDIR)/usr/share/yumex/.
install -m644 $(PIXDIR)/*.png $(DESTDIR)/usr/share/pixmaps/yumex/.
@@ -39,6 +39,7 @@ install:
@rm -f $(MISCDIR)/dk.yumex.backend.policy
intltool-merge -x -u $(PODIR) $(MISCDIR)/dk.yumex.backend.policy.in $(MISCDIR)/dk.yumex.backend.policy
install -m644 $(MISCDIR)/dk.yumex.backend.policy $(DESTDIR)/usr/share/polkit-1/actions/.
+ install -m644 $(MISCDIR)/10-yumex-without-pw.rules.template $(DESTDIR)/etc/polkit-1/rules.d/.
# build & install desktop file with translations
@rm -f $(MISCDIR)/yumex.desktop
intltool-merge -d -u $(PODIR) $(MISCDIR)/yumex.desktop.in $(MISCDIR)/yumex.desktop
diff --git a/misc/10-yumex-without-pw.rules.template b/misc/10-yumex-without-pw.rules.template
new file mode 100644
index 0000000..e3bec06
--- /dev/null
+++ b/misc/10-yumex-without-pw.rules.template
@@ -0,0 +1,15 @@
+// See the polkit(8) man page for more information about configuring polkit.
+
+polkit.addRule(function(action, subject) {
+ var prefix = "dk.yumex.backend.";
+ if (action.id.substring(0, prefix.length) == prefix
+ && subject.user == "put_your_username_here") {
+ return polkit.Result.YES;
+ }
+});
+
+/* replace subject.user == ... with
+
+subject.isInGroup("some_group_name") && subject.active
+
+if you do not want to hard code a user name */
diff --git a/yumex.spec b/yumex.spec
index 4516035..949b30c 100644
--- a/yumex.spec
+++ b/yumex.spec
@@ -80,6 +80,7 @@ rm -rf $RPM_BUILD_ROOT
%config(noreplace) %{_sysconfdir}/yumex.profiles.conf
%config(noreplace) %{_sysconfdir}/yumex.conf
%{_datadir}/polkit-1/actions/dk.yumex.backend.policy
+%{_sysconfdir}/polkit-1/rules.d/10-yumex-without-pw.rules.template
%{_datadir}/applications/*.desktop

%changelog
--
1.8.1.2

Tim Lauridsen

unread,
Feb 10, 2013, 3:25:39 AM2/10/13
to yu...@googlegroups.com, Håkon Løvdal
You are right, but it does not change the functionality :)

Tim

Tim Lauridsen

unread,
Feb 10, 2013, 3:29:41 AM2/10/13
to yu...@googlegroups.com, Håkon Løvdal
A good idea, but maybe it sould go into the %doc directory, I am not sure adding template or example files to the configuration directory is a good idea.
it is better to add to the doc dir as an example and then the user can copy it to the /etc dir and modify it.

Tim 

Håkon Løvdal

unread,
Feb 14, 2013, 6:47:23 PM2/14/13
to Tim Lauridsen, yu...@googlegroups.com
On 10 February 2013 09:29, Tim Lauridsen <tim.la...@gmail.com> wrote:
> A good idea, but maybe it sould go into the %doc directory, I am not sure
> adding template or example files to the configuration directory is a good
> idea.
> it is better to add to the doc dir as an example and then the user can copy
> it to the /etc dir and modify it.
>

The documentation directory will probably be the best choice since Fedora 17
and 18 use different configuration formats, so without some polkit version
detection it becomes somewhat messy to handle.

I will send an updated patch to include both formats.

BR Håkon Løvdal
Reply all
Reply to author
Forward
0 new messages