[creepy] 02/02: Create patch to store plugin config in users home dir
Ross Gammon
ross-guest at moszumanska.debian.org
Mon Nov 24 20:44:36 UTC 2014
This is an automated email from the git hooks/post-receive script.
ross-guest pushed a commit to branch master
in repository creepy.
commit 12283fa275ab2a934f63ce4a52f3b3756517882d
Author: Ross Gammon <rossgammon at mail.dk>
Date: Mon Nov 24 21:41:58 2014 +0100
Create patch to store plugin config in users home dir
---
debian/patches/04-local-config.patch | 75 ++++++++++++++++++++++++++++++++++++
debian/patches/series | 1 +
2 files changed, 76 insertions(+)
diff --git a/debian/patches/04-local-config.patch b/debian/patches/04-local-config.patch
new file mode 100644
index 0000000..2093aa6
--- /dev/null
+++ b/debian/patches/04-local-config.patch
@@ -0,0 +1,75 @@
+Description: Store configuration in a writable place
+ Creepy is currently designed to save its plugin configuration in the current
+ directory, and when installed by the Debian Package to /usr/share the plugins
+ do not work because creepy does not have the required priviledges.
+ .
+ This patch reads the configuration from /usr/share and then when writing the
+ new configuration, writes it to ~/.creepy. Thereafter the configuration is
+ read from ~/.creepy. This keeps the original configuration file intact.
+Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=770591
+Author: Ross Gammon <rossgammon at mail.dk>
+
+--- creepy.orig/creepy/models/InputPlugin.py
++++ creepy/creepy/models/InputPlugin.py
+@@ -4,6 +4,7 @@
+ from configobj import ConfigObj
+ import logging
+ import os
++from os.path import expanduser
+ from utilities import GeneralUtilities
+
+ #set up logging
+@@ -41,8 +42,11 @@
+ pass
+
+ def getPluginDir(self):
+- """FIXME Figure out way to always set it to the directory where the plugin code was found"""
+- return os.path.join('/usr/share/creepy/plugins', self.name)
++ """Returns the installed config file or the local override if it exists"""
++ plugindir = expanduser("~/.creepy/plugins")
++ if not os.path.isdir(os.path.join(plugindir, self.name)):
++ plugindir = '/usr/share/creepy/plugins'
++ return os.path.join(plugindir, self.name)
+
+ def getConfigObj(self, config_filename = None):
+ if config_filename is None:
+@@ -63,6 +67,8 @@
+ return config,options
+
+ def saveConfiguration(self, new_config):
++ if not os.path.isdir(expanduser(os.path.join("~/.creepy/plugins", self.name))):
++ GeneralUtilities.setLocalPluginDir(self.name)
+ config = self.getConfigObj()
+ try:
+ config['string_options'] = new_config['string_options']
+@@ -88,4 +94,4 @@
+ If the developer of the plugin has not implemented this function in the plugin,
+ return the key name to be used in the label
+ '''
+- return key
+\ No newline at end of file
++ return key
+--- creepy.orig/creepy/utilities/GeneralUtilities.py
++++ creepy/creepy/utilities/GeneralUtilities.py
+@@ -21,6 +21,14 @@
+ else: raise
+ return logdir
+
++def setLocalPluginDir(plugin):
++ localplugindir = expanduser(os.path.join("~/.creepy/plugins", plugin))
++ try: os.makedirs(localplugindir)
++ except OSError as e:
++ if e.errno == errno.EEXIST and os.path.isdir(localplugindir): pass
++ else: raise
++ return localplugindir
++
+ def reportProblem():
+ webbrowser.open_new_tab('https://github.com/ilektrojohn/creepy/issues')
+
+@@ -55,4 +63,4 @@
+ ">": ">",
+ "<": "<",
+ }
+- return "".join(html_escape_table.get(c, c) for c in text)
+\ No newline at end of file
++ return "".join(html_escape_table.get(c, c) for c in text)
diff --git a/debian/patches/series b/debian/patches/series
index c3ac3d3..5b0c5f9 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1,3 +1,4 @@
01-log-to-homedir.patch
02-plugin-directory.patch
03-include-dir.patch
+04-local-config.patch
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-grass/creepy.git
More information about the Pkg-grass-devel
mailing list