Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 493520 | Differences between
and this patch

Collapse All | Expand All

(-)a/WebappConfig/config.py (-4 / +3 lines)
Lines 188-194 class BashConfigParser(configparser_ConfigParser): Link Here
188
                    # allow empty values
188
                    # allow empty values
189
                    if optval == '""':
189
                    if optval == '""':
190
                        optval = ''
190
                        optval = ''
191
                    if optval[0] == '"' and optval[-1] == '"' :
191
                    elif optval[0] == '"' and optval[-1] == '"' :
192
                        optval = optval[1:-1]
192
                        optval = optval[1:-1]
193
                    optname = self.optionxform(optname.rstrip())
193
                    optname = self.optionxform(optname.rstrip())
194
                    cursect[optname] = optval
194
                    cursect[optname] = optval
Lines 311-317 class Config: Link Here
311
311
312
    def set_configprotect(self):
312
    def set_configprotect(self):
313
        self.config.set('USER', 'config_protect',
313
        self.config.set('USER', 'config_protect',
314
           wrapper.config_protect(self.maybe_get('cat'),
314
                wrapper.config_protect(self, self.maybe_get('cat'),
315
                                  self.config.get('USER', 'pn'),
315
                                  self.config.get('USER', 'pn'),
316
                                  self.config.get('USER', 'pvr'),
316
                                  self.config.get('USER', 'pvr'),
317
                                  self.config.get('USER', 'package_manager') ))
317
                                  self.config.get('USER', 'package_manager') ))
Lines 822-828 class Config: Link Here
822
                    + self.config.get('USER', 'my_etcconfig') +
822
                    + self.config.get('USER', 'my_etcconfig') +
823
                    ' needs updating!')
823
                    ' needs updating!')
824
824
825
826
        OUT.debug('Successfully parsed configuration file options', 7)
825
        OUT.debug('Successfully parsed configuration file options', 7)
827
826
828
        # Parse the command line
827
        # Parse the command line
Lines 1520-1526 class Config: Link Here
1520
                    'dotconfig' : self.create_dotconfig(),
1519
                    'dotconfig' : self.create_dotconfig(),
1521
                    'ebuild'    : self.create_ebuild(),
1520
                    'ebuild'    : self.create_ebuild(),
1522
                    'db'        : self.create_webapp_db(category, package, version),
1521
                    'db'        : self.create_webapp_db(category, package, version),
1523
                    'protect'   : Protection(category,package,version,
1522
                    'protect'   : Protection(self, category,package,version,
1524
                                    self.config.get('USER','package_manager')),
1523
                                    self.config.get('USER','package_manager')),
1525
                    'content'   : content}
1524
                    'content'   : content}
1526
1525
(-)a/WebappConfig/protect.py (-6 / +14 lines)
Lines 23-28 Link Here
23
import re, os, os.path
23
import re, os, os.path
24
24
25
import WebappConfig.wrapper
25
import WebappConfig.wrapper
26
from WebappConfig.config    import Config
26
27
27
from WebappConfig.debug     import OUT
28
from WebappConfig.debug     import OUT
28
29
Lines 35-46 class Protection: Link Here
35
    A small helper class to handle config protection.
36
    A small helper class to handle config protection.
36
    '''
37
    '''
37
38
38
    def __init__(self, cat, pn, pvr, pm):
39
    def __init__(self, config, cat, pn, pvr, pm):
39
        '''
40
        '''
40
        This is distribution specific so the information is provided by
41
        This is distribution specific so the information is provided by
41
        wrapper.py
42
        wrapper.py
42
        '''
43
        '''
43
        self.config_protect = WebappConfig.wrapper.config_protect(cat, pn, pvr, pm)
44
        self.config = config
45
        self.config_protect = WebappConfig.wrapper.config_protect(self.config, cat, pn, pvr, pm)
44
        self.protect_prefix = WebappConfig.wrapper.protect_prefix
46
        self.protect_prefix = WebappConfig.wrapper.protect_prefix
45
        self.update_command = WebappConfig.wrapper.update_command
47
        self.update_command = WebappConfig.wrapper.update_command
46
48
Lines 70-76 class Protection: Link Here
70
        >>> import os.path
72
        >>> import os.path
71
        >>> here = os.path.dirname(os.path.realpath(__file__))
73
        >>> here = os.path.dirname(os.path.realpath(__file__))
72
74
73
        >>> a = Protection('','horde','3.0.5','portage')
75
        >>> import WebappConfig
76
        >>> config = WebappConfig.config.Config()
77
        >>> a = Protection(config,'','horde','3.0.5','portage')
74
        >>> a.get_protectedname(here + '/tests/testfiles/protect/empty',
78
        >>> a.get_protectedname(here + '/tests/testfiles/protect/empty',
75
        ...                     'test')#doctest: +ELLIPSIS
79
        ...                     'test')#doctest: +ELLIPSIS
76
        '.../tests/testfiles/protect/empty//._cfg0000_test'
80
        '.../tests/testfiles/protect/empty//._cfg0000_test'
Lines 117-124 class Protection: Link Here
117
        Traverses the path of parent directories for the
121
        Traverses the path of parent directories for the
118
        given install dir and checks if any matches the list
122
        given install dir and checks if any matches the list
119
        of config protected files.
123
        of config protected files.
120
124
        
121
        >>> a = Protection('','horde','3.0.5','portage')
125
        >>> import WebappConfig
126
        >>> config = WebappConfig.config.Config()
127
        >>> a = Protection(config,'','horde','3.0.5','portage')
122
128
123
        Add a virtual config protected directory:
129
        Add a virtual config protected directory:
124
130
Lines 177-184 class Protection: Link Here
177
        '''
183
        '''
178
        Instruct the user how to update the application.
184
        Instruct the user how to update the application.
179
185
186
        >>> import WebappConfig
187
        >>> config = WebappConfig.config.Config()
180
        >>> OUT.color_off()
188
        >>> OUT.color_off()
181
        >>> a = Protection('','horde','3.0.5','portage')
189
        >>> a = Protection(config, '','horde','3.0.5','portage')
182
190
183
        >>> a.how_to_update(['/my/strange/htdocs/where/i/installed/x'])
191
        >>> a.how_to_update(['/my/strange/htdocs/where/i/installed/x'])
184
        * One or more files have been config protected
192
        * One or more files have been config protected
(-)a/WebappConfig/wrapper.py (-3 / +10 lines)
Lines 41-47 update_command = 'etc-update' Link Here
41
# Link for bug reporting
41
# Link for bug reporting
42
bugs_link  = 'http://bugs.gentoo.org/'
42
bugs_link  = 'http://bugs.gentoo.org/'
43
43
44
def config_protect(cat, pn, pvr, pm):
44
def config_protect(config, cat, pn, pvr, pm):
45
    def safe_join(a, b):
46
        if a and b:
47
            return a + ' ' + b
48
        if a:
49
            return a
50
        return b
51
45
    '''Return CONFIG_PROTECT (used by protect.py)'''
52
    '''Return CONFIG_PROTECT (used by protect.py)'''
46
    if pm == "portage":
53
    if pm == "portage":
47
        try:
54
        try:
Lines 49-55 def config_protect(cat, pn, pvr, pm): Link Here
49
        except ImportError as e:
56
        except ImportError as e:
50
            OUT.die("Portage libraries not found, quitting:\n%s" % e)
57
            OUT.die("Portage libraries not found, quitting:\n%s" % e)
51
58
52
        return portage.settings['CONFIG_PROTECT']
59
        return safe_join(config.maybe_get("config_protect"),portage.settings['CONFIG_PROTECT'])
53
60
54
    elif pm == "paludis":
61
    elif pm == "paludis":
55
        cmd="cave print-id-environment-variable -b --format '%%v\n' --variable-name CONFIG_PROTECT %s/%s" % (cat,pn)
62
        cmd="cave print-id-environment-variable -b --format '%%v\n' --variable-name CONFIG_PROTECT %s/%s" % (cat,pn)
Lines 60-66 def config_protect(cat, pn, pvr, pm): Link Here
60
        fo.close()
67
        fo.close()
61
        fe.close()
68
        fe.close()
62
69
63
        return ' '.join(result_lines).strip()
70
        return safe_join(config.maybe_get("config_protect"), ' '.join(result_lines).strip())
64
    else:
71
    else:
65
        OUT.die("Unknown package manager: " + pm)
72
        OUT.die("Unknown package manager: " + pm)
66
73

Return to bug 493520