~ctf/checkbox/bug811177

« back to all changes in this revision

Viewing changes to install/config

  • Committer: ubuntu
  • Date: 2008-01-29 20:32:40 UTC
  • mto: This revision was merged to the branch mainline in revision 154.
  • Revision ID: ubuntu@ubuntu-20080129203240-s2me3vbksz3kghrw
Using *_directory configuration variables.

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
            fp.write("[%s]\n" % DEFAULTSECT)
30
30
            defaults = dict(self._defaults)
31
31
 
 
32
            directories = [d for d in defaults.keys()
 
33
                           if d.endswith("_directory")]
 
34
            if directories:
 
35
                for directory in directories:
 
36
                    value = defaults.pop(directory)
 
37
                    value = str(value).replace('\n', '\n\t')
 
38
                    fp.write("%s = %s\n" % (directory, value))
 
39
 
32
40
            # Write includes first
33
41
            if 'includes' in defaults:
34
42
                key = 'includes'
62
70
    process.
63
71
    """
64
72
    separator = "/"
65
 
    config_base = "/usr/share/%(name)s/configs/%(name)s.ini"
 
73
    configs_base = "/usr/share/%(base_name)s/configs/%(name)s.ini"
 
74
    examples_base = "/usr/share/%(base_name)s/examples/%(name)s.ini"
66
75
 
67
76
    def __init__(self, name, config_path=None, example_path=None, variables=[]):
68
77
        self.name = name
 
78
        self.base_name = re.sub(r"(-gtk|-cli)$", "", name)
69
79
        self._variables = variables
70
 
        self._config_path = config_path or self.config_base % {"name": name}
 
80
        self._configs_path = config_path or self.configs_base \
 
81
            % {"name": name, "base_name": self.base_name}
 
82
        self._examples_path = example_path or self.examples_base \
 
83
            % {"name": name, "base_name": self.base_name}
 
84
 
 
85
        # Create config directory
 
86
        dirname = os.path.dirname(self._configs_path)
 
87
        if not os.path.exists(dirname):
 
88
            os.mkdir(dirname)
71
89
 
72
90
        self._config = Config()
73
91
        if os.environ.get("DEBIAN_HAS_FRONTEND"):
84
102
        Write phase of the config process which takes an output file
85
103
        as argument.
86
104
        """
87
 
        path = self._config_path
88
 
        if path and os.path.isfile(path):
89
 
            self._config.read(path)
 
105
        for path in [self._examples_path, self._configs_path]:
 
106
            if path and os.path.isfile(path):
 
107
                self._config.read(path)
90
108
 
91
109
        # Set configuration variables
92
110
        for variable in self._variables:
94
112
            value = self._debconf.get(variable)
95
113
            self._config.set(section, name, value)
96
114
 
97
 
        # Write config
 
115
        # Write config file
98
116
        descriptor = open(output, "w")
99
117
        self._config.write(descriptor)
100
118
        descriptor.close()
103
121
        """
104
122
        Configure phase of the config process.
105
123
        """
106
 
        path = self._config_path
 
124
        path = self._configs_path
107
125
        if path and os.path.isfile(path):
108
126
            self._config.read(path)
109
127