Ensure configuration exists before reading it
offlate/manager.py
49 | 49 | except Exception: | |
50 | 50 | with open(self.confdir + '/conf.json', 'w') as f: | |
51 | 51 | f.write(json.dumps({})) | |
52 | + | self.conf = {} | |
52 | 53 | ||
53 | 54 | class ProjectManager: | |
54 | 55 | def __init__(self): | |
… | |||
168 | 169 | return self.createProject(name, lang, system, info, callback) | |
169 | 170 | ||
170 | 171 | def isConfigured(self, system): | |
172 | + | if not "Generic" in self.settings.conf: | |
173 | + | self.settings.conf["Generic"] = {} | |
171 | 174 | if system == TRANSLATION_PROJECT: | |
172 | 175 | if not "TP" in self.settings.conf: | |
173 | 176 | self.settings.conf["TP"] = {} | |
174 | 177 | settings = self.settings.conf["TP"] | |
175 | 178 | for s in self.settings.conf["Generic"].keys(): | |
179 | + | if not s in self.settings.conf["Generic"]: | |
180 | + | self.settings.conf["Generic"][s] = None | |
176 | 181 | settings[s] = self.settings.conf["Generic"][s] | |
177 | 182 | return TPProject.isConfigured(settings) | |
178 | 183 | elif system == TRANSIFEX: | |
… | |||
180 | 185 | self.settings.conf["Transifex"] = {} | |
181 | 186 | settings = self.settings.conf["Transifex"] | |
182 | 187 | for s in self.settings.conf["Generic"].keys(): | |
188 | + | if not s in self.settings.conf["Generic"]: | |
189 | + | self.settings.conf["Generic"][s] = None | |
183 | 190 | settings[s] = self.settings.conf["Generic"][s] | |
184 | 191 | return TransifexProject.isConfigured(settings) | |
185 | 192 | elif system == GITLAB: | |
… | |||
187 | 194 | self.settings.conf["Gitlab"] = {} | |
188 | 195 | settings = self.settings.conf["Gitlab"] | |
189 | 196 | for s in self.settings.conf["Generic"].keys(): | |
197 | + | if not s in self.settings.conf["Generic"]: | |
198 | + | self.settings.conf["Generic"][s] = None | |
190 | 199 | settings[s] = self.settings.conf["Generic"][s] | |
191 | 200 | return GitlabProject.isConfigured(settings) | |
192 | 201 | else: |