28:df55ca77e25f | 29:76d04dd67367 |
---|---|
16 import sys | 16 import sys |
17 import os | 17 import os |
18 import re | 18 import re |
19 | 19 |
20 from PyQt4.QtCore import QObject, QTimer, QUrl, QFileInfo | 20 from PyQt4.QtCore import QObject, QTimer, QUrl, QFileInfo |
21 from PyQt4.QtGui import QMenu, QInputDialog, QLineEdit, QDesktopServices, QDialog | 21 from PyQt4.QtGui import QMenu, QInputDialog, QLineEdit, QDesktopServices, \ |
22 QDialog | |
22 from PyQt4.QtCore import QProcess as QProcessPyQt | 23 from PyQt4.QtCore import QProcess as QProcessPyQt |
23 | 24 |
24 from E5Gui.E5Application import e5App | 25 from E5Gui.E5Application import e5App |
25 from E5Gui import E5MessageBox, E5FileDialog | 26 from E5Gui import E5MessageBox, E5FileDialog |
26 from E5Gui.E5Action import E5Action | 27 from E5Gui.E5Action import E5Action |
45 """ | 46 """ |
46 Class transforming the call arguments in case of gnome-terminal. | 47 Class transforming the call arguments in case of gnome-terminal. |
47 """ | 48 """ |
48 def start(self, cmd, args=[], mode=QProcessPyQt.ReadWrite): | 49 def start(self, cmd, args=[], mode=QProcessPyQt.ReadWrite): |
49 """ | 50 """ |
50 Starts the given program (cmd) in a new process, if none is already | 51 Static method to start the given program (cmd) in a new process, if |
51 running, passing the command line arguments in argss. | 52 none is already running, passing the command line arguments in args. |
52 | 53 |
53 @param cmd start the given program cmd (string) | 54 @param cmd start the given program cmd (string) |
54 @keyparam args list of parameters (list of strings) | 55 @keyparam args list of parameters (list of strings) |
55 @keyparam mode access mode (QIODevice.OpenMode) | 56 @keyparam mode access mode (QIODevice.OpenMode) |
56 """ | 57 """ |
60 super(QProcess, self).start(cmd, args, mode) | 61 super(QProcess, self).start(cmd, args, mode) |
61 | 62 |
62 @staticmethod | 63 @staticmethod |
63 def startDetached(cmd, args=[], path=''): | 64 def startDetached(cmd, args=[], path=''): |
64 """ | 65 """ |
65 Starts the given program (cmd) in a new process, if none is already | 66 Static method to start the given program (cmd) in a new process, if |
66 running, passing the command line arguments in argss. | 67 none is already running, passing the command line arguments in args. |
67 | 68 |
68 @param cmd start the given program cmd (string) | 69 @param cmd start the given program cmd (string) |
69 @keyparam args list of parameters (list of strings) | 70 @keyparam args list of parameters (list of strings) |
70 @keyparam path new working directory (string) | 71 @keyparam path new working directory (string) |
71 @return tuple of successful start and process id (boolean, integer) | 72 @return tuple of successful start and process id (boolean, integer) |
110 """ | 111 """ |
111 Public method to define the Django actions. | 112 Public method to define the Django actions. |
112 """ | 113 """ |
113 self.actions = [] | 114 self.actions = [] |
114 | 115 |
115 self.selectSiteAct = E5Action(self.trUtf8('Current Project'), | 116 self.selectSiteAct = E5Action( |
116 "", | 117 self.trUtf8('Current Project'), |
117 0, 0, | 118 "", |
118 self, 'django_current_project') | 119 0, 0, |
120 self, 'django_current_project') | |
119 self.selectSiteAct.setStatusTip(self.trUtf8( | 121 self.selectSiteAct.setStatusTip(self.trUtf8( |
120 'Selects the current project')) | 122 'Selects the current project')) |
121 self.selectSiteAct.setWhatsThis(self.trUtf8( | 123 self.selectSiteAct.setWhatsThis(self.trUtf8( |
122 """<b>Current Project</b>""" | 124 """<b>Current Project</b>""" |
123 """<p>Selects the current project. Used for multi-project """ | 125 """<p>Selects the current project. Used for multi-project """ |
129 | 131 |
130 ############################## | 132 ############################## |
131 ## start actions below ## | 133 ## start actions below ## |
132 ############################## | 134 ############################## |
133 | 135 |
134 self.startProjectAct = E5Action(self.trUtf8('Start Project'), | 136 self.startProjectAct = E5Action( |
135 self.trUtf8('Start &Project'), | 137 self.trUtf8('Start Project'), |
136 0, 0, | 138 self.trUtf8('Start &Project'), |
137 self, 'django_start_project') | 139 0, 0, |
140 self, 'django_start_project') | |
138 self.startProjectAct.setStatusTip(self.trUtf8( | 141 self.startProjectAct.setStatusTip(self.trUtf8( |
139 'Starts a new Django project')) | 142 'Starts a new Django project')) |
140 self.startProjectAct.setWhatsThis(self.trUtf8( | 143 self.startProjectAct.setWhatsThis(self.trUtf8( |
141 """<b>Start Project</b>""" | 144 """<b>Start Project</b>""" |
142 """<p>Starts a new Django project using "django-admin.py startproject".</p>""" | 145 """<p>Starts a new Django project using "django-admin.py""" |
146 """ startproject".</p>""" | |
143 )) | 147 )) |
144 self.startProjectAct.triggered[()].connect(self.__startProject) | 148 self.startProjectAct.triggered[()].connect(self.__startProject) |
145 self.actions.append(self.startProjectAct) | 149 self.actions.append(self.startProjectAct) |
146 | 150 |
147 self.startGlobalApplicationAct = E5Action( | 151 self.startGlobalApplicationAct = E5Action( |
148 self.trUtf8('Start Application (global)'), | 152 self.trUtf8('Start Application (global)'), |
149 self.trUtf8('Start Application (&global)'), | 153 self.trUtf8('Start Application (&global)'), |
150 0, 0, | 154 0, 0, |
151 self, 'django_start_global_application') | 155 self, 'django_start_global_application') |
152 self.startGlobalApplicationAct.setStatusTip(self.trUtf8( | 156 self.startGlobalApplicationAct.setStatusTip(self.trUtf8( |
153 'Starts a new global Django application')) | 157 'Starts a new global Django application')) |
154 self.startGlobalApplicationAct.setWhatsThis(self.trUtf8( | 158 self.startGlobalApplicationAct.setWhatsThis(self.trUtf8( |
155 """<b>Start Application (global)</b>""" | 159 """<b>Start Application (global)</b>""" |
156 """<p>Starts a new global Django application using""" | 160 """<p>Starts a new global Django application using""" |
159 self.startGlobalApplicationAct.triggered[()].connect( | 163 self.startGlobalApplicationAct.triggered[()].connect( |
160 self.__startGlobalApplication) | 164 self.__startGlobalApplication) |
161 self.actions.append(self.startGlobalApplicationAct) | 165 self.actions.append(self.startGlobalApplicationAct) |
162 | 166 |
163 self.startLocalApplicationAct = E5Action( | 167 self.startLocalApplicationAct = E5Action( |
164 self.trUtf8('Start Application (local)'), | 168 self.trUtf8('Start Application (local)'), |
165 self.trUtf8('Start Application (&local)'), | 169 self.trUtf8('Start Application (&local)'), |
166 0, 0, | 170 0, 0, |
167 self, 'django_start_local_application') | 171 self, 'django_start_local_application') |
168 self.startLocalApplicationAct.setStatusTip(self.trUtf8( | 172 self.startLocalApplicationAct.setStatusTip(self.trUtf8( |
169 'Starts a new local Django application')) | 173 'Starts a new local Django application')) |
170 self.startLocalApplicationAct.setWhatsThis(self.trUtf8( | 174 self.startLocalApplicationAct.setWhatsThis(self.trUtf8( |
171 """<b>Start Application (local)</b>""" | 175 """<b>Start Application (local)</b>""" |
172 """<p>Starts a new local Django application using""" | 176 """<p>Starts a new local Django application using""" |
178 | 182 |
179 ############################## | 183 ############################## |
180 ## run actions below ## | 184 ## run actions below ## |
181 ############################## | 185 ############################## |
182 | 186 |
183 self.runServerAct = E5Action(self.trUtf8('Run Server'), | 187 self.runServerAct = E5Action( |
184 self.trUtf8('Run &Server'), | 188 self.trUtf8('Run Server'), |
185 0, 0, | 189 self.trUtf8('Run &Server'), |
186 self, 'django_run_server') | 190 0, 0, |
191 self, 'django_run_server') | |
187 self.runServerAct.setStatusTip(self.trUtf8( | 192 self.runServerAct.setStatusTip(self.trUtf8( |
188 'Starts the Django Web server')) | 193 'Starts the Django Web server')) |
189 self.runServerAct.setWhatsThis(self.trUtf8( | 194 self.runServerAct.setWhatsThis(self.trUtf8( |
190 """<b>Run Server</b>""" | 195 """<b>Run Server</b>""" |
191 """<p>Starts the Django Web server using "manage.py runserver".</p>""" | 196 """<p>Starts the Django Web server using "manage.py""" |
197 """ runserver".</p>""" | |
192 )) | 198 )) |
193 self.runServerAct.triggered[()].connect(self.__runServer) | 199 self.runServerAct.triggered[()].connect(self.__runServer) |
194 self.actions.append(self.runServerAct) | 200 self.actions.append(self.runServerAct) |
195 | 201 |
196 self.runBrowserAct = E5Action(self.trUtf8('Run Web-Browser'), | 202 self.runBrowserAct = E5Action( |
197 self.trUtf8('Run &Web-Browser'), | 203 self.trUtf8('Run Web-Browser'), |
198 0, 0, | 204 self.trUtf8('Run &Web-Browser'), |
199 self, 'django_run_browser') | 205 0, 0, |
206 self, 'django_run_browser') | |
200 self.runBrowserAct.setStatusTip(self.trUtf8( | 207 self.runBrowserAct.setStatusTip(self.trUtf8( |
201 'Starts the default Web-Browser with the URL of the Django Web server')) | 208 'Starts the default Web-Browser with the URL of the Django Web' |
209 ' server')) | |
202 self.runBrowserAct.setWhatsThis(self.trUtf8( | 210 self.runBrowserAct.setWhatsThis(self.trUtf8( |
203 """<b>Run Web-Browser</b>""" | 211 """<b>Run Web-Browser</b>""" |
204 """<p>Starts the default Web-Browser with the URL of the """ | 212 """<p>Starts the default Web-Browser with the URL of the """ |
205 """Django Web server.</p>""" | 213 """Django Web server.</p>""" |
206 )) | 214 )) |
209 | 217 |
210 ############################## | 218 ############################## |
211 ## caching actions below ## | 219 ## caching actions below ## |
212 ############################## | 220 ############################## |
213 | 221 |
214 self.createCacheTableAct = E5Action(self.trUtf8('Create Cache Tables'), | 222 self.createCacheTableAct = E5Action( |
215 self.trUtf8('C&reate Cache Tables'), | 223 self.trUtf8('Create Cache Tables'), |
216 0, 0, | 224 self.trUtf8('C&reate Cache Tables'), |
217 self, 'django_create_cache_tables') | 225 0, 0, |
226 self, 'django_create_cache_tables') | |
218 self.createCacheTableAct.setStatusTip(self.trUtf8( | 227 self.createCacheTableAct.setStatusTip(self.trUtf8( |
219 'Creates the tables needed to use the SQL cache backend')) | 228 'Creates the tables needed to use the SQL cache backend')) |
220 self.createCacheTableAct.setWhatsThis(self.trUtf8( | 229 self.createCacheTableAct.setWhatsThis(self.trUtf8( |
221 """<b>Create Cache Tables</b>""" | 230 """<b>Create Cache Tables</b>""" |
222 """<p>Creates the tables needed to use the SQL cache backend.</p>""" | 231 """<p>Creates the tables needed to use the SQL cache""" |
223 )) | 232 """ backend.</p>""" |
224 self.createCacheTableAct.triggered[()].connect(self.__createCacheTables) | 233 )) |
234 self.createCacheTableAct.triggered[()].connect( | |
235 self.__createCacheTables) | |
225 self.actions.append(self.createCacheTableAct) | 236 self.actions.append(self.createCacheTableAct) |
226 | 237 |
227 ############################## | 238 ############################## |
228 ## help action below ## | 239 ## help action below ## |
229 ############################## | 240 ############################## |
230 | 241 |
231 self.helpAct = E5Action(self.trUtf8('Help'), | 242 self.helpAct = E5Action( |
232 self.trUtf8('&Help'), | 243 self.trUtf8('Help'), |
233 0, 0, | 244 self.trUtf8('&Help'), |
234 self, 'django_help') | 245 0, 0, |
246 self, 'django_help') | |
235 self.helpAct.setStatusTip(self.trUtf8( | 247 self.helpAct.setStatusTip(self.trUtf8( |
236 'Shows the Django help index')) | 248 'Shows the Django help index')) |
237 self.helpAct.setWhatsThis(self.trUtf8( | 249 self.helpAct.setWhatsThis(self.trUtf8( |
238 """<b>Help</b>""" | 250 """<b>Help</b>""" |
239 """<p>Shows the Django help index page.</p>""" | 251 """<p>Shows the Django help index page.</p>""" |
243 | 255 |
244 ############################## | 256 ############################## |
245 ## about action below ## | 257 ## about action below ## |
246 ############################## | 258 ############################## |
247 | 259 |
248 self.aboutDjangoAct = E5Action(self.trUtf8('About Django'), | 260 self.aboutDjangoAct = E5Action( |
249 self.trUtf8('About D&jango'), | 261 self.trUtf8('About Django'), |
250 0, 0, | 262 self.trUtf8('About D&jango'), |
251 self, 'django_about') | 263 0, 0, |
264 self, 'django_about') | |
252 self.aboutDjangoAct.setStatusTip(self.trUtf8( | 265 self.aboutDjangoAct.setStatusTip(self.trUtf8( |
253 'Shows some information about Django')) | 266 'Shows some information about Django')) |
254 self.aboutDjangoAct.setWhatsThis(self.trUtf8( | 267 self.aboutDjangoAct.setWhatsThis(self.trUtf8( |
255 """<b>About Django</b>""" | 268 """<b>About Django</b>""" |
256 """<p>Shows some information about Django.</p>""" | 269 """<p>Shows some information about Django.</p>""" |
267 | 280 |
268 def __initDatabaseActions(self): | 281 def __initDatabaseActions(self): |
269 """ | 282 """ |
270 Private method to define the database related actions. | 283 Private method to define the database related actions. |
271 """ | 284 """ |
272 self.syncDatabaseAct = E5Action(self.trUtf8('Synchronize'), | 285 self.syncDatabaseAct = E5Action( |
273 self.trUtf8('&Synchronize'), | 286 self.trUtf8('Synchronize'), |
274 0, 0, | 287 self.trUtf8('&Synchronize'), |
275 self, 'django_database_syncdb') | 288 0, 0, |
289 self, 'django_database_syncdb') | |
276 self.syncDatabaseAct.setStatusTip(self.trUtf8( | 290 self.syncDatabaseAct.setStatusTip(self.trUtf8( |
277 'Synchronizes the database')) | 291 'Synchronizes the database')) |
278 self.syncDatabaseAct.setWhatsThis(self.trUtf8( | 292 self.syncDatabaseAct.setWhatsThis(self.trUtf8( |
279 """<b>Synchronize</b>""" | 293 """<b>Synchronize</b>""" |
280 """<p>Synchronizes the database.</p>""" | 294 """<p>Synchronizes the database.</p>""" |
281 )) | 295 )) |
282 self.syncDatabaseAct.triggered[()].connect(self.__databaseSynchronize) | 296 self.syncDatabaseAct.triggered[()].connect(self.__databaseSynchronize) |
283 self.actions.append(self.syncDatabaseAct) | 297 self.actions.append(self.syncDatabaseAct) |
284 | 298 |
285 self.inspectDatabaseAct = E5Action(self.trUtf8('Introspect'), | 299 self.inspectDatabaseAct = E5Action( |
286 self.trUtf8('&Introspect'), | 300 self.trUtf8('Introspect'), |
287 0, 0, | 301 self.trUtf8('&Introspect'), |
288 self, 'django_database_inspect') | 302 0, 0, |
303 self, 'django_database_inspect') | |
289 self.inspectDatabaseAct.setStatusTip(self.trUtf8( | 304 self.inspectDatabaseAct.setStatusTip(self.trUtf8( |
290 'Introspects the database tables and outputs a Django model module')) | 305 'Introspects the database tables and outputs a Django model' |
306 ' module')) | |
291 self.inspectDatabaseAct.setWhatsThis(self.trUtf8( | 307 self.inspectDatabaseAct.setWhatsThis(self.trUtf8( |
292 """<b>Introspect</b>""" | 308 """<b>Introspect</b>""" |
293 """<p>Introspects the database tables and outputs a """ | 309 """<p>Introspects the database tables and outputs a """ |
294 """Django model module.</p>""" | 310 """Django model module.</p>""" |
295 )) | 311 )) |
296 self.inspectDatabaseAct.triggered[()].connect(self.__databaseInspect) | 312 self.inspectDatabaseAct.triggered[()].connect(self.__databaseInspect) |
297 self.actions.append(self.inspectDatabaseAct) | 313 self.actions.append(self.inspectDatabaseAct) |
298 | 314 |
299 self.flushDatabaseAct = E5Action(self.trUtf8('Flush'), | 315 self.flushDatabaseAct = E5Action( |
300 self.trUtf8('&Flush'), | 316 self.trUtf8('Flush'), |
301 0, 0, | 317 self.trUtf8('&Flush'), |
302 self, 'django_database_flush') | 318 0, 0, |
319 self, 'django_database_flush') | |
303 self.flushDatabaseAct.setStatusTip(self.trUtf8( | 320 self.flushDatabaseAct.setStatusTip(self.trUtf8( |
304 'Returns all database tables to the state just after their installation')) | 321 'Returns all database tables to the state just after their' |
322 ' installation')) | |
305 self.flushDatabaseAct.setWhatsThis(self.trUtf8( | 323 self.flushDatabaseAct.setWhatsThis(self.trUtf8( |
306 """<b>Flush</b>""" | 324 """<b>Flush</b>""" |
307 """<p>Returns all database tables to the state """ | 325 """<p>Returns all database tables to the state """ |
308 """just after their installation.</p>""" | 326 """just after their installation.</p>""" |
309 )) | 327 )) |
310 self.flushDatabaseAct.triggered[()].connect(self.__databaseFlush) | 328 self.flushDatabaseAct.triggered[()].connect(self.__databaseFlush) |
311 self.actions.append(self.flushDatabaseAct) | 329 self.actions.append(self.flushDatabaseAct) |
312 | 330 |
313 self.databaseClientAct = E5Action(self.trUtf8('Start Client Console'), | 331 self.databaseClientAct = E5Action( |
314 self.trUtf8('Start &Client Console'), | 332 self.trUtf8('Start Client Console'), |
315 0, 0, | 333 self.trUtf8('Start &Client Console'), |
316 self, 'django_database_client') | 334 0, 0, |
335 self, 'django_database_client') | |
317 self.databaseClientAct.setStatusTip(self.trUtf8( | 336 self.databaseClientAct.setStatusTip(self.trUtf8( |
318 'Starts a console window for the database client')) | 337 'Starts a console window for the database client')) |
319 self.databaseClientAct.setWhatsThis(self.trUtf8( | 338 self.databaseClientAct.setWhatsThis(self.trUtf8( |
320 """<b>Start Client Console</b>""" | 339 """<b>Start Client Console</b>""" |
321 """<p>Starts a console window for the database client.</p>""" | 340 """<p>Starts a console window for the database client.</p>""" |
325 | 344 |
326 def __initDatabaseSqlActions(self): | 345 def __initDatabaseSqlActions(self): |
327 """ | 346 """ |
328 Private method to define the database SQL related actions. | 347 Private method to define the database SQL related actions. |
329 """ | 348 """ |
330 self.databaseSqlCreateTablesAct = E5Action(self.trUtf8('Create Tables'), | 349 self.databaseSqlCreateTablesAct = E5Action( |
331 self.trUtf8('Create &Tables'), | 350 self.trUtf8('Create Tables'), |
332 0, 0, | 351 self.trUtf8('Create &Tables'), |
333 self, 'django_database_sql_create_tables') | 352 0, 0, |
353 self, 'django_database_sql_create_tables') | |
334 self.databaseSqlCreateTablesAct.setStatusTip(self.trUtf8( | 354 self.databaseSqlCreateTablesAct.setStatusTip(self.trUtf8( |
335 'Prints the CREATE TABLE SQL statements for one or more applications')) | 355 'Prints the CREATE TABLE SQL statements for one or more' |
356 ' applications')) | |
336 self.databaseSqlCreateTablesAct.setWhatsThis(self.trUtf8( | 357 self.databaseSqlCreateTablesAct.setWhatsThis(self.trUtf8( |
337 """<b>Create Tables</b>""" | 358 """<b>Create Tables</b>""" |
338 """<p>Prints the CREATE TABLE SQL statements for one or """ | 359 """<p>Prints the CREATE TABLE SQL statements for one or """ |
339 """more applications.</p>""" | 360 """more applications.</p>""" |
340 )) | 361 )) |
341 self.databaseSqlCreateTablesAct.triggered[()].connect( | 362 self.databaseSqlCreateTablesAct.triggered[()].connect( |
342 self.__databaseSqlCreateTables) | 363 self.__databaseSqlCreateTables) |
343 self.actions.append(self.databaseSqlCreateTablesAct) | 364 self.actions.append(self.databaseSqlCreateTablesAct) |
344 | 365 |
345 self.databaseSqlCreateIndexesAct = E5Action(self.trUtf8('Create Indexes'), | 366 self.databaseSqlCreateIndexesAct = E5Action( |
346 self.trUtf8('Create &Indexes'), | 367 self.trUtf8('Create Indexes'), |
347 0, 0, | 368 self.trUtf8('Create &Indexes'), |
348 self, 'django_database_sql_create_indexes') | 369 0, 0, |
370 self, 'django_database_sql_create_indexes') | |
349 self.databaseSqlCreateIndexesAct.setStatusTip(self.trUtf8( | 371 self.databaseSqlCreateIndexesAct.setStatusTip(self.trUtf8( |
350 'Prints the CREATE INDEX SQL statements for one or more applications')) | 372 'Prints the CREATE INDEX SQL statements for one or more' |
373 ' applications')) | |
351 self.databaseSqlCreateIndexesAct.setWhatsThis(self.trUtf8( | 374 self.databaseSqlCreateIndexesAct.setWhatsThis(self.trUtf8( |
352 """<b>Create Indexes</b>""" | 375 """<b>Create Indexes</b>""" |
353 """<p>Prints the CREATE INDEX SQL statements for one or """ | 376 """<p>Prints the CREATE INDEX SQL statements for one or """ |
354 """more applications.</p>""" | 377 """more applications.</p>""" |
355 )) | 378 )) |
356 self.databaseSqlCreateIndexesAct.triggered[()].connect( | 379 self.databaseSqlCreateIndexesAct.triggered[()].connect( |
357 self.__databaseSqlCreateIndexes) | 380 self.__databaseSqlCreateIndexes) |
358 self.actions.append(self.databaseSqlCreateIndexesAct) | 381 self.actions.append(self.databaseSqlCreateIndexesAct) |
359 | 382 |
360 self.databaseSqlCreateEverythingAct = E5Action(self.trUtf8('Create Everything'), | 383 self.databaseSqlCreateEverythingAct = E5Action( |
361 self.trUtf8('Create &Everything'), | 384 self.trUtf8('Create Everything'), |
362 0, 0, | 385 self.trUtf8('Create &Everything'), |
363 self, 'django_database_sql_create_everything') | 386 0, 0, |
387 self, 'django_database_sql_create_everything') | |
364 self.databaseSqlCreateEverythingAct.setStatusTip(self.trUtf8( | 388 self.databaseSqlCreateEverythingAct.setStatusTip(self.trUtf8( |
365 'Prints the CREATE ... SQL statements for one or more applications')) | 389 'Prints the CREATE ... SQL statements for one or more' |
390 ' applications')) | |
366 self.databaseSqlCreateEverythingAct.setWhatsThis(self.trUtf8( | 391 self.databaseSqlCreateEverythingAct.setWhatsThis(self.trUtf8( |
367 """<b>Create Everything</b>""" | 392 """<b>Create Everything</b>""" |
368 """<p>Prints the CREATE TABLE, custom SQL and CREATE INDEX SQL """ | 393 """<p>Prints the CREATE TABLE, custom SQL and CREATE INDEX SQL """ |
369 """statements for one or more applications.</p>""" | 394 """statements for one or more applications.</p>""" |
370 )) | 395 )) |
371 self.databaseSqlCreateEverythingAct.triggered[()].connect( | 396 self.databaseSqlCreateEverythingAct.triggered[()].connect( |
372 self.__databaseSqlCreateEverything) | 397 self.__databaseSqlCreateEverything) |
373 self.actions.append(self.databaseSqlCreateEverythingAct) | 398 self.actions.append(self.databaseSqlCreateEverythingAct) |
374 | 399 |
375 self.databaseSqlCustomAct = E5Action(self.trUtf8('Custom Statements'), | 400 self.databaseSqlCustomAct = E5Action( |
376 self.trUtf8('&Custom Statements'), | 401 self.trUtf8('Custom Statements'), |
377 0, 0, | 402 self.trUtf8('&Custom Statements'), |
378 self, 'django_database_sql_custom') | 403 0, 0, |
404 self, 'django_database_sql_custom') | |
379 self.databaseSqlCustomAct.setStatusTip(self.trUtf8( | 405 self.databaseSqlCustomAct.setStatusTip(self.trUtf8( |
380 'Prints the custom table modifying SQL statements for ' | 406 'Prints the custom table modifying SQL statements for ' |
381 'one or more applications')) | 407 'one or more applications')) |
382 self.databaseSqlCustomAct.setWhatsThis(self.trUtf8( | 408 self.databaseSqlCustomAct.setWhatsThis(self.trUtf8( |
383 """<b>Custom Statements</b>""" | 409 """<b>Custom Statements</b>""" |
386 )) | 412 )) |
387 self.databaseSqlCustomAct.triggered[()].connect( | 413 self.databaseSqlCustomAct.triggered[()].connect( |
388 self.__databaseSqlCustom) | 414 self.__databaseSqlCustom) |
389 self.actions.append(self.databaseSqlCustomAct) | 415 self.actions.append(self.databaseSqlCustomAct) |
390 | 416 |
391 self.databaseSqlDropTablesAct = E5Action(self.trUtf8('Drop Tables'), | 417 self.databaseSqlDropTablesAct = E5Action( |
392 self.trUtf8('&Drop Tables'), | 418 self.trUtf8('Drop Tables'), |
393 0, 0, | 419 self.trUtf8('&Drop Tables'), |
394 self, 'django_database_sql_drop_tables') | 420 0, 0, |
421 self, 'django_database_sql_drop_tables') | |
395 self.databaseSqlDropTablesAct.setStatusTip(self.trUtf8( | 422 self.databaseSqlDropTablesAct.setStatusTip(self.trUtf8( |
396 'Prints the DROP TABLE SQL statements for ' | 423 'Prints the DROP TABLE SQL statements for ' |
397 'one or more applications')) | 424 'one or more applications')) |
398 self.databaseSqlDropTablesAct.setWhatsThis(self.trUtf8( | 425 self.databaseSqlDropTablesAct.setWhatsThis(self.trUtf8( |
399 """<b>Drop Tables</b>""" | 426 """<b>Drop Tables</b>""" |
402 )) | 429 )) |
403 self.databaseSqlDropTablesAct.triggered[()].connect( | 430 self.databaseSqlDropTablesAct.triggered[()].connect( |
404 self.__databaseSqlDropTables) | 431 self.__databaseSqlDropTables) |
405 self.actions.append(self.databaseSqlDropTablesAct) | 432 self.actions.append(self.databaseSqlDropTablesAct) |
406 | 433 |
407 self.databaseSqlFlushAct = E5Action(self.trUtf8('Flush Database'), | 434 self.databaseSqlFlushAct = E5Action( |
408 self.trUtf8('&Flush Database'), | 435 self.trUtf8('Flush Database'), |
409 0, 0, | 436 self.trUtf8('&Flush Database'), |
410 self, 'django_database_sql_flush_database') | 437 0, 0, |
438 self, 'django_database_sql_flush_database') | |
411 self.databaseSqlFlushAct.setStatusTip(self.trUtf8( | 439 self.databaseSqlFlushAct.setStatusTip(self.trUtf8( |
412 'Prints a list of statements to return all database tables to the state ' | 440 'Prints a list of statements to return all database tables to the' |
413 'just after their installation')) | 441 ' state just after their installation')) |
414 self.databaseSqlFlushAct.setWhatsThis(self.trUtf8( | 442 self.databaseSqlFlushAct.setWhatsThis(self.trUtf8( |
415 """<b>Flush Database</b>""" | 443 """<b>Flush Database</b>""" |
416 """<p>Prints a list of statements to return all database tables to """ | 444 """<p>Prints a list of statements to return all database tables""" |
417 """the state just after their installation.</p>""" | 445 """ to the state just after their installation.</p>""" |
418 )) | 446 )) |
419 self.databaseSqlFlushAct.triggered[()].connect( | 447 self.databaseSqlFlushAct.triggered[()].connect( |
420 self.__databaseSqlFlushDatabase) | 448 self.__databaseSqlFlushDatabase) |
421 self.actions.append(self.databaseSqlFlushAct) | 449 self.actions.append(self.databaseSqlFlushAct) |
422 | 450 |
423 self.databaseSqlResetSeqAct = E5Action(self.trUtf8('Reset Sequences'), | 451 self.databaseSqlResetSeqAct = E5Action( |
424 self.trUtf8('Reset &Sequences'), | 452 self.trUtf8('Reset Sequences'), |
425 0, 0, | 453 self.trUtf8('Reset &Sequences'), |
426 self, 'django_database_sql_reset_sequences') | 454 0, 0, |
455 self, 'django_database_sql_reset_sequences') | |
427 self.databaseSqlResetSeqAct.setStatusTip(self.trUtf8( | 456 self.databaseSqlResetSeqAct.setStatusTip(self.trUtf8( |
428 'Prints the SQL statements for resetting sequences for ' | 457 'Prints the SQL statements for resetting sequences for ' |
429 'one or more applications')) | 458 'one or more applications')) |
430 self.databaseSqlResetSeqAct.setWhatsThis(self.trUtf8( | 459 self.databaseSqlResetSeqAct.setWhatsThis(self.trUtf8( |
431 """<b>Reset Sequences</b>""" | 460 """<b>Reset Sequences</b>""" |
438 | 467 |
439 def __initToolsActions(self): | 468 def __initToolsActions(self): |
440 """ | 469 """ |
441 Private method to define the tool actions. | 470 Private method to define the tool actions. |
442 """ | 471 """ |
443 self.diffSettingsAct = E5Action(self.trUtf8('Diff Settings'), | 472 self.diffSettingsAct = E5Action( |
444 self.trUtf8('&Diff Settings'), | 473 self.trUtf8('Diff Settings'), |
445 0, 0, | 474 self.trUtf8('&Diff Settings'), |
446 self, 'django_tools_diffsettings') | 475 0, 0, |
476 self, 'django_tools_diffsettings') | |
447 self.diffSettingsAct.setStatusTip(self.trUtf8( | 477 self.diffSettingsAct.setStatusTip(self.trUtf8( |
448 'Shows the modification made to the settings')) | 478 'Shows the modification made to the settings')) |
449 self.diffSettingsAct.setWhatsThis(self.trUtf8( | 479 self.diffSettingsAct.setWhatsThis(self.trUtf8( |
450 """<b>Diff Settings</b>""" | 480 """<b>Diff Settings</b>""" |
451 """<p>Shows the modification made to the settings.</p>""" | 481 """<p>Shows the modification made to the settings.</p>""" |
452 )) | 482 )) |
453 self.diffSettingsAct.triggered[()].connect(self.__diffSettings) | 483 self.diffSettingsAct.triggered[()].connect(self.__diffSettings) |
454 self.actions.append(self.diffSettingsAct) | 484 self.actions.append(self.diffSettingsAct) |
455 | 485 |
456 self.cleanupAct = E5Action(self.trUtf8('Cleanup'), | 486 self.cleanupAct = E5Action( |
457 self.trUtf8('&Cleanup'), | 487 self.trUtf8('Cleanup'), |
458 0, 0, | 488 self.trUtf8('&Cleanup'), |
459 self, 'django_tools_cleanup') | 489 0, 0, |
490 self, 'django_tools_cleanup') | |
460 self.cleanupAct.setStatusTip(self.trUtf8( | 491 self.cleanupAct.setStatusTip(self.trUtf8( |
461 'Cleans out old data from the database')) | 492 'Cleans out old data from the database')) |
462 self.cleanupAct.setWhatsThis(self.trUtf8( | 493 self.cleanupAct.setWhatsThis(self.trUtf8( |
463 """<b>Cleanup</b>""" | 494 """<b>Cleanup</b>""" |
464 """<p>Cleans out old data from the database.</p>""" | 495 """<p>Cleans out old data from the database.</p>""" |
465 )) | 496 )) |
466 self.cleanupAct.triggered[()].connect(self.__cleanup) | 497 self.cleanupAct.triggered[()].connect(self.__cleanup) |
467 self.actions.append(self.cleanupAct) | 498 self.actions.append(self.cleanupAct) |
468 | 499 |
469 self.validateAct = E5Action(self.trUtf8('Validate'), | 500 self.validateAct = E5Action( |
470 self.trUtf8('&Validate'), | 501 self.trUtf8('Validate'), |
471 0, 0, | 502 self.trUtf8('&Validate'), |
472 self, 'django_tools_validate') | 503 0, 0, |
504 self, 'django_tools_validate') | |
473 self.validateAct.setStatusTip(self.trUtf8( | 505 self.validateAct.setStatusTip(self.trUtf8( |
474 'Validates all installed models')) | 506 'Validates all installed models')) |
475 self.validateAct.setWhatsThis(self.trUtf8( | 507 self.validateAct.setWhatsThis(self.trUtf8( |
476 """<b>Validate</b>""" | 508 """<b>Validate</b>""" |
477 """<p>Validates all installed models.</p>""" | 509 """<p>Validates all installed models.</p>""" |
478 )) | 510 )) |
479 self.validateAct.triggered[()].connect(self.__validate) | 511 self.validateAct.triggered[()].connect(self.__validate) |
480 self.actions.append(self.validateAct) | 512 self.actions.append(self.validateAct) |
481 | 513 |
482 self.runPythonShellAct = E5Action(self.trUtf8('Start Python Console'), | 514 self.runPythonShellAct = E5Action( |
483 self.trUtf8('Start &Python Console'), | 515 self.trUtf8('Start Python Console'), |
484 0, 0, | 516 self.trUtf8('Start &Python Console'), |
485 self, 'django_tools_pythonconsole') | 517 0, 0, |
518 self, 'django_tools_pythonconsole') | |
486 self.runPythonShellAct.setStatusTip(self.trUtf8( | 519 self.runPythonShellAct.setStatusTip(self.trUtf8( |
487 'Starts a Python interactive interpreter')) | 520 'Starts a Python interactive interpreter')) |
488 self.runPythonShellAct.setWhatsThis(self.trUtf8( | 521 self.runPythonShellAct.setWhatsThis(self.trUtf8( |
489 """<b>Start Python Console</b>""" | 522 """<b>Start Python Console</b>""" |
490 """<p>Starts a Python interactive interpreter.</p>""" | 523 """<p>Starts a Python interactive interpreter.</p>""" |
494 | 527 |
495 def __initTestingActions(self): | 528 def __initTestingActions(self): |
496 """ | 529 """ |
497 Private method to define the testing actions. | 530 Private method to define the testing actions. |
498 """ | 531 """ |
499 self.dumpDataAct = E5Action(self.trUtf8('Dump Data'), | 532 self.dumpDataAct = E5Action( |
500 self.trUtf8('&Dump Data'), | 533 self.trUtf8('Dump Data'), |
501 0, 0, | 534 self.trUtf8('&Dump Data'), |
502 self, 'django_tools_dumpdata') | 535 0, 0, |
536 self, 'django_tools_dumpdata') | |
503 self.dumpDataAct.setStatusTip(self.trUtf8( | 537 self.dumpDataAct.setStatusTip(self.trUtf8( |
504 'Dump the database data to a fixture')) | 538 'Dump the database data to a fixture')) |
505 self.dumpDataAct.setWhatsThis(self.trUtf8( | 539 self.dumpDataAct.setWhatsThis(self.trUtf8( |
506 """<b>Dump Data</b>""" | 540 """<b>Dump Data</b>""" |
507 """<p>Dump the database data to a fixture.</p>""" | 541 """<p>Dump the database data to a fixture.</p>""" |
508 )) | 542 )) |
509 self.dumpDataAct.triggered[()].connect(self.__dumpData) | 543 self.dumpDataAct.triggered[()].connect(self.__dumpData) |
510 self.actions.append(self.dumpDataAct) | 544 self.actions.append(self.dumpDataAct) |
511 | 545 |
512 self.loadDataAct = E5Action(self.trUtf8('Load Data'), | 546 self.loadDataAct = E5Action( |
513 self.trUtf8('&Load Data'), | 547 self.trUtf8('Load Data'), |
514 0, 0, | 548 self.trUtf8('&Load Data'), |
515 self, 'django_tools_loaddata') | 549 0, 0, |
550 self, 'django_tools_loaddata') | |
516 self.loadDataAct.setStatusTip(self.trUtf8( | 551 self.loadDataAct.setStatusTip(self.trUtf8( |
517 'Load data from fixture files')) | 552 'Load data from fixture files')) |
518 self.loadDataAct.setWhatsThis(self.trUtf8( | 553 self.loadDataAct.setWhatsThis(self.trUtf8( |
519 """<b>Load Data</b>""" | 554 """<b>Load Data</b>""" |
520 """<p>Load data from fixture files.</p>""" | 555 """<p>Load data from fixture files.</p>""" |
521 )) | 556 )) |
522 self.loadDataAct.triggered[()].connect(self.__loadData) | 557 self.loadDataAct.triggered[()].connect(self.__loadData) |
523 self.actions.append(self.loadDataAct) | 558 self.actions.append(self.loadDataAct) |
524 | 559 |
525 self.runTestAct = E5Action(self.trUtf8('Run Testsuite'), | 560 self.runTestAct = E5Action( |
526 self.trUtf8('Run &Testsuite'), | 561 self.trUtf8('Run Testsuite'), |
527 0, 0, | 562 self.trUtf8('Run &Testsuite'), |
528 self, 'django_tools_run_test') | 563 0, 0, |
564 self, 'django_tools_run_test') | |
529 self.runTestAct.setStatusTip(self.trUtf8( | 565 self.runTestAct.setStatusTip(self.trUtf8( |
530 'Run the test suite for applications or the whole site')) | 566 'Run the test suite for applications or the whole site')) |
531 self.runTestAct.setWhatsThis(self.trUtf8( | 567 self.runTestAct.setWhatsThis(self.trUtf8( |
532 """<b>Run Testsuite</b>""" | 568 """<b>Run Testsuite</b>""" |
533 """<p>Run the test suite for applications or the whole site.</p>""" | 569 """<p>Run the test suite for applications or the whole site.</p>""" |
534 )) | 570 )) |
535 self.runTestAct.triggered[()].connect(self.__runTestSuite) | 571 self.runTestAct.triggered[()].connect(self.__runTestSuite) |
536 self.actions.append(self.runTestAct) | 572 self.actions.append(self.runTestAct) |
537 | 573 |
538 self.runTestServerAct = E5Action(self.trUtf8('Run Testserver'), | 574 self.runTestServerAct = E5Action( |
539 self.trUtf8('Run Test&server'), | 575 self.trUtf8('Run Testserver'), |
540 0, 0, | 576 self.trUtf8('Run Test&server'), |
541 self, 'django_tools_run_test_server') | 577 0, 0, |
578 self, 'django_tools_run_test_server') | |
542 self.runTestServerAct.setStatusTip(self.trUtf8( | 579 self.runTestServerAct.setStatusTip(self.trUtf8( |
543 'Run a development server with data from a set of fixtures')) | 580 'Run a development server with data from a set of fixtures')) |
544 self.runTestServerAct.setWhatsThis(self.trUtf8( | 581 self.runTestServerAct.setWhatsThis(self.trUtf8( |
545 """<b>Run Testserver</b>""" | 582 """<b>Run Testserver</b>""" |
546 """<p>Run a development server with data from a set of fixtures.</p>""" | 583 """<p>Run a development server with data from a set of""" |
584 """ fixtures.</p>""" | |
547 )) | 585 )) |
548 self.runTestServerAct.triggered[()].connect(self.__runTestServer) | 586 self.runTestServerAct.triggered[()].connect(self.__runTestServer) |
549 self.actions.append(self.runTestServerAct) | 587 self.actions.append(self.runTestServerAct) |
550 | 588 |
551 def __initAuthorizationActions(self): | 589 def __initAuthorizationActions(self): |
552 """ | 590 """ |
553 Private method to define the authorization actions. | 591 Private method to define the authorization actions. |
554 """ | 592 """ |
555 self.changePasswordAct = E5Action(self.trUtf8('Change Password'), | 593 self.changePasswordAct = E5Action( |
556 self.trUtf8('Change &Password'), | 594 self.trUtf8('Change Password'), |
557 0, 0, | 595 self.trUtf8('Change &Password'), |
558 self, 'django_auth_changepassword') | 596 0, 0, |
597 self, 'django_auth_changepassword') | |
559 self.changePasswordAct.setStatusTip(self.trUtf8( | 598 self.changePasswordAct.setStatusTip(self.trUtf8( |
560 'Change the password of a user')) | 599 'Change the password of a user')) |
561 self.changePasswordAct.setWhatsThis(self.trUtf8( | 600 self.changePasswordAct.setWhatsThis(self.trUtf8( |
562 """<b>Change Password</b>""" | 601 """<b>Change Password</b>""" |
563 """<p>Change the password of a user of the Django project.</p>""" | 602 """<p>Change the password of a user of the Django project.</p>""" |
564 )) | 603 )) |
565 self.changePasswordAct.triggered[()].connect(self.__changePassword) | 604 self.changePasswordAct.triggered[()].connect(self.__changePassword) |
566 self.actions.append(self.changePasswordAct) | 605 self.actions.append(self.changePasswordAct) |
567 | 606 |
568 self.createSuperUserAct = E5Action(self.trUtf8('Create Superuser'), | 607 self.createSuperUserAct = E5Action( |
569 self.trUtf8('Create &Superuser'), | 608 self.trUtf8('Create Superuser'), |
570 0, 0, | 609 self.trUtf8('Create &Superuser'), |
571 self, 'django_auth_createsuperuser') | 610 0, 0, |
611 self, 'django_auth_createsuperuser') | |
572 self.createSuperUserAct.setStatusTip(self.trUtf8( | 612 self.createSuperUserAct.setStatusTip(self.trUtf8( |
573 'Create a superuser account')) | 613 'Create a superuser account')) |
574 self.createSuperUserAct.setWhatsThis(self.trUtf8( | 614 self.createSuperUserAct.setWhatsThis(self.trUtf8( |
575 """<b>Create Superuser</b>""" | 615 """<b>Create Superuser</b>""" |
576 """<p>Create a superuser account for the Django project.</p>""" | 616 """<p>Create a superuser account for the Django project.</p>""" |
580 | 620 |
581 def __initSessionActions(self): | 621 def __initSessionActions(self): |
582 """ | 622 """ |
583 Private method to define the session actions. | 623 Private method to define the session actions. |
584 """ | 624 """ |
585 self.clearSessionsAct = E5Action(self.trUtf8('Clear Sessions'), | 625 self.clearSessionsAct = E5Action( |
586 self.trUtf8('Clear &Sessions'), | 626 self.trUtf8('Clear Sessions'), |
587 0, 0, | 627 self.trUtf8('Clear &Sessions'), |
588 self, 'django_session_clearsessions') | 628 0, 0, |
629 self, 'django_session_clearsessions') | |
589 self.clearSessionsAct.setStatusTip(self.trUtf8( | 630 self.clearSessionsAct.setStatusTip(self.trUtf8( |
590 'Clear expired sessions')) | 631 'Clear expired sessions')) |
591 self.clearSessionsAct.setWhatsThis(self.trUtf8( | 632 self.clearSessionsAct.setWhatsThis(self.trUtf8( |
592 """<b>Clear Sessions</b>""" | 633 """<b>Clear Sessions</b>""" |
593 """<p>Clear expired sessions of the Django project.</p>""" | 634 """<p>Clear expired sessions of the Django project.</p>""" |
748 """ | 789 """ |
749 if self.__hooksInstalled: | 790 if self.__hooksInstalled: |
750 editor = self.__plugin.getPreferences("TranslationsEditor") | 791 editor = self.__plugin.getPreferences("TranslationsEditor") |
751 try: | 792 try: |
752 if editor: | 793 if editor: |
753 self.__translationsBrowser.addHookMethodAndMenuEntry("open", | 794 self.__translationsBrowser.addHookMethodAndMenuEntry( |
795 "open", | |
754 self.openPOEditor, | 796 self.openPOEditor, |
755 self.trUtf8("Open with {0}").format(os.path.basename(editor))) | 797 self.trUtf8("Open with {0}").format( |
798 os.path.basename(editor))) | |
756 else: | 799 else: |
757 self.__translationsBrowser.removeHookMethod("open") | 800 self.__translationsBrowser.removeHookMethod("open") |
758 except KeyError: | 801 except KeyError: |
759 # ignore for older eric5 versions | 802 # ignore for older eric5 versions |
760 pass | 803 pass |
764 Public method to add our hook methods. | 807 Public method to add our hook methods. |
765 """ | 808 """ |
766 if self.__e5project.getProjectType() == "Django": | 809 if self.__e5project.getProjectType() == "Django": |
767 self.__formsBrowser = \ | 810 self.__formsBrowser = \ |
768 e5App().getObject("ProjectBrowser").getProjectBrowser("forms") | 811 e5App().getObject("ProjectBrowser").getProjectBrowser("forms") |
769 self.__formsBrowser.addHookMethodAndMenuEntry("newForm", | 812 self.__formsBrowser.addHookMethodAndMenuEntry( |
813 "newForm", | |
770 self.newForm, self.trUtf8("New template...")) | 814 self.newForm, self.trUtf8("New template...")) |
771 | 815 |
772 self.__e5project.projectLanguageAddedByCode.connect( | 816 self.__e5project.projectLanguageAddedByCode.connect( |
773 self.__projectLanguageAdded) | 817 self.__projectLanguageAdded) |
774 self.__translationsBrowser = \ | 818 self.__translationsBrowser = \ |
775 e5App().getObject("ProjectBrowser").getProjectBrowser("translations") | 819 e5App().getObject("ProjectBrowser")\ |
776 self.__translationsBrowser.addHookMethodAndMenuEntry("generateAll", | 820 .getProjectBrowser("translations") |
821 self.__translationsBrowser.addHookMethodAndMenuEntry( | |
822 "generateAll", | |
777 self.updateCatalogs, self.trUtf8("Update all catalogs")) | 823 self.updateCatalogs, self.trUtf8("Update all catalogs")) |
778 self.__translationsBrowser.addHookMethodAndMenuEntry("generateSelected", | 824 self.__translationsBrowser.addHookMethodAndMenuEntry( |
779 self.updateSelectedCatalogs, self.trUtf8("Update selected catalogs")) | 825 "generateSelected", |
826 self.updateSelectedCatalogs, | |
827 self.trUtf8("Update selected catalogs")) | |
780 self.__translationsBrowser.addHookMethodAndMenuEntry( | 828 self.__translationsBrowser.addHookMethodAndMenuEntry( |
781 "generateAllWithObsolete", self.updateCatalogsWithObsolete, | 829 "generateAllWithObsolete", self.updateCatalogsWithObsolete, |
782 self.trUtf8("Update all catalogs (with obsolete)")) | 830 self.trUtf8("Update all catalogs (with obsolete)")) |
783 self.__translationsBrowser.addHookMethodAndMenuEntry( | 831 self.__translationsBrowser.addHookMethodAndMenuEntry( |
784 "generateSelectedWithObsolete", self.updateSelectedCatalogsWithObsolete, | 832 "generateSelectedWithObsolete", |
833 self.updateSelectedCatalogsWithObsolete, | |
785 self.trUtf8("Update selected catalogs (with obsolete)")) | 834 self.trUtf8("Update selected catalogs (with obsolete)")) |
786 self.__translationsBrowser.addHookMethodAndMenuEntry("releaseAll", | 835 self.__translationsBrowser.addHookMethodAndMenuEntry( |
836 "releaseAll", | |
787 self.compileCatalogs, self.trUtf8("Compile all catalogs")) | 837 self.compileCatalogs, self.trUtf8("Compile all catalogs")) |
788 self.__translationsBrowser.addHookMethodAndMenuEntry("releaseSelected", | 838 self.__translationsBrowser.addHookMethodAndMenuEntry( |
839 "releaseSelected", | |
789 self.compileSelectedCatalogs, | 840 self.compileSelectedCatalogs, |
790 self.trUtf8("Compile selected catalogs")) | 841 self.trUtf8("Compile selected catalogs")) |
791 | 842 |
792 self.__hooksInstalled = True | 843 self.__hooksInstalled = True |
793 | 844 |
801 self.__formsBrowser.removeHookMethod("newForm") | 852 self.__formsBrowser.removeHookMethod("newForm") |
802 self.__formsBrowser = None | 853 self.__formsBrowser = None |
803 | 854 |
804 self.__e5project.projectLanguageAddedByCode.disconnect( | 855 self.__e5project.projectLanguageAddedByCode.disconnect( |
805 self.__projectLanguageAdded) | 856 self.__projectLanguageAdded) |
806 self.__translationsBrowser.removeHookMethod("generateAll") | 857 self.__translationsBrowser.removeHookMethod( |
807 self.__translationsBrowser.removeHookMethod("generateSelected") | 858 "generateAll") |
808 self.__translationsBrowser.removeHookMethod("generateAllWithObsolete") | 859 self.__translationsBrowser.removeHookMethod( |
809 self.__translationsBrowser.removeHookMethod("generateSelectedWithObsolete") | 860 "generateSelected") |
810 self.__translationsBrowser.removeHookMethod("releaseAll") | 861 self.__translationsBrowser.removeHookMethod( |
811 self.__translationsBrowser.removeHookMethod("releaseSelected") | 862 "generateAllWithObsolete") |
863 self.__translationsBrowser.removeHookMethod( | |
864 "generateSelectedWithObsolete") | |
865 self.__translationsBrowser.removeHookMethod( | |
866 "releaseAll") | |
867 self.__translationsBrowser.removeHookMethod( | |
868 "releaseSelected") | |
812 try: | 869 try: |
813 self.__translationsBrowser.removeHookMethod("open") | 870 self.__translationsBrowser.removeHookMethod("open") |
814 except KeyError: | 871 except KeyError: |
815 # ignore for older eric5 versions | 872 # ignore for older eric5 versions |
816 pass | 873 pass |
841 ex = selectedFilter.split("(*")[1].split(")")[0] | 898 ex = selectedFilter.split("(*")[1].split(")")[0] |
842 if ex: | 899 if ex: |
843 fname += ex | 900 fname += ex |
844 | 901 |
845 if os.path.exists(fname): | 902 if os.path.exists(fname): |
846 res = E5MessageBox.yesNo(self.__ui, | 903 res = E5MessageBox.yesNo( |
904 self.__ui, | |
847 self.trUtf8("New Form"), | 905 self.trUtf8("New Form"), |
848 self.trUtf8("The file already exists! Overwrite it?"), | 906 self.trUtf8("The file already exists! Overwrite it?"), |
849 icon=E5MessageBox.Warning) | 907 icon=E5MessageBox.Warning) |
850 | 908 |
851 if not res: | 909 if not res: |
857 f.write('<!DOCTYPE html>') | 915 f.write('<!DOCTYPE html>') |
858 f.write('<html>\n') | 916 f.write('<html>\n') |
859 f.write(' <head>\n') | 917 f.write(' <head>\n') |
860 f.write(' <meta content="" />\n') | 918 f.write(' <meta content="" />\n') |
861 f.write(' <title></title>\n') | 919 f.write(' <title></title>\n') |
862 f.write(' <link rel="stylesheet" type="text/css" href="style.css"/>') | 920 f.write(' <link rel="stylesheet" type="text/css"' |
921 ' href="style.css"/>') | |
863 f.write(' <!--[if lte IE 7]>') | 922 f.write(' <!--[if lte IE 7]>') |
864 f.write(' <link rel="stylesheet" type="text/css" href="ie.css"/>') | 923 f.write(' <link rel="stylesheet" type="text/css"' |
924 ' href="ie.css"/>') | |
865 f.write(' <![endif]-->') | 925 f.write(' <![endif]-->') |
866 f.write(' </head>\n') | 926 f.write(' </head>\n') |
867 f.write('\n') | 927 f.write('\n') |
868 f.write(' <body class="bodyclass">\n') | 928 f.write(' <body class="bodyclass">\n') |
869 f.write(' <div id="container">') | 929 f.write(' <div id="container">') |
871 f.write(' </body>\n') | 931 f.write(' </body>\n') |
872 f.close() | 932 f.close() |
873 f.write('</html>\n') | 933 f.write('</html>\n') |
874 f.close() | 934 f.close() |
875 except (IOError, OSError) as e: | 935 except (IOError, OSError) as e: |
876 E5MessageBox.critical(self.__ui, | 936 E5MessageBox.critical( |
937 self.__ui, | |
877 self.trUtf8("New Form"), | 938 self.trUtf8("New Form"), |
878 self.trUtf8("<p>The new form file <b>{0}</b> could not be created.<br>" | 939 self.trUtf8("<p>The new form file <b>{0}</b> could not be" |
879 "Problem: {1}</p>").format(fname, str(e))) | 940 " created.<br> Problem: {1}</p>") |
941 .format(fname, str(e))) | |
880 return | 942 return |
881 | 943 |
882 self.__e5project.appendFile(fname) | 944 self.__e5project.appendFile(fname) |
883 self.__formsBrowser.sourceFile.emit(fname) | 945 self.__formsBrowser.sourceFile.emit(fname) |
884 | 946 |
898 """ | 960 """ |
899 Private method to build all full path of an executable file from | 961 Private method to build all full path of an executable file from |
900 the environment. | 962 the environment. |
901 | 963 |
902 @param file filename of the executable (string) | 964 @param file filename of the executable (string) |
903 @return list of full executable names, if the executable file is accessible | 965 @return list of full executable names, if the executable file is |
904 via the searchpath defined by the PATH environment variable, or an | 966 accessible via the searchpath defined by the PATH environment |
905 empty list otherwise. | 967 variable, or an empty list otherwise. |
906 """ | 968 """ |
907 paths = [] | 969 paths = [] |
908 | 970 |
909 if os.path.isabs(file): | 971 if os.path.isabs(file): |
910 if os.access(file, os.X_OK): | 972 if os.access(file, os.X_OK): |
958 f.close() | 1020 f.close() |
959 except (IOError, OSError): | 1021 except (IOError, OSError): |
960 l0 = "" | 1022 l0 = "" |
961 if variant.lower() in l0.lower() or \ | 1023 if variant.lower() in l0.lower() or \ |
962 "{0}.".format(variant[-1]) in l0 or \ | 1024 "{0}.".format(variant[-1]) in l0 or \ |
963 (variant == "Python2" and \ | 1025 (variant == "Python2" and |
964 "python3" not in l0.lower() and \ | 1026 "python3" not in l0.lower() and |
965 "python" in l0.lower()): | 1027 "python" in l0.lower()): |
966 variants.append(variant) | 1028 variants.append(variant) |
967 break | 1029 break |
968 | 1030 |
969 return variants | 1031 return variants |
970 | 1032 |
1023 cmd = os.path.join(virtualEnv, "Scripts", "django-admin.py") | 1085 cmd = os.path.join(virtualEnv, "Scripts", "django-admin.py") |
1024 else: | 1086 else: |
1025 cmds = [ | 1087 cmds = [ |
1026 os.path.join(virtualEnv, "bin", "django-admin.py"), | 1088 os.path.join(virtualEnv, "bin", "django-admin.py"), |
1027 os.path.join(virtualEnv, "bin", "django-admin"), | 1089 os.path.join(virtualEnv, "bin", "django-admin"), |
1028 os.path.join(virtualEnv, "local", "bin", "django-admin.py"), | 1090 os.path.join(virtualEnv, "local", "bin", |
1091 "django-admin.py"), | |
1029 os.path.join(virtualEnv, "local", "bin", "django-admin"), | 1092 os.path.join(virtualEnv, "local", "bin", "django-admin"), |
1030 ] | 1093 ] |
1031 for cmd in cmds: | 1094 for cmd in cmds: |
1032 if os.path.exists(cmd): | 1095 if os.path.exists(cmd): |
1033 break | 1096 break |
1085 Private slot to show some info about Django. | 1148 Private slot to show some info about Django. |
1086 """ | 1149 """ |
1087 version = self.getDjangoVersion() | 1150 version = self.getDjangoVersion() |
1088 url = "http://www.djangoproject.com" | 1151 url = "http://www.djangoproject.com" |
1089 | 1152 |
1090 msgBox = E5MessageBox.E5MessageBox(E5MessageBox.Question, | 1153 msgBox = E5MessageBox.E5MessageBox( |
1154 E5MessageBox.Question, | |
1091 self.trUtf8("About Django"), | 1155 self.trUtf8("About Django"), |
1092 self.trUtf8( | 1156 self.trUtf8( |
1093 "<p>Django is a high-level Python Web framework that encourages rapid " | 1157 "<p>Django is a high-level Python Web framework that" |
1158 " encourages rapid " | |
1094 "development and clean, pragmatic design.</p>" | 1159 "development and clean, pragmatic design.</p>" |
1095 "<p><table>" | 1160 "<p><table>" |
1096 "<tr><td>Version:</td><td>{0}</td></tr>" | 1161 "<tr><td>Version:</td><td>{0}</td></tr>" |
1097 "<tr><td>URL:</td><td><a href=\"{1}\">" | 1162 "<tr><td>URL:</td><td><a href=\"{1}\">" |
1098 "{1}</a></td></tr>" | 1163 "{1}</a></td></tr>" |
1122 process.start(cmd, args) | 1187 process.start(cmd, args) |
1123 procStarted = process.waitForStarted() | 1188 procStarted = process.waitForStarted() |
1124 if procStarted: | 1189 if procStarted: |
1125 finished = process.waitForFinished(30000) | 1190 finished = process.waitForFinished(30000) |
1126 if finished and process.exitCode() == 0: | 1191 if finished and process.exitCode() == 0: |
1127 output = \ | 1192 output = str(process.readAllStandardOutput(), ioEncoding, |
1128 str(process.readAllStandardOutput(), ioEncoding, 'replace') | 1193 'replace') |
1129 self.__djangoVersion = output.splitlines()[0].strip() | 1194 self.__djangoVersion = output.splitlines()[0].strip() |
1130 | 1195 |
1131 return self.__djangoVersion | 1196 return self.__djangoVersion |
1132 | 1197 |
1133 def __getApplications(self): | 1198 def __getApplications(self): |
1241 "Select the empty entry for none."), | 1306 "Select the empty entry for none."), |
1242 selections, | 1307 selections, |
1243 0, False) | 1308 0, False) |
1244 if ok and bool(selection): | 1309 if ok and bool(selection): |
1245 if selection == projectStr: | 1310 if selection == projectStr: |
1246 path, projectName = os.path.split(self.__e5project.getProjectPath()) | 1311 path, projectName = os.path.split( |
1312 self.__e5project.getProjectPath()) | |
1247 self.__createProject(projectName, path) | 1313 self.__createProject(projectName, path) |
1248 elif selection == applStr: | 1314 elif selection == applStr: |
1249 path, applName = os.path.split(self.__e5project.getProjectPath()) | 1315 path, applName = os.path.split( |
1316 self.__e5project.getProjectPath()) | |
1250 self.__createApplication(applName, path) | 1317 self.__createApplication(applName, path) |
1251 | 1318 |
1252 def __createProject(self, projectName, path): | 1319 def __createProject(self, projectName, path): |
1253 """ | 1320 """ |
1254 Private slot to create a new Django project. | 1321 Private slot to create a new Django project. |
1267 else: | 1334 else: |
1268 cmd = self.__getDjangoAdminCommand() | 1335 cmd = self.__getDjangoAdminCommand() |
1269 if cmd: | 1336 if cmd: |
1270 args.append(cmd) | 1337 args.append(cmd) |
1271 else: | 1338 else: |
1272 E5MessageBox.critical(self.__ui, | 1339 E5MessageBox.critical( |
1340 self.__ui, | |
1273 title, | 1341 title, |
1274 self.trUtf8("""<p>The <b>django-admin.py</b> script is not in""" | 1342 self.trUtf8("""<p>The <b>django-admin.py</b> script is""" |
1275 """ the path. Aborting...</p>""")) | 1343 """ not in the path. Aborting...</p>""")) |
1276 return | 1344 return |
1277 | 1345 |
1278 args.append("startproject") | 1346 args.append("startproject") |
1279 args.append(projectName) | 1347 args.append(projectName) |
1280 | 1348 |
1281 dia = DjangoDialog(title, | 1349 dia = DjangoDialog( |
1350 title, | |
1282 msgSuccess=self.trUtf8("Django project created successfully.")) | 1351 msgSuccess=self.trUtf8("Django project created successfully.")) |
1283 res = dia.startProcess(args, path) | 1352 res = dia.startProcess(args, path) |
1284 if res: | 1353 if res: |
1285 dia.exec_() | 1354 dia.exec_() |
1286 | 1355 |
1287 # create the base directory for translations | 1356 # create the base directory for translations |
1288 i18nPath = os.path.join(path, projectName, "locale") | 1357 i18nPath = os.path.join(path, projectName, "locale") |
1289 if not os.path.exists(i18nPath): | 1358 if not os.path.exists(i18nPath): |
1290 os.makedirs(i18nPath) | 1359 os.makedirs(i18nPath) |
1291 | 1360 |
1292 if os.path.join(path, projectName) == self.__e5project.getProjectPath(): | 1361 if os.path.join(path, projectName) == \ |
1362 self.__e5project.getProjectPath(): | |
1293 self.__setCurrentSite("") | 1363 self.__setCurrentSite("") |
1294 else: | 1364 else: |
1295 self.__setCurrentSite(projectName) | 1365 self.__setCurrentSite(projectName) |
1296 | 1366 |
1297 return res | 1367 return res |
1304 self.__ui, | 1374 self.__ui, |
1305 self.trUtf8("Start Django Project"), | 1375 self.trUtf8("Start Django Project"), |
1306 self.trUtf8("Enter the name of the new Django project."), | 1376 self.trUtf8("Enter the name of the new Django project."), |
1307 QLineEdit.Normal) | 1377 QLineEdit.Normal) |
1308 if ok and projectName != "": | 1378 if ok and projectName != "": |
1309 res = self.__createProject(projectName, self.__e5project.getProjectPath()) | 1379 res = self.__createProject(projectName, |
1380 self.__e5project.getProjectPath()) | |
1310 if res: | 1381 if res: |
1311 # search for new files and add them to the project | 1382 # search for new files and add them to the project |
1312 sitePath = os.path.join(self.__e5project.getProjectPath(), | 1383 sitePath = os.path.join(self.__e5project.getProjectPath(), |
1313 projectName) | 1384 projectName) |
1314 for entry in os.walk(sitePath): | 1385 for entry in os.walk(sitePath): |
1321 Private slot to create a new Django application. | 1392 Private slot to create a new Django application. |
1322 | 1393 |
1323 @param applName name of the new application (string) | 1394 @param applName name of the new application (string) |
1324 @param path the directory where the application should be created | 1395 @param path the directory where the application should be created |
1325 (string) | 1396 (string) |
1326 @param isGlobal flag indicating a standalone Django application (boolean) | 1397 @param isGlobal flag indicating a standalone Django application |
1398 (boolean) | |
1327 @return flag indicating a successful creation (boolean) | 1399 @return flag indicating a successful creation (boolean) |
1328 """ | 1400 """ |
1329 title = self.trUtf8("Start Django Application") | 1401 title = self.trUtf8("Start Django Application") |
1330 | 1402 |
1331 args = [] | 1403 args = [] |
1336 else: | 1408 else: |
1337 cmd = self.__getDjangoAdminCommand() | 1409 cmd = self.__getDjangoAdminCommand() |
1338 if cmd: | 1410 if cmd: |
1339 args.append(cmd) | 1411 args.append(cmd) |
1340 else: | 1412 else: |
1341 E5MessageBox.critical(self.__ui, | 1413 E5MessageBox.critical( |
1414 self.__ui, | |
1342 title, | 1415 title, |
1343 self.trUtf8("""<p>The <b>django-admin.py</b> script is not in""" | 1416 self.trUtf8("""<p>The <b>django-admin.py</b> script""" |
1344 """ the path. Aborting...</p>""")) | 1417 """ is not in the path.""" |
1418 """ Aborting...</p>""")) | |
1345 return | 1419 return |
1346 else: | 1420 else: |
1347 args.append(self.__getPythonExecutable()) | 1421 args.append(self.__getPythonExecutable()) |
1348 args.append("manage.py") | 1422 args.append("manage.py") |
1349 try: | 1423 try: |
1351 except DjangoNoSiteSelectedException: | 1425 except DjangoNoSiteSelectedException: |
1352 return False | 1426 return False |
1353 args.append("startapp") | 1427 args.append("startapp") |
1354 args.append(applName) | 1428 args.append(applName) |
1355 | 1429 |
1356 dia = DjangoDialog(title, | 1430 dia = DjangoDialog( |
1431 title, | |
1357 msgSuccess=self.trUtf8("Django application created successfully.")) | 1432 msgSuccess=self.trUtf8("Django application created successfully.")) |
1358 res = dia.startProcess(args, path) | 1433 res = dia.startProcess(args, path) |
1359 if res: | 1434 if res: |
1360 dia.exec_() | 1435 dia.exec_() |
1361 return res | 1436 return res |
1365 Private slot to start a new global Django application. | 1440 Private slot to start a new global Django application. |
1366 """ | 1441 """ |
1367 applName, ok = QInputDialog.getText( | 1442 applName, ok = QInputDialog.getText( |
1368 self.__ui, | 1443 self.__ui, |
1369 self.trUtf8("Start Global Django Application"), | 1444 self.trUtf8("Start Global Django Application"), |
1370 self.trUtf8("Enter the name of the new global Django application."), | 1445 self.trUtf8("Enter the name of the new global Django" |
1446 " application."), | |
1371 QLineEdit.Normal) | 1447 QLineEdit.Normal) |
1372 if ok and applName != "": | 1448 if ok and applName != "": |
1373 res = self.__createApplication(applName, self.__e5project.getProjectPath()) | 1449 res = self.__createApplication(applName, |
1450 self.__e5project.getProjectPath()) | |
1374 if res: | 1451 if res: |
1375 # search for new files and add them to the project | 1452 # search for new files and add them to the project |
1376 appPath = os.path.join(self.__e5project.getProjectPath(), applName) | 1453 appPath = os.path.join(self.__e5project.getProjectPath(), |
1454 applName) | |
1377 for entry in os.walk(appPath): | 1455 for entry in os.walk(appPath): |
1378 for fileName in entry[2]: | 1456 for fileName in entry[2]: |
1379 fullName = os.path.join(entry[0], fileName) | 1457 fullName = os.path.join(entry[0], fileName) |
1380 self.__e5project.appendFile(fullName) | 1458 self.__e5project.appendFile(fullName) |
1381 | 1459 |
1418 return sites | 1496 return sites |
1419 | 1497 |
1420 def __selectSite(self): | 1498 def __selectSite(self): |
1421 """ | 1499 """ |
1422 Private method to select a site to work with. | 1500 Private method to select a site to work with. |
1423 | |
1424 @return selected site (string) | |
1425 """ | 1501 """ |
1426 sites = self.__findSites() | 1502 sites = self.__findSites() |
1427 if len(sites) == 1: | 1503 if len(sites) == 1: |
1428 site = sites[0] | 1504 site = sites[0] |
1429 else: | 1505 else: |
1478 | 1554 |
1479 if self.__currentSite is None: | 1555 if self.__currentSite is None: |
1480 self.__e5project.pdata["TRANSLATIONPATTERN"] = [] | 1556 self.__e5project.pdata["TRANSLATIONPATTERN"] = [] |
1481 else: | 1557 else: |
1482 self.__e5project.pdata["TRANSLATIONPATTERN"] = [ | 1558 self.__e5project.pdata["TRANSLATIONPATTERN"] = [ |
1483 os.path.join(site, "locale", "%language%", "LC_MESSAGES", "django.po") | 1559 os.path.join(site, "locale", "%language%", "LC_MESSAGES", |
1560 "django.po") | |
1484 ] | 1561 ] |
1485 | 1562 |
1486 def __site(self): | 1563 def __site(self): |
1487 """ | 1564 """ |
1488 Private method to get the name of the current site. | 1565 Private method to get the name of the current site. |
1520 if addr: | 1597 if addr: |
1521 args.append(addr) | 1598 args.append(addr) |
1522 | 1599 |
1523 try: | 1600 try: |
1524 if Utilities.isWindowsPlatform(): | 1601 if Utilities.isWindowsPlatform(): |
1525 serverProcStarted, pid = \ | 1602 serverProcStarted, pid = QProcess.startDetached( |
1526 QProcess.startDetached(args[0], args[1:], self.__sitePath()) | 1603 args[0], args[1:], self.__sitePath()) |
1527 else: | 1604 else: |
1528 if self.__serverProc is not None: | 1605 if self.__serverProc is not None: |
1529 self.__serverProcFinished() | 1606 self.__serverProcFinished() |
1530 | 1607 |
1531 self.__serverProc = QProcess() | 1608 self.__serverProc = QProcess() |
1532 self.__serverProc.finished.connect(self.__serverProcFinished) | 1609 self.__serverProc.finished.connect( |
1610 self.__serverProcFinished) | |
1533 self.__serverProc.setWorkingDirectory(self.__sitePath()) | 1611 self.__serverProc.setWorkingDirectory(self.__sitePath()) |
1534 self.__serverProc.start(args[0], args[1:]) | 1612 self.__serverProc.start(args[0], args[1:]) |
1535 serverProcStarted = self.__serverProc.waitForStarted() | 1613 serverProcStarted = self.__serverProc.waitForStarted() |
1536 if not serverProcStarted: | 1614 if not serverProcStarted: |
1537 E5MessageBox.critical(None, | 1615 E5MessageBox.critical( |
1616 None, | |
1538 self.trUtf8('Process Generation Error'), | 1617 self.trUtf8('Process Generation Error'), |
1539 self.trUtf8('The Django server could not be started.')) | 1618 self.trUtf8('The Django server could not be started.')) |
1540 except DjangoNoSiteSelectedException: | 1619 except DjangoNoSiteSelectedException: |
1541 pass | 1620 pass |
1542 | 1621 |
1576 else: | 1655 else: |
1577 addr = "127.0.0.1" | 1656 addr = "127.0.0.1" |
1578 url = QUrl("http://{0}:{1}".format(addr, port)) | 1657 url = QUrl("http://{0}:{1}".format(addr, port)) |
1579 res = QDesktopServices.openUrl(url) | 1658 res = QDesktopServices.openUrl(url) |
1580 if not res: | 1659 if not res: |
1581 E5MessageBox.critical(None, | 1660 E5MessageBox.critical( |
1661 None, | |
1582 self.trUtf8('Run Web-Browser'), | 1662 self.trUtf8('Run Web-Browser'), |
1583 self.trUtf8('Could not start the web-browser for the url "{0}".')\ | 1663 self.trUtf8('Could not start the web-browser for the' |
1584 .format(url.toString())) | 1664 ' url "{0}".').format(url.toString())) |
1585 | 1665 |
1586 ################################################################## | 1666 ################################################################## |
1587 ## slots below implement database related functions | 1667 ## slots below implement database related functions |
1588 ################################################################## | 1668 ################################################################## |
1589 | 1669 |
1601 args.append("syncdb") | 1681 args.append("syncdb") |
1602 try: | 1682 try: |
1603 wd = self.__sitePath() | 1683 wd = self.__sitePath() |
1604 started, pid = QProcess.startDetached(args[0], args[1:], wd) | 1684 started, pid = QProcess.startDetached(args[0], args[1:], wd) |
1605 if not started: | 1685 if not started: |
1606 E5MessageBox.critical(None, | 1686 E5MessageBox.critical( |
1687 None, | |
1607 self.trUtf8('Process Generation Error'), | 1688 self.trUtf8('Process Generation Error'), |
1608 self.trUtf8('The Django process could not be started.')) | 1689 self.trUtf8('The Django process could not be' |
1690 ' started.')) | |
1609 except DjangoNoSiteSelectedException: | 1691 except DjangoNoSiteSelectedException: |
1610 pass | 1692 pass |
1611 | 1693 |
1612 def __databaseInspect(self): | 1694 def __databaseInspect(self): |
1613 """ | 1695 """ |
1614 Private slot to introspect the database and output a Django model module. | 1696 Private slot to introspect the database and output a Django model |
1697 module. | |
1615 """ | 1698 """ |
1616 title = self.trUtf8("Introspect Database") | 1699 title = self.trUtf8("Introspect Database") |
1617 | 1700 |
1618 args = [] | 1701 args = [] |
1619 args.append(self.__getPythonExecutable()) | 1702 args.append(self.__getPythonExecutable()) |
1630 if res: | 1713 if res: |
1631 dia.exec_() | 1714 dia.exec_() |
1632 | 1715 |
1633 def __databaseFlush(self): | 1716 def __databaseFlush(self): |
1634 """ | 1717 """ |
1635 Private slot to return all database tables to the state just after their | 1718 Private slot to return all database tables to the state just after |
1636 installation. | 1719 their installation. |
1637 """ | 1720 """ |
1638 try: | 1721 try: |
1639 path = self.__sitePath() | 1722 path = self.__sitePath() |
1640 except DjangoNoSiteSelectedException: | 1723 except DjangoNoSiteSelectedException: |
1641 return | 1724 return |
1642 | 1725 |
1643 title = self.trUtf8("Flush Database") | 1726 title = self.trUtf8("Flush Database") |
1644 | 1727 |
1645 res = E5MessageBox.yesNo(self.__ui, | 1728 res = E5MessageBox.yesNo( |
1729 self.__ui, | |
1646 title, | 1730 title, |
1647 self.trUtf8("""Flushing the database will destroy all data. Are you sure?""")) | 1731 self.trUtf8("""Flushing the database will destroy all data.""" |
1732 """ Are you sure?""")) | |
1648 if res: | 1733 if res: |
1649 args = [] | 1734 args = [] |
1650 args.append(self.__getPythonExecutable()) | 1735 args.append(self.__getPythonExecutable()) |
1651 args.append("manage.py") | 1736 args.append("manage.py") |
1652 args.append("flush") | 1737 args.append("flush") |
1653 args.append("--noinput") | 1738 args.append("--noinput") |
1654 | 1739 |
1655 dia = DjangoDialog(title, | 1740 dia = DjangoDialog( |
1656 msgSuccess=self.trUtf8("Database tables flushed successfully.")) | 1741 title, |
1742 msgSuccess=self.trUtf8("Database tables flushed" | |
1743 " successfully.")) | |
1657 res = dia.startProcess(args, path) | 1744 res = dia.startProcess(args, path) |
1658 if res: | 1745 if res: |
1659 dia.exec_() | 1746 dia.exec_() |
1660 | 1747 |
1661 def __runDatabaseClient(self): | 1748 def __runDatabaseClient(self): |
1672 args.append("dbshell") | 1759 args.append("dbshell") |
1673 try: | 1760 try: |
1674 wd = self.__sitePath() | 1761 wd = self.__sitePath() |
1675 started, pid = QProcess.startDetached(args[0], args[1:], wd) | 1762 started, pid = QProcess.startDetached(args[0], args[1:], wd) |
1676 if not started: | 1763 if not started: |
1677 E5MessageBox.critical(None, | 1764 E5MessageBox.critical( |
1765 None, | |
1678 self.trUtf8('Process Generation Error'), | 1766 self.trUtf8('Process Generation Error'), |
1679 self.trUtf8('The Django process could not be started.')) | 1767 self.trUtf8('The Django process could not be' |
1768 ' started.')) | |
1680 except DjangoNoSiteSelectedException: | 1769 except DjangoNoSiteSelectedException: |
1681 pass | 1770 pass |
1682 | 1771 |
1683 ####################################################################### | 1772 ####################################################################### |
1684 ## slots below implement database functions outputting SQL statements | 1773 ## slots below implement database functions outputting SQL statements |
1807 try: | 1896 try: |
1808 path = self.__sitePath() | 1897 path = self.__sitePath() |
1809 except DjangoNoSiteSelectedException: | 1898 except DjangoNoSiteSelectedException: |
1810 return | 1899 return |
1811 | 1900 |
1812 dia = DjangoDialog(title, | 1901 dia = DjangoDialog( |
1902 title, | |
1813 msgSuccess=self.trUtf8("Database cleaned up successfully.")) | 1903 msgSuccess=self.trUtf8("Database cleaned up successfully.")) |
1814 res = dia.startProcess(args, path) | 1904 res = dia.startProcess(args, path) |
1815 if res: | 1905 if res: |
1816 dia.exec_() | 1906 dia.exec_() |
1817 | 1907 |
1857 args.append("--plain") | 1947 args.append("--plain") |
1858 try: | 1948 try: |
1859 wd = self.__sitePath() | 1949 wd = self.__sitePath() |
1860 started, pid = QProcess.startDetached(args[0], args[1:], wd) | 1950 started, pid = QProcess.startDetached(args[0], args[1:], wd) |
1861 if not started: | 1951 if not started: |
1862 E5MessageBox.critical(None, | 1952 E5MessageBox.critical( |
1953 None, | |
1863 self.trUtf8('Process Generation Error'), | 1954 self.trUtf8('Process Generation Error'), |
1864 self.trUtf8('The Django process could not be started.')) | 1955 self.trUtf8('The Django process could not be' |
1956 ' started.')) | |
1865 except DjangoNoSiteSelectedException: | 1957 except DjangoNoSiteSelectedException: |
1866 pass | 1958 pass |
1867 | 1959 |
1868 ################################################################## | 1960 ################################################################## |
1869 ## slots below implement caching functions | 1961 ## slots below implement caching functions |
1881 return | 1973 return |
1882 | 1974 |
1883 tblStr, ok = QInputDialog.getText( | 1975 tblStr, ok = QInputDialog.getText( |
1884 self.__ui, | 1976 self.__ui, |
1885 title, | 1977 title, |
1886 self.trUtf8("Enter the names of the cache tables separated by spaces."), | 1978 self.trUtf8("Enter the names of the cache tables separated by" |
1979 " spaces."), | |
1887 QLineEdit.Normal) | 1980 QLineEdit.Normal) |
1888 if ok and tblStr != "": | 1981 if ok and tblStr != "": |
1889 tableNames = tblStr.split() | 1982 tableNames = tblStr.split() |
1890 | 1983 |
1891 args = [] | 1984 args = [] |
1892 args.append(self.__getPythonExecutable()) | 1985 args.append(self.__getPythonExecutable()) |
1893 args.append("manage.py") | 1986 args.append("manage.py") |
1894 args.append("createcachetable") | 1987 args.append("createcachetable") |
1895 args += tableNames | 1988 args += tableNames |
1896 | 1989 |
1897 dia = DjangoDialog(title, | 1990 dia = DjangoDialog( |
1991 title, | |
1898 msgSuccess=self.trUtf8("Cache tables created successfully.")) | 1992 msgSuccess=self.trUtf8("Cache tables created successfully.")) |
1899 res = dia.startProcess(args, wd) | 1993 res = dia.startProcess(args, wd) |
1900 if res: | 1994 if res: |
1901 dia.exec_() | 1995 dia.exec_() |
1902 | 1996 |
1935 elif format == "xml": | 2029 elif format == "xml": |
1936 fileFilters = self.trUtf8("XML Files (*.xml)") | 2030 fileFilters = self.trUtf8("XML Files (*.xml)") |
1937 elif format == "yaml": | 2031 elif format == "yaml": |
1938 fileFilters = self.trUtf8("YAML Files (*.yaml)") | 2032 fileFilters = self.trUtf8("YAML Files (*.yaml)") |
1939 | 2033 |
1940 dia = DjangoDialog(title, fixed=True, linewrap=False, | 2034 dia = DjangoDialog( |
1941 saveFilters=fileFilters) | 2035 title, fixed=True, linewrap=False, saveFilters=fileFilters) |
1942 res = dia.startProcess(args, wd, showCommand=False) | 2036 res = dia.startProcess(args, wd, showCommand=False) |
1943 if res: | 2037 if res: |
1944 dia.exec_() | 2038 dia.exec_() |
1945 | 2039 |
1946 def __loadData(self): | 2040 def __loadData(self): |
1989 args.append("test") | 2083 args.append("test") |
1990 args += self.__getApplications() | 2084 args += self.__getApplications() |
1991 | 2085 |
1992 started, pid = QProcess.startDetached(args[0], args[1:], wd) | 2086 started, pid = QProcess.startDetached(args[0], args[1:], wd) |
1993 if not started: | 2087 if not started: |
1994 E5MessageBox.critical(None, | 2088 E5MessageBox.critical( |
2089 None, | |
1995 self.trUtf8('Process Generation Error'), | 2090 self.trUtf8('Process Generation Error'), |
1996 self.trUtf8('The Django process could not be started.')) | 2091 self.trUtf8('The Django process could not be started.')) |
1997 | 2092 |
1998 def __runTestServer(self): | 2093 def __runTestServer(self): |
1999 """ | 2094 """ |
2000 Private slot to run a development server with data from a set of fixtures. | 2095 Private slot to run a development server with data from a set of |
2096 fixtures. | |
2001 """ | 2097 """ |
2002 consoleCmd = self.__isSpawningConsole( | 2098 consoleCmd = self.__isSpawningConsole( |
2003 self.__plugin.getPreferences("ConsoleCommand"))[1] | 2099 self.__plugin.getPreferences("ConsoleCommand"))[1] |
2004 if consoleCmd: | 2100 if consoleCmd: |
2005 from .DjangoLoaddataDataDialog import DjangoLoaddataDataDialog | 2101 from .DjangoLoaddataDataDialog import DjangoLoaddataDataDialog |
2019 args.append("--addrport=%s" % addr) | 2115 args.append("--addrport=%s" % addr) |
2020 args += fixtures | 2116 args += fixtures |
2021 | 2117 |
2022 try: | 2118 try: |
2023 if Utilities.isWindowsPlatform(): | 2119 if Utilities.isWindowsPlatform(): |
2024 serverProcStarted, pid = \ | 2120 serverProcStarted, pid = QProcess.startDetached( |
2025 QProcess.startDetached(args[0], args[1:], self.__sitePath()) | 2121 args[0], args[1:], self.__sitePath()) |
2026 else: | 2122 else: |
2027 if self.__testServerProc is not None: | 2123 if self.__testServerProc is not None: |
2028 self.__testServerProcFinished() | 2124 self.__testServerProcFinished() |
2029 | 2125 |
2030 self.__testServerProc = QProcess() | 2126 self.__testServerProc = QProcess() |
2031 self.__testServerProc.finished.connect(self.__serverProcFinished) | 2127 self.__testServerProc.finished.connect( |
2032 self.__testServerProc.setWorkingDirectory(self.__sitePath()) | 2128 self.__serverProcFinished) |
2129 self.__testServerProc.setWorkingDirectory( | |
2130 self.__sitePath()) | |
2033 self.__testServerProc.start(args[0], args[1:]) | 2131 self.__testServerProc.start(args[0], args[1:]) |
2034 serverProcStarted = self.__testServerProc.waitForStarted() | 2132 serverProcStarted = \ |
2133 self.__testServerProc.waitForStarted() | |
2035 if not serverProcStarted: | 2134 if not serverProcStarted: |
2036 E5MessageBox.critical(None, | 2135 E5MessageBox.critical( |
2136 None, | |
2037 self.trUtf8('Process Generation Error'), | 2137 self.trUtf8('Process Generation Error'), |
2038 self.trUtf8('The Django test server could not be started.')) | 2138 self.trUtf8('The Django test server could not be' |
2139 ' started.')) | |
2039 except DjangoNoSiteSelectedException: | 2140 except DjangoNoSiteSelectedException: |
2040 pass | 2141 pass |
2041 | 2142 |
2042 def __testServerProcFinished(self): | 2143 def __testServerProcFinished(self): |
2043 """ | 2144 """ |
2073 args.append("manage.py") | 2174 args.append("manage.py") |
2074 args.append("changepassword") | 2175 args.append("changepassword") |
2075 args.append(userName) | 2176 args.append(userName) |
2076 try: | 2177 try: |
2077 wd = self.__sitePath() | 2178 wd = self.__sitePath() |
2078 started, pid = QProcess.startDetached(args[0], args[1:], wd) | 2179 started, pid = QProcess.startDetached( |
2180 args[0], args[1:], wd) | |
2079 if not started: | 2181 if not started: |
2080 E5MessageBox.critical(None, | 2182 E5MessageBox.critical( |
2183 None, | |
2081 self.trUtf8('Process Generation Error'), | 2184 self.trUtf8('Process Generation Error'), |
2082 self.trUtf8('The Django process could not be started.')) | 2185 self.trUtf8('The Django process could not be' |
2186 ' started.')) | |
2083 except DjangoNoSiteSelectedException: | 2187 except DjangoNoSiteSelectedException: |
2084 pass | 2188 pass |
2085 | 2189 |
2086 def __createSuperUser(self): | 2190 def __createSuperUser(self): |
2087 """ | 2191 """ |
2097 args.append("createsuperuser") | 2201 args.append("createsuperuser") |
2098 try: | 2202 try: |
2099 wd = self.__sitePath() | 2203 wd = self.__sitePath() |
2100 started, pid = QProcess.startDetached(args[0], args[1:], wd) | 2204 started, pid = QProcess.startDetached(args[0], args[1:], wd) |
2101 if not started: | 2205 if not started: |
2102 E5MessageBox.critical(None, | 2206 E5MessageBox.critical( |
2207 None, | |
2103 self.trUtf8('Process Generation Error'), | 2208 self.trUtf8('Process Generation Error'), |
2104 self.trUtf8('The Django process could not be started.')) | 2209 self.trUtf8('The Django process could not be' |
2210 ' started.')) | |
2105 except DjangoNoSiteSelectedException: | 2211 except DjangoNoSiteSelectedException: |
2106 pass | 2212 pass |
2107 | 2213 |
2108 ################################################################## | 2214 ################################################################## |
2109 ## slots below implement session functions | 2215 ## slots below implement session functions |
2123 args = [] | 2229 args = [] |
2124 args.append(self.__getPythonExecutable()) | 2230 args.append(self.__getPythonExecutable()) |
2125 args.append("manage.py") | 2231 args.append("manage.py") |
2126 args.append("clearsessions") | 2232 args.append("clearsessions") |
2127 | 2233 |
2128 dia = DjangoDialog(title, | 2234 dia = DjangoDialog( |
2235 title, | |
2129 msgSuccess=self.trUtf8("Expired sessions cleared successfully.")) | 2236 msgSuccess=self.trUtf8("Expired sessions cleared successfully.")) |
2130 res = dia.startProcess(args, wd) | 2237 res = dia.startProcess(args, wd) |
2131 if res: | 2238 if res: |
2132 dia.exec_() | 2239 dia.exec_() |
2133 | 2240 |
2191 """ | 2298 """ |
2192 Private slot handling the addition of a new language. | 2299 Private slot handling the addition of a new language. |
2193 | 2300 |
2194 @param code language code of the new language (string) | 2301 @param code language code of the new language (string) |
2195 """ | 2302 """ |
2196 title = self.trUtf8("Initializing message catalog for '{0}'").format(code) | 2303 title = self.trUtf8("Initializing message catalog for '{0}'")\ |
2304 .format(code) | |
2197 | 2305 |
2198 args = [] | 2306 args = [] |
2199 args.append(self.__getPythonExecutable()) | 2307 args.append(self.__getPythonExecutable()) |
2200 args.append("manage.py") | 2308 args.append("manage.py") |
2201 args.append("makemessages") | 2309 args.append("makemessages") |
2203 args.append(code) | 2311 args.append(code) |
2204 | 2312 |
2205 try: | 2313 try: |
2206 wd = self.__sitePath() | 2314 wd = self.__sitePath() |
2207 except DjangoNoSiteSelectedException: | 2315 except DjangoNoSiteSelectedException: |
2208 E5MessageBox.warning(None, | 2316 E5MessageBox.warning( |
2317 None, | |
2209 title, | 2318 title, |
2210 self.trUtf8('No current site selected or no site created yet.' | 2319 self.trUtf8('No current site selected or no site created yet.' |
2211 ' Aborting...')) | 2320 ' Aborting...')) |
2212 return | 2321 return |
2213 | 2322 |
2214 dia = DjangoDialog(title, | 2323 dia = DjangoDialog( |
2215 msgSuccess=self.trUtf8("\nMessage catalog initialized successfully.")) | 2324 title, |
2325 msgSuccess=self.trUtf8( | |
2326 "\nMessage catalog initialized successfully.")) | |
2216 res = dia.startProcess(args, wd) | 2327 res = dia.startProcess(args, wd) |
2217 if res: | 2328 if res: |
2218 dia.exec_() | 2329 dia.exec_() |
2219 | 2330 |
2220 langFile = self.__e5project.pdata["TRANSLATIONPATTERN"][0]\ | 2331 langFile = self.__e5project.pdata["TRANSLATIONPATTERN"][0]\ |
2230 title = self.trUtf8("Updating message catalogs") | 2341 title = self.trUtf8("Updating message catalogs") |
2231 | 2342 |
2232 try: | 2343 try: |
2233 wd = self.__sitePath() | 2344 wd = self.__sitePath() |
2234 except DjangoNoSiteSelectedException: | 2345 except DjangoNoSiteSelectedException: |
2235 E5MessageBox.warning(None, | 2346 E5MessageBox.warning( |
2347 None, | |
2236 title, | 2348 title, |
2237 self.trUtf8('No current site selected or no site created yet.' | 2349 self.trUtf8('No current site selected or no site created yet.' |
2238 ' Aborting...')) | 2350 ' Aborting...')) |
2239 return | 2351 return |
2240 | 2352 |
2241 argsLists = [] | 2353 argsLists = [] |
2242 | 2354 |
2243 for filename in self.__normalizeList(self.__siteFilteredList(filenames)): | 2355 for filename in self.__normalizeList( |
2356 self.__siteFilteredList(filenames)): | |
2244 locale = self.__getLocale(filename) | 2357 locale = self.__getLocale(filename) |
2245 if locale: | 2358 if locale: |
2246 args = [] | 2359 args = [] |
2247 args.append(self.__getPythonExecutable()) | 2360 args.append(self.__getPythonExecutable()) |
2248 args.append("manage.py") | 2361 args.append("manage.py") |
2251 args.append("-l") | 2364 args.append("-l") |
2252 args.append(locale) | 2365 args.append(locale) |
2253 argsLists.append(args) | 2366 argsLists.append(args) |
2254 | 2367 |
2255 if len(argsLists) == 0: | 2368 if len(argsLists) == 0: |
2256 E5MessageBox.warning(None, | 2369 E5MessageBox.warning( |
2370 None, | |
2257 title, | 2371 title, |
2258 self.trUtf8('No locales detected. Aborting...')) | 2372 self.trUtf8('No locales detected. Aborting...')) |
2259 return | 2373 return |
2260 | 2374 |
2261 dia = DjangoDialog(title, | 2375 dia = DjangoDialog( |
2376 title, | |
2262 msgSuccess=self.trUtf8("\nMessage catalogs updated successfully.")) | 2377 msgSuccess=self.trUtf8("\nMessage catalogs updated successfully.")) |
2263 res = dia.startBatchProcesses(argsLists, wd) | 2378 res = dia.startBatchProcesses(argsLists, wd) |
2264 if res: | 2379 if res: |
2265 dia.exec_() | 2380 dia.exec_() |
2266 | 2381 |
2268 """ | 2383 """ |
2269 Public method to update the message catalogs keeping obsolete messages. | 2384 Public method to update the message catalogs keeping obsolete messages. |
2270 | 2385 |
2271 @param filenames list of filenames | 2386 @param filenames list of filenames |
2272 """ | 2387 """ |
2273 title = self.trUtf8("Updating message catalogs (keeping obsolete messages)") | 2388 title = self.trUtf8("Updating message catalogs (keeping obsolete" |
2389 " messages)") | |
2274 | 2390 |
2275 try: | 2391 try: |
2276 wd = self.__sitePath() | 2392 wd = self.__sitePath() |
2277 except DjangoNoSiteSelectedException: | 2393 except DjangoNoSiteSelectedException: |
2278 E5MessageBox.warning(None, | 2394 E5MessageBox.warning( |
2395 None, | |
2279 title, | 2396 title, |
2280 self.trUtf8('No current site selected or no site created yet.' | 2397 self.trUtf8('No current site selected or no site created yet.' |
2281 ' Aborting...')) | 2398 ' Aborting...')) |
2282 return | 2399 return |
2283 | 2400 |
2284 argsLists = [] | 2401 argsLists = [] |
2285 | 2402 |
2286 for filename in self.__normalizeList(self.__siteFilteredList(filenames)): | 2403 for filename in self.__normalizeList( |
2404 self.__siteFilteredList(filenames)): | |
2287 locale = self.__getLocale(filename) | 2405 locale = self.__getLocale(filename) |
2288 if locale: | 2406 if locale: |
2289 args = [] | 2407 args = [] |
2290 args.append(self.__getPythonExecutable()) | 2408 args.append(self.__getPythonExecutable()) |
2291 args.append("manage.py") | 2409 args.append("manage.py") |
2293 args.append("-l") | 2411 args.append("-l") |
2294 args.append(locale) | 2412 args.append(locale) |
2295 argsLists.append(args) | 2413 argsLists.append(args) |
2296 | 2414 |
2297 if len(argsLists) == 0: | 2415 if len(argsLists) == 0: |
2298 E5MessageBox.warning(None, | 2416 E5MessageBox.warning( |
2417 None, | |
2299 title, | 2418 title, |
2300 self.trUtf8('No locales detected. Aborting...')) | 2419 self.trUtf8('No locales detected. Aborting...')) |
2301 return | 2420 return |
2302 | 2421 |
2303 dia = DjangoDialog(title, | 2422 dia = DjangoDialog( |
2423 title, | |
2304 msgSuccess=self.trUtf8("\nMessage catalogs updated successfully.")) | 2424 msgSuccess=self.trUtf8("\nMessage catalogs updated successfully.")) |
2305 res = dia.startBatchProcesses(argsLists, wd) | 2425 res = dia.startBatchProcesses(argsLists, wd) |
2306 if res: | 2426 if res: |
2307 dia.exec_() | 2427 dia.exec_() |
2308 | 2428 |
2322 args.append("--no-obsolete") | 2442 args.append("--no-obsolete") |
2323 | 2443 |
2324 try: | 2444 try: |
2325 wd = self.__sitePath() | 2445 wd = self.__sitePath() |
2326 except DjangoNoSiteSelectedException: | 2446 except DjangoNoSiteSelectedException: |
2327 E5MessageBox.warning(None, | 2447 E5MessageBox.warning( |
2448 None, | |
2328 title, | 2449 title, |
2329 self.trUtf8('No current site selected or no site created yet.' | 2450 self.trUtf8('No current site selected or no site created yet.' |
2330 ' Aborting...')) | 2451 ' Aborting...')) |
2331 return | 2452 return |
2332 | 2453 |
2333 dia = DjangoDialog(title, | 2454 dia = DjangoDialog( |
2455 title, | |
2334 msgSuccess=self.trUtf8("\nMessage catalogs updated successfully.")) | 2456 msgSuccess=self.trUtf8("\nMessage catalogs updated successfully.")) |
2335 res = dia.startProcess(args, wd) | 2457 res = dia.startProcess(args, wd) |
2336 if res: | 2458 if res: |
2337 dia.exec_() | 2459 dia.exec_() |
2338 | 2460 |
2340 """ | 2462 """ |
2341 Public method to update the message catalogs keeping obsolete messages. | 2463 Public method to update the message catalogs keeping obsolete messages. |
2342 | 2464 |
2343 @param filenames list of filenames (not used) | 2465 @param filenames list of filenames (not used) |
2344 """ | 2466 """ |
2345 title = self.trUtf8("Updating message catalogs (keeping obsolete messages)") | 2467 title = self.trUtf8("Updating message catalogs (keeping obsolete" |
2468 " messages)") | |
2346 | 2469 |
2347 args = [] | 2470 args = [] |
2348 args.append(self.__getPythonExecutable()) | 2471 args.append(self.__getPythonExecutable()) |
2349 args.append("manage.py") | 2472 args.append("manage.py") |
2350 args.append("makemessages") | 2473 args.append("makemessages") |
2351 args.append("-a") | 2474 args.append("-a") |
2352 | 2475 |
2353 try: | 2476 try: |
2354 wd = self.__sitePath() | 2477 wd = self.__sitePath() |
2355 except DjangoNoSiteSelectedException: | 2478 except DjangoNoSiteSelectedException: |
2356 E5MessageBox.warning(None, | 2479 E5MessageBox.warning( |
2480 None, | |
2357 title, | 2481 title, |
2358 self.trUtf8('No current site selected or no site created yet.' | 2482 self.trUtf8('No current site selected or no site created yet.' |
2359 ' Aborting...')) | 2483 ' Aborting...')) |
2360 return | 2484 return |
2361 | 2485 |
2362 dia = DjangoDialog(title, | 2486 dia = DjangoDialog( |
2487 title, | |
2363 msgSuccess=self.trUtf8("\nMessage catalogs updated successfully.")) | 2488 msgSuccess=self.trUtf8("\nMessage catalogs updated successfully.")) |
2364 res = dia.startProcess(args, wd) | 2489 res = dia.startProcess(args, wd) |
2365 if res: | 2490 if res: |
2366 dia.exec_() | 2491 dia.exec_() |
2367 | 2492 |
2374 title = self.trUtf8("Compiling message catalogs") | 2499 title = self.trUtf8("Compiling message catalogs") |
2375 | 2500 |
2376 try: | 2501 try: |
2377 wd = self.__sitePath() | 2502 wd = self.__sitePath() |
2378 except DjangoNoSiteSelectedException: | 2503 except DjangoNoSiteSelectedException: |
2379 E5MessageBox.warning(None, | 2504 E5MessageBox.warning( |
2505 None, | |
2380 title, | 2506 title, |
2381 self.trUtf8('No current site selected or no site created yet.' | 2507 self.trUtf8('No current site selected or no site created yet.' |
2382 ' Aborting...')) | 2508 ' Aborting...')) |
2383 return | 2509 return |
2384 | 2510 |
2385 argsLists = [] | 2511 argsLists = [] |
2386 | 2512 |
2387 for filename in self.__normalizeList(self.__siteFilteredList(filenames)): | 2513 for filename in self.__normalizeList( |
2514 self.__siteFilteredList(filenames)): | |
2388 locale = self.__getLocale(filename) | 2515 locale = self.__getLocale(filename) |
2389 if locale: | 2516 if locale: |
2390 args = [] | 2517 args = [] |
2391 args.append(self.__getPythonExecutable()) | 2518 args.append(self.__getPythonExecutable()) |
2392 args.append("manage.py") | 2519 args.append("manage.py") |
2394 args.append("-l") | 2521 args.append("-l") |
2395 args.append(locale) | 2522 args.append(locale) |
2396 argsLists.append(args) | 2523 argsLists.append(args) |
2397 | 2524 |
2398 if len(argsLists) == 0: | 2525 if len(argsLists) == 0: |
2399 E5MessageBox.warning(None, | 2526 E5MessageBox.warning( |
2527 None, | |
2400 title, | 2528 title, |
2401 self.trUtf8('No locales detected. Aborting...')) | 2529 self.trUtf8('No locales detected. Aborting...')) |
2402 return | 2530 return |
2403 | 2531 |
2404 dia = DjangoDialog(title, | 2532 dia = DjangoDialog( |
2405 msgSuccess=self.trUtf8("\nMessage catalogs compiled successfully.")) | 2533 title, |
2534 msgSuccess=self.trUtf8( | |
2535 "\nMessage catalogs compiled successfully.")) | |
2406 res = dia.startBatchProcesses(argsLists, wd, mergedOutput=True) | 2536 res = dia.startBatchProcesses(argsLists, wd, mergedOutput=True) |
2407 if res: | 2537 if res: |
2408 dia.exec_() | 2538 dia.exec_() |
2409 | 2539 |
2410 for entry in os.walk(self.__sitePath()): | 2540 for entry in os.walk(self.__sitePath()): |
2427 args.append("compilemessages") | 2557 args.append("compilemessages") |
2428 | 2558 |
2429 try: | 2559 try: |
2430 wd = self.__sitePath() | 2560 wd = self.__sitePath() |
2431 except DjangoNoSiteSelectedException: | 2561 except DjangoNoSiteSelectedException: |
2432 E5MessageBox.warning(None, | 2562 E5MessageBox.warning( |
2563 None, | |
2433 title, | 2564 title, |
2434 self.trUtf8('No current site selected or no site created yet.' | 2565 self.trUtf8('No current site selected or no site created yet.' |
2435 ' Aborting...')) | 2566 ' Aborting...')) |
2436 return | 2567 return |
2437 | 2568 |
2438 dia = DjangoDialog(title, | 2569 dia = DjangoDialog( |
2439 msgSuccess=self.trUtf8("\nMessage catalogs compiled successfully.")) | 2570 title, |
2571 msgSuccess=self.trUtf8( | |
2572 "\nMessage catalogs compiled successfully.")) | |
2440 res = dia.startProcess(args, wd, mergedOutput=True) | 2573 res = dia.startProcess(args, wd, mergedOutput=True) |
2441 if res: | 2574 if res: |
2442 dia.exec_() | 2575 dia.exec_() |
2443 | 2576 |
2444 for entry in os.walk(self.__sitePath()): | 2577 for entry in os.walk(self.__sitePath()): |
2459 wd = self.__sitePath() | 2592 wd = self.__sitePath() |
2460 except DjangoNoSiteSelectedException: | 2593 except DjangoNoSiteSelectedException: |
2461 wd = "" | 2594 wd = "" |
2462 started, pid = QProcess.startDetached(editor, [poFile], wd) | 2595 started, pid = QProcess.startDetached(editor, [poFile], wd) |
2463 if not started: | 2596 if not started: |
2464 E5MessageBox.critical(None, | 2597 E5MessageBox.critical( |
2598 None, | |
2465 self.trUtf8('Process Generation Error'), | 2599 self.trUtf8('Process Generation Error'), |
2466 self.trUtf8('The translations editor process ({0}) could not' | 2600 self.trUtf8('The translations editor process ({0}) could' |
2467 ' be started.').format(os.path.basename(editor))) | 2601 ' not be started.') |
2602 .format(os.path.basename(editor))) |