Gentoo Archives: gentoo-commits

From: Devan Franchini <twitch153@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/webapp-config:master commit in: WebappConfig/
Date: Tue, 29 Oct 2013 19:13:36
Message-Id: 1383073728.49445ace79dfeb223d826960ce0fc8539f75c9a8.twitch153@gentoo
1 commit: 49445ace79dfeb223d826960ce0fc8539f75c9a8
2 Author: Devan Franchini <twitch153 <AT> gentoo <DOT> org>
3 AuthorDate: Tue Oct 29 19:08:48 2013 +0000
4 Commit: Devan Franchini <twitch153 <AT> gentoo <DOT> org>
5 CommitDate: Tue Oct 29 19:08:48 2013 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/webapp-config.git;a=commit;h=49445ace
7
8 WebappConfig/config.py: Modifies default interpolation style.
9
10 Due to python3.2 using one interpolation style when running ConfigParser
11 it was necessary to change the interpolation style to the Extended
12 Interpolation style which allows ConfigParser to interpolate such
13 variables that follow the style of ${} in config.py and the config
14 file in /etc/vhosts/webapp-config. For total backwards compatibility
15 we also needed to change the interpolation style being used in config.py
16 because it was using a Basic Interpolation style of %(variable)s.
17 This change has been tested with both python3.2 and python2.7.
18
19 ---
20 WebappConfig/config.py | 54 +++++++++++++++++++++++++++-----------------------
21 1 file changed, 29 insertions(+), 25 deletions(-)
22
23 diff --git a/WebappConfig/config.py b/WebappConfig/config.py
24 index c4b424b..1c09488 100644
25 --- a/WebappConfig/config.py
26 +++ b/WebappConfig/config.py
27 @@ -26,6 +26,7 @@ try:
28 import configparser
29 if sys.version_info >= (3, 2):
30 from configparser import ConfigParser as configparser_ConfigParser
31 + from configparser import ExtendedInterpolation
32 else:
33 from configparser import SafeConfigParser as configparser_ConfigParser
34 except ImportError:
35 @@ -53,7 +54,10 @@ class BashConfigParser(configparser_ConfigParser):
36
37 def __init__(self, defaults=None):
38 self.error_action = 1
39 - configparser_ConfigParser.__init__(self, defaults)
40 + if sys.hexversion >= 0x3000000:
41 + configparser_ConfigParser.__init__(self, defaults, interpolation=ExtendedInterpolation())
42 + else:
43 + configparser_ConfigParser.__init__(self, defaults)
44
45 def on_error(self, action = 0):
46 self.error_action = action
47 @@ -244,7 +248,7 @@ class Config:
48 'vhost_config_uid' : str(os.getuid()),
49 'vhost_config_virtual_files' : 'virtual',
50 'vhost_config_default_dirs' : 'default-owned',
51 - 'vhost_config_dir' : '%(vhost_root)s/conf',
52 + 'vhost_config_dir' : '${vhost_root}/conf',
53 'vhost_htdocs_insecure' : 'htdocs',
54 'vhost_htdocs_secure' : 'htdocs-secure',
55 'vhost_perms_serverowned_dir' : '0775',
56 @@ -266,16 +270,16 @@ class Config:
57 'vhost_server_gid' : 'root',
58 'my_persistroot' : '/var/db/webapps',
59 'wa_installsbase' : 'installs',
60 - 'vhost_root' : '/var/www/%(vhost_hostname)s',
61 - 'g_htdocsdir' : '%(vhost_root)s/%(my_htdocsbase)s',
62 - 'my_appdir' : '%(my_approot)s/%(my_appsuffix)s',
63 - 'my_htdocsdir' : '%(my_appdir)s/htdocs',
64 - 'my_persistdir' : '%(my_persistroot)s/%(my_appsuffix)s',
65 - 'my_hostrootdir' : '%(my_appdir)s/%(my_hostrootbase)s',
66 - 'my_cgibindir' : '%(my_hostrootdir)s/%(my_cgibinbase)s',
67 - 'my_iconsdir' : '%(my_hostrootdir)s/%(my_iconsbase)s',
68 - 'my_errorsdir' : '%(my_hostrootdir)s/%(my_errorsbase)s',
69 - 'g_cgibindir' : '%(vhost_root)s/%(my_cgibinbase)s',
70 + 'vhost_root' : '/var/www/${vhost_hostname}',
71 + 'g_htdocsdir' : '${vhost_root}/${my_htdocsbase}',
72 + 'my_appdir' : '${my_approot}/${my_appsuffix}',
73 + 'my_htdocsdir' : '${my_appdir}/htdocs',
74 + 'my_persistdir' : '${my_persistroot}/${my_appsuffix}',
75 + 'my_hostrootdir' : '${my_appdir}/${my_hostrootbase}',
76 + 'my_cgibindir' : '${my_hostrootdir}/${my_cgibinbase}',
77 + 'my_iconsdir' : '${my_hostrootdir}/${my_iconsbase}',
78 + 'my_errorsdir' : '${my_hostrootdir}/${my_errorsbase}',
79 + 'g_cgibindir' : '${vhost_root}/${my_cgibinbase}',
80 'my_approot' : '/usr/share/webapps',
81 'package_manager' : 'portage',
82 'allow_absolute' : 'no',
83 @@ -283,15 +287,15 @@ class Config:
84 'my_cgibinbase' : 'cgi-bin',
85 'my_iconsbase' : 'icons',
86 'my_errorsbase' : 'error',
87 - 'my_sqlscriptsdir' : '%(my_appdir)s/sqlscripts',
88 - 'my_hookscriptsdir' : '%(my_appdir)s/hooks',
89 - 'my_serverconfigdir': '%(my_appdir)s/conf',
90 - 'wa_configlist' : '%(my_appdir)s/config-files',
91 - 'wa_solist' : '%(my_appdir)s/server-owned-files',
92 - 'wa_virtuallist' : '%(my_appdir)s/virtuals',
93 - 'wa_installs' : '%(my_persistdir)s/%(wa_installsbase)s',
94 + 'my_sqlscriptsdir' : '${my_appdir}/sqlscripts',
95 + 'my_hookscriptsdir' : '${my_appdir}/hooks',
96 + 'my_serverconfigdir': '${my_appdir}/conf',
97 + 'wa_configlist' : '${my_appdir}/config-files',
98 + 'wa_solist' : '${my_appdir}/server-owned-files',
99 + 'wa_virtuallist' : '${my_appdir}/virtuals',
100 + 'wa_installs' : '${my_persistdir}/${wa_installsbase}',
101 'wa_postinstallinfo':
102 - '%(my_appdir)s/post-install-instructions.txt',
103 + '${my_appdir}/post-install-instructions.txt',
104 }
105
106 # Setup basic defaults
107 @@ -338,9 +342,9 @@ class Config:
108 self.config.set('USER', 'persist_suffix', '/'.join([cat,pn,pvr]))
109
110 if os.path.isdir(new_layout):
111 - self.config.set('USER', 'my_appsuffix', '%(cat)s/%(pn)s/%(pvr)s')
112 + self.config.set('USER', 'my_appsuffix', '${cat}/${pn}/${pvr}')
113 elif os.path.isdir(old_layout):
114 - self.config.set('USER', 'my_appsuffix', '%(pn)s/%(pvr)s')
115 + self.config.set('USER', 'my_appsuffix', '${pn}/${pvr}')
116 self.config.set('USER', 'cat', '')
117 else:
118 OUT.die('Unable to determine location of master copy')
119 @@ -349,7 +353,7 @@ class Config:
120 OUT.debug('Checking for old layout', 7)
121
122 if os.path.isdir(old_layout):
123 - self.config.set('USER', 'my_appsuffix', '%(pn)s/%(pvr)s')
124 + self.config.set('USER', 'my_appsuffix', '${pn}/${pvr}')
125 self.config.set('USER', 'cat', '')
126 # no category info at all is available, so drop it from persist_suffix
127 self.config.set('USER', 'persist_suffix', '/'.join([pn,pvr]))
128 @@ -920,10 +924,10 @@ class Config:
129 if (self.config.has_option('USER', 'g_secure') and
130 self.config.getboolean('USER', 'g_secure')):
131 self.config.set('USER', 'my_htdocsbase',
132 - '%(vhost_htdocs_secure)s')
133 + '${vhost_htdocs_secure}')
134 else:
135 self.config.set('USER', 'my_htdocsbase',
136 - '%(vhost_htdocs_insecure)s')
137 + '${vhost_htdocs_insecure}')
138
139 # set the action to be performed
140 work = ['install', 'clean', 'upgrade', 'list_installs',