48:cf944abf6137 | 51:0b60dbff8e9a |
---|---|
15 | 15 |
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 PyQt5.QtCore import QObject, QTimer, QUrl, QFileInfo |
21 from PyQt4.QtGui import QMenu, QInputDialog, QLineEdit, QDesktopServices, \ | 21 from PyQt5.QtGui import QDesktopServices |
22 QDialog | 22 from PyQt5.QtWidgets import QMenu, QInputDialog, QLineEdit, QDialog |
23 from PyQt4.QtCore import QProcess as QProcessPyQt | 23 from PyQt5.QtCore import QProcess as QProcessPyQt |
24 | 24 |
25 from E5Gui.E5Application import e5App | 25 from E5Gui.E5Application import e5App |
26 from E5Gui import E5MessageBox, E5FileDialog | 26 from E5Gui import E5MessageBox, E5FileDialog |
27 from E5Gui.E5Action import E5Action | 27 from E5Gui.E5Action import E5Action |
28 | 28 |
46 """ | 46 """ |
47 Class transforming the call arguments in case of gnome-terminal. | 47 Class transforming the call arguments in case of gnome-terminal. |
48 """ | 48 """ |
49 def start(self, cmd, args=[], mode=QProcessPyQt.ReadWrite): | 49 def start(self, cmd, args=[], mode=QProcessPyQt.ReadWrite): |
50 """ | 50 """ |
51 Static method to start the given program (cmd) in a new process, if | 51 Public method to start the given program (cmd) in a new process, if |
52 none is already running, passing the command line arguments in args. | 52 none is already running, passing the command line arguments in args. |
53 | 53 |
54 @param cmd start the given program cmd (string) | 54 @param cmd start the given program cmd (string) |
55 @keyparam args list of parameters (list of strings) | 55 @keyparam args list of parameters (list of strings) |
56 @keyparam mode access mode (QIODevice.OpenMode) | 56 @keyparam mode access mode (QIODevice.OpenMode) |
61 super(QProcess, self).start(cmd, args, mode) | 61 super(QProcess, self).start(cmd, args, mode) |
62 | 62 |
63 @staticmethod | 63 @staticmethod |
64 def startDetached(cmd, args=[], path=''): | 64 def startDetached(cmd, args=[], path=''): |
65 """ | 65 """ |
66 Static method to start the given program (cmd) in a new process, if | 66 Public static method to start the given program (cmd) in a new process, |
67 none is already running, passing the command line arguments in args. | 67 if none is already running, passing the command line arguments in args. |
68 | 68 |
69 @param cmd start the given program cmd (string) | 69 @param cmd start the given program cmd (string) |
70 @keyparam args list of parameters (list of strings) | 70 @keyparam args list of parameters (list of strings) |
71 @keyparam path new working directory (string) | 71 @keyparam path new working directory (string) |
72 @return tuple of successful start and process id (boolean, integer) | 72 @return tuple of successful start and process id (boolean, integer) |
110 Public method to define the Django actions. | 110 Public method to define the Django actions. |
111 """ | 111 """ |
112 self.actions = [] | 112 self.actions = [] |
113 | 113 |
114 self.selectSiteAct = E5Action( | 114 self.selectSiteAct = E5Action( |
115 self.trUtf8('Current Project'), | 115 self.tr('Current Project'), |
116 "", | 116 "", |
117 0, 0, | 117 0, 0, |
118 self, 'django_current_project') | 118 self, 'django_current_project') |
119 self.selectSiteAct.setStatusTip(self.trUtf8( | 119 self.selectSiteAct.setStatusTip(self.tr( |
120 'Selects the current project')) | 120 'Selects the current project')) |
121 self.selectSiteAct.setWhatsThis(self.trUtf8( | 121 self.selectSiteAct.setWhatsThis(self.tr( |
122 """<b>Current Project</b>""" | 122 """<b>Current Project</b>""" |
123 """<p>Selects the current project. Used for multi-project """ | 123 """<p>Selects the current project. Used for multi-project """ |
124 """Django projects to switch between the projects.</p>""" | 124 """Django projects to switch between the projects.</p>""" |
125 )) | 125 )) |
126 self.selectSiteAct.triggered[()].connect(self.__selectSite) | 126 self.selectSiteAct.triggered.connect(self.__selectSite) |
127 self.actions.append(self.selectSiteAct) | 127 self.actions.append(self.selectSiteAct) |
128 self.__setCurrentSite(None) | 128 self.__setCurrentSite(None) |
129 | 129 |
130 ############################## | 130 ############################## |
131 ## start actions below ## | 131 ## start actions below ## |
132 ############################## | 132 ############################## |
133 | 133 |
134 self.startProjectAct = E5Action( | 134 self.startProjectAct = E5Action( |
135 self.trUtf8('Start Project'), | 135 self.tr('Start Project'), |
136 self.trUtf8('Start &Project'), | 136 self.tr('Start &Project'), |
137 0, 0, | 137 0, 0, |
138 self, 'django_start_project') | 138 self, 'django_start_project') |
139 self.startProjectAct.setStatusTip(self.trUtf8( | 139 self.startProjectAct.setStatusTip(self.tr( |
140 'Starts a new Django project')) | 140 'Starts a new Django project')) |
141 self.startProjectAct.setWhatsThis(self.trUtf8( | 141 self.startProjectAct.setWhatsThis(self.tr( |
142 """<b>Start Project</b>""" | 142 """<b>Start Project</b>""" |
143 """<p>Starts a new Django project using "django-admin.py""" | 143 """<p>Starts a new Django project using "django-admin.py""" |
144 """ startproject".</p>""" | 144 """ startproject".</p>""" |
145 )) | 145 )) |
146 self.startProjectAct.triggered[()].connect(self.__startProject) | 146 self.startProjectAct.triggered.connect(self.__startProject) |
147 self.actions.append(self.startProjectAct) | 147 self.actions.append(self.startProjectAct) |
148 | 148 |
149 self.startGlobalApplicationAct = E5Action( | 149 self.startGlobalApplicationAct = E5Action( |
150 self.trUtf8('Start Application (global)'), | 150 self.tr('Start Application (global)'), |
151 self.trUtf8('Start Application (&global)'), | 151 self.tr('Start Application (&global)'), |
152 0, 0, | 152 0, 0, |
153 self, 'django_start_global_application') | 153 self, 'django_start_global_application') |
154 self.startGlobalApplicationAct.setStatusTip(self.trUtf8( | 154 self.startGlobalApplicationAct.setStatusTip(self.tr( |
155 'Starts a new global Django application')) | 155 'Starts a new global Django application')) |
156 self.startGlobalApplicationAct.setWhatsThis(self.trUtf8( | 156 self.startGlobalApplicationAct.setWhatsThis(self.tr( |
157 """<b>Start Application (global)</b>""" | 157 """<b>Start Application (global)</b>""" |
158 """<p>Starts a new global Django application using""" | 158 """<p>Starts a new global Django application using""" |
159 """ "django-admin.py startapp".</p>""" | 159 """ "django-admin.py startapp".</p>""" |
160 )) | 160 )) |
161 self.startGlobalApplicationAct.triggered[()].connect( | 161 self.startGlobalApplicationAct.triggered.connect( |
162 self.__startGlobalApplication) | 162 self.__startGlobalApplication) |
163 self.actions.append(self.startGlobalApplicationAct) | 163 self.actions.append(self.startGlobalApplicationAct) |
164 | 164 |
165 self.startLocalApplicationAct = E5Action( | 165 self.startLocalApplicationAct = E5Action( |
166 self.trUtf8('Start Application (local)'), | 166 self.tr('Start Application (local)'), |
167 self.trUtf8('Start Application (&local)'), | 167 self.tr('Start Application (&local)'), |
168 0, 0, | 168 0, 0, |
169 self, 'django_start_local_application') | 169 self, 'django_start_local_application') |
170 self.startLocalApplicationAct.setStatusTip(self.trUtf8( | 170 self.startLocalApplicationAct.setStatusTip(self.tr( |
171 'Starts a new local Django application')) | 171 'Starts a new local Django application')) |
172 self.startLocalApplicationAct.setWhatsThis(self.trUtf8( | 172 self.startLocalApplicationAct.setWhatsThis(self.tr( |
173 """<b>Start Application (local)</b>""" | 173 """<b>Start Application (local)</b>""" |
174 """<p>Starts a new local Django application using""" | 174 """<p>Starts a new local Django application using""" |
175 """ "manage.py startapp".</p>""" | 175 """ "manage.py startapp".</p>""" |
176 )) | 176 )) |
177 self.startLocalApplicationAct.triggered[()].connect( | 177 self.startLocalApplicationAct.triggered.connect( |
178 self.__startLocalApplication) | 178 self.__startLocalApplication) |
179 self.actions.append(self.startLocalApplicationAct) | 179 self.actions.append(self.startLocalApplicationAct) |
180 | 180 |
181 ############################## | 181 ############################## |
182 ## run actions below ## | 182 ## run actions below ## |
183 ############################## | 183 ############################## |
184 | 184 |
185 self.runServerAct = E5Action( | 185 self.runServerAct = E5Action( |
186 self.trUtf8('Run Server'), | 186 self.tr('Run Server'), |
187 self.trUtf8('Run &Server'), | 187 self.tr('Run &Server'), |
188 0, 0, | 188 0, 0, |
189 self, 'django_run_server') | 189 self, 'django_run_server') |
190 self.runServerAct.setStatusTip(self.trUtf8( | 190 self.runServerAct.setStatusTip(self.tr( |
191 'Starts the Django Web server')) | 191 'Starts the Django Web server')) |
192 self.runServerAct.setWhatsThis(self.trUtf8( | 192 self.runServerAct.setWhatsThis(self.tr( |
193 """<b>Run Server</b>""" | 193 """<b>Run Server</b>""" |
194 """<p>Starts the Django Web server using "manage.py""" | 194 """<p>Starts the Django Web server using "manage.py""" |
195 """ runserver".</p>""" | 195 """ runserver".</p>""" |
196 )) | 196 )) |
197 self.runServerAct.triggered[()].connect(self.__runServer) | 197 self.runServerAct.triggered.connect(self.__runServer) |
198 self.actions.append(self.runServerAct) | 198 self.actions.append(self.runServerAct) |
199 | 199 |
200 self.runBrowserAct = E5Action( | 200 self.runBrowserAct = E5Action( |
201 self.trUtf8('Run Web-Browser'), | 201 self.tr('Run Web-Browser'), |
202 self.trUtf8('Run &Web-Browser'), | 202 self.tr('Run &Web-Browser'), |
203 0, 0, | 203 0, 0, |
204 self, 'django_run_browser') | 204 self, 'django_run_browser') |
205 self.runBrowserAct.setStatusTip(self.trUtf8( | 205 self.runBrowserAct.setStatusTip(self.tr( |
206 'Starts the default Web-Browser with the URL of the Django Web' | 206 'Starts the default Web-Browser with the URL of the Django Web' |
207 ' server')) | 207 ' server')) |
208 self.runBrowserAct.setWhatsThis(self.trUtf8( | 208 self.runBrowserAct.setWhatsThis(self.tr( |
209 """<b>Run Web-Browser</b>""" | 209 """<b>Run Web-Browser</b>""" |
210 """<p>Starts the default Web-Browser with the URL of the """ | 210 """<p>Starts the default Web-Browser with the URL of the """ |
211 """Django Web server.</p>""" | 211 """Django Web server.</p>""" |
212 )) | 212 )) |
213 self.runBrowserAct.triggered[()].connect(self.__runBrowser) | 213 self.runBrowserAct.triggered.connect(self.__runBrowser) |
214 self.actions.append(self.runBrowserAct) | 214 self.actions.append(self.runBrowserAct) |
215 | 215 |
216 ############################## | 216 ############################## |
217 ## caching actions below ## | 217 ## caching actions below ## |
218 ############################## | 218 ############################## |
219 | 219 |
220 self.createCacheTableAct = E5Action( | 220 self.createCacheTableAct = E5Action( |
221 self.trUtf8('Create Cache Tables'), | 221 self.tr('Create Cache Tables'), |
222 self.trUtf8('C&reate Cache Tables'), | 222 self.tr('C&reate Cache Tables'), |
223 0, 0, | 223 0, 0, |
224 self, 'django_create_cache_tables') | 224 self, 'django_create_cache_tables') |
225 self.createCacheTableAct.setStatusTip(self.trUtf8( | 225 self.createCacheTableAct.setStatusTip(self.tr( |
226 'Creates the tables needed to use the SQL cache backend')) | 226 'Creates the tables needed to use the SQL cache backend')) |
227 self.createCacheTableAct.setWhatsThis(self.trUtf8( | 227 self.createCacheTableAct.setWhatsThis(self.tr( |
228 """<b>Create Cache Tables</b>""" | 228 """<b>Create Cache Tables</b>""" |
229 """<p>Creates the tables needed to use the SQL cache""" | 229 """<p>Creates the tables needed to use the SQL cache""" |
230 """ backend.</p>""" | 230 """ backend.</p>""" |
231 )) | 231 )) |
232 self.createCacheTableAct.triggered[()].connect( | 232 self.createCacheTableAct.triggered.connect( |
233 self.__createCacheTables) | 233 self.__createCacheTables) |
234 self.actions.append(self.createCacheTableAct) | 234 self.actions.append(self.createCacheTableAct) |
235 | 235 |
236 ############################## | 236 ############################## |
237 ## help action below ## | 237 ## help action below ## |
238 ############################## | 238 ############################## |
239 | 239 |
240 self.helpAct = E5Action( | 240 self.helpAct = E5Action( |
241 self.trUtf8('Help'), | 241 self.tr('Help'), |
242 self.trUtf8('&Help'), | 242 self.tr('&Help'), |
243 0, 0, | 243 0, 0, |
244 self, 'django_help') | 244 self, 'django_help') |
245 self.helpAct.setStatusTip(self.trUtf8( | 245 self.helpAct.setStatusTip(self.tr( |
246 'Shows the Django help index')) | 246 'Shows the Django help index')) |
247 self.helpAct.setWhatsThis(self.trUtf8( | 247 self.helpAct.setWhatsThis(self.tr( |
248 """<b>Help</b>""" | 248 """<b>Help</b>""" |
249 """<p>Shows the Django help index page.</p>""" | 249 """<p>Shows the Django help index page.</p>""" |
250 )) | 250 )) |
251 self.helpAct.triggered[()].connect(self.__showHelpIndex) | 251 self.helpAct.triggered.connect(self.__showHelpIndex) |
252 self.actions.append(self.helpAct) | 252 self.actions.append(self.helpAct) |
253 | 253 |
254 ############################## | 254 ############################## |
255 ## about action below ## | 255 ## about action below ## |
256 ############################## | 256 ############################## |
257 | 257 |
258 self.aboutDjangoAct = E5Action( | 258 self.aboutDjangoAct = E5Action( |
259 self.trUtf8('About Django'), | 259 self.tr('About Django'), |
260 self.trUtf8('About D&jango'), | 260 self.tr('About D&jango'), |
261 0, 0, | 261 0, 0, |
262 self, 'django_about') | 262 self, 'django_about') |
263 self.aboutDjangoAct.setStatusTip(self.trUtf8( | 263 self.aboutDjangoAct.setStatusTip(self.tr( |
264 'Shows some information about Django')) | 264 'Shows some information about Django')) |
265 self.aboutDjangoAct.setWhatsThis(self.trUtf8( | 265 self.aboutDjangoAct.setWhatsThis(self.tr( |
266 """<b>About Django</b>""" | 266 """<b>About Django</b>""" |
267 """<p>Shows some information about Django.</p>""" | 267 """<p>Shows some information about Django.</p>""" |
268 )) | 268 )) |
269 self.aboutDjangoAct.triggered[()].connect(self.__djangoInfo) | 269 self.aboutDjangoAct.triggered.connect(self.__djangoInfo) |
270 self.actions.append(self.aboutDjangoAct) | 270 self.actions.append(self.aboutDjangoAct) |
271 | 271 |
272 self.__initDatabaseActions() | 272 self.__initDatabaseActions() |
273 self.__initDatabaseSqlActions() | 273 self.__initDatabaseSqlActions() |
274 self.__initToolsActions() | 274 self.__initToolsActions() |
279 def __initDatabaseActions(self): | 279 def __initDatabaseActions(self): |
280 """ | 280 """ |
281 Private method to define the database related actions. | 281 Private method to define the database related actions. |
282 """ | 282 """ |
283 self.syncDatabaseAct = E5Action( | 283 self.syncDatabaseAct = E5Action( |
284 self.trUtf8('Synchronize'), | 284 self.tr('Synchronize'), |
285 self.trUtf8('&Synchronize'), | 285 self.tr('&Synchronize'), |
286 0, 0, | 286 0, 0, |
287 self, 'django_database_syncdb') | 287 self, 'django_database_syncdb') |
288 self.syncDatabaseAct.setStatusTip(self.trUtf8( | 288 self.syncDatabaseAct.setStatusTip(self.tr( |
289 'Synchronizes the database')) | 289 'Synchronizes the database')) |
290 self.syncDatabaseAct.setWhatsThis(self.trUtf8( | 290 self.syncDatabaseAct.setWhatsThis(self.tr( |
291 """<b>Synchronize</b>""" | 291 """<b>Synchronize</b>""" |
292 """<p>Synchronizes the database.</p>""" | 292 """<p>Synchronizes the database.</p>""" |
293 )) | 293 )) |
294 self.syncDatabaseAct.triggered[()].connect(self.__databaseSynchronize) | 294 self.syncDatabaseAct.triggered.connect(self.__databaseSynchronize) |
295 self.actions.append(self.syncDatabaseAct) | 295 self.actions.append(self.syncDatabaseAct) |
296 | 296 |
297 self.inspectDatabaseAct = E5Action( | 297 self.inspectDatabaseAct = E5Action( |
298 self.trUtf8('Introspect'), | 298 self.tr('Introspect'), |
299 self.trUtf8('&Introspect'), | 299 self.tr('&Introspect'), |
300 0, 0, | 300 0, 0, |
301 self, 'django_database_inspect') | 301 self, 'django_database_inspect') |
302 self.inspectDatabaseAct.setStatusTip(self.trUtf8( | 302 self.inspectDatabaseAct.setStatusTip(self.tr( |
303 'Introspects the database tables and outputs a Django model' | 303 'Introspects the database tables and outputs a Django model' |
304 ' module')) | 304 ' module')) |
305 self.inspectDatabaseAct.setWhatsThis(self.trUtf8( | 305 self.inspectDatabaseAct.setWhatsThis(self.tr( |
306 """<b>Introspect</b>""" | 306 """<b>Introspect</b>""" |
307 """<p>Introspects the database tables and outputs a """ | 307 """<p>Introspects the database tables and outputs a """ |
308 """Django model module.</p>""" | 308 """Django model module.</p>""" |
309 )) | 309 )) |
310 self.inspectDatabaseAct.triggered[()].connect(self.__databaseInspect) | 310 self.inspectDatabaseAct.triggered.connect(self.__databaseInspect) |
311 self.actions.append(self.inspectDatabaseAct) | 311 self.actions.append(self.inspectDatabaseAct) |
312 | 312 |
313 self.flushDatabaseAct = E5Action( | 313 self.flushDatabaseAct = E5Action( |
314 self.trUtf8('Flush'), | 314 self.tr('Flush'), |
315 self.trUtf8('&Flush'), | 315 self.tr('&Flush'), |
316 0, 0, | 316 0, 0, |
317 self, 'django_database_flush') | 317 self, 'django_database_flush') |
318 self.flushDatabaseAct.setStatusTip(self.trUtf8( | 318 self.flushDatabaseAct.setStatusTip(self.tr( |
319 'Returns all database tables to the state just after their' | 319 'Returns all database tables to the state just after their' |
320 ' installation')) | 320 ' installation')) |
321 self.flushDatabaseAct.setWhatsThis(self.trUtf8( | 321 self.flushDatabaseAct.setWhatsThis(self.tr( |
322 """<b>Flush</b>""" | 322 """<b>Flush</b>""" |
323 """<p>Returns all database tables to the state """ | 323 """<p>Returns all database tables to the state """ |
324 """just after their installation.</p>""" | 324 """just after their installation.</p>""" |
325 )) | 325 )) |
326 self.flushDatabaseAct.triggered[()].connect(self.__databaseFlush) | 326 self.flushDatabaseAct.triggered.connect(self.__databaseFlush) |
327 self.actions.append(self.flushDatabaseAct) | 327 self.actions.append(self.flushDatabaseAct) |
328 | 328 |
329 self.databaseClientAct = E5Action( | 329 self.databaseClientAct = E5Action( |
330 self.trUtf8('Start Client Console'), | 330 self.tr('Start Client Console'), |
331 self.trUtf8('Start &Client Console'), | 331 self.tr('Start &Client Console'), |
332 0, 0, | 332 0, 0, |
333 self, 'django_database_client') | 333 self, 'django_database_client') |
334 self.databaseClientAct.setStatusTip(self.trUtf8( | 334 self.databaseClientAct.setStatusTip(self.tr( |
335 'Starts a console window for the database client')) | 335 'Starts a console window for the database client')) |
336 self.databaseClientAct.setWhatsThis(self.trUtf8( | 336 self.databaseClientAct.setWhatsThis(self.tr( |
337 """<b>Start Client Console</b>""" | 337 """<b>Start Client Console</b>""" |
338 """<p>Starts a console window for the database client.</p>""" | 338 """<p>Starts a console window for the database client.</p>""" |
339 )) | 339 )) |
340 self.databaseClientAct.triggered[()].connect(self.__runDatabaseClient) | 340 self.databaseClientAct.triggered.connect(self.__runDatabaseClient) |
341 self.actions.append(self.databaseClientAct) | 341 self.actions.append(self.databaseClientAct) |
342 | 342 |
343 def __initDatabaseSqlActions(self): | 343 def __initDatabaseSqlActions(self): |
344 """ | 344 """ |
345 Private method to define the database SQL related actions. | 345 Private method to define the database SQL related actions. |
346 """ | 346 """ |
347 self.databaseSqlCreateTablesAct = E5Action( | 347 self.databaseSqlCreateTablesAct = E5Action( |
348 self.trUtf8('Create Tables'), | 348 self.tr('Create Tables'), |
349 self.trUtf8('Create &Tables'), | 349 self.tr('Create &Tables'), |
350 0, 0, | 350 0, 0, |
351 self, 'django_database_sql_create_tables') | 351 self, 'django_database_sql_create_tables') |
352 self.databaseSqlCreateTablesAct.setStatusTip(self.trUtf8( | 352 self.databaseSqlCreateTablesAct.setStatusTip(self.tr( |
353 'Prints the CREATE TABLE SQL statements for one or more' | 353 'Prints the CREATE TABLE SQL statements for one or more' |
354 ' applications')) | 354 ' applications')) |
355 self.databaseSqlCreateTablesAct.setWhatsThis(self.trUtf8( | 355 self.databaseSqlCreateTablesAct.setWhatsThis(self.tr( |
356 """<b>Create Tables</b>""" | 356 """<b>Create Tables</b>""" |
357 """<p>Prints the CREATE TABLE SQL statements for one or """ | 357 """<p>Prints the CREATE TABLE SQL statements for one or """ |
358 """more applications.</p>""" | 358 """more applications.</p>""" |
359 )) | 359 )) |
360 self.databaseSqlCreateTablesAct.triggered[()].connect( | 360 self.databaseSqlCreateTablesAct.triggered.connect( |
361 self.__databaseSqlCreateTables) | 361 self.__databaseSqlCreateTables) |
362 self.actions.append(self.databaseSqlCreateTablesAct) | 362 self.actions.append(self.databaseSqlCreateTablesAct) |
363 | 363 |
364 self.databaseSqlCreateIndexesAct = E5Action( | 364 self.databaseSqlCreateIndexesAct = E5Action( |
365 self.trUtf8('Create Indexes'), | 365 self.tr('Create Indexes'), |
366 self.trUtf8('Create &Indexes'), | 366 self.tr('Create &Indexes'), |
367 0, 0, | 367 0, 0, |
368 self, 'django_database_sql_create_indexes') | 368 self, 'django_database_sql_create_indexes') |
369 self.databaseSqlCreateIndexesAct.setStatusTip(self.trUtf8( | 369 self.databaseSqlCreateIndexesAct.setStatusTip(self.tr( |
370 'Prints the CREATE INDEX SQL statements for one or more' | 370 'Prints the CREATE INDEX SQL statements for one or more' |
371 ' applications')) | 371 ' applications')) |
372 self.databaseSqlCreateIndexesAct.setWhatsThis(self.trUtf8( | 372 self.databaseSqlCreateIndexesAct.setWhatsThis(self.tr( |
373 """<b>Create Indexes</b>""" | 373 """<b>Create Indexes</b>""" |
374 """<p>Prints the CREATE INDEX SQL statements for one or """ | 374 """<p>Prints the CREATE INDEX SQL statements for one or """ |
375 """more applications.</p>""" | 375 """more applications.</p>""" |
376 )) | 376 )) |
377 self.databaseSqlCreateIndexesAct.triggered[()].connect( | 377 self.databaseSqlCreateIndexesAct.triggered.connect( |
378 self.__databaseSqlCreateIndexes) | 378 self.__databaseSqlCreateIndexes) |
379 self.actions.append(self.databaseSqlCreateIndexesAct) | 379 self.actions.append(self.databaseSqlCreateIndexesAct) |
380 | 380 |
381 self.databaseSqlCreateEverythingAct = E5Action( | 381 self.databaseSqlCreateEverythingAct = E5Action( |
382 self.trUtf8('Create Everything'), | 382 self.tr('Create Everything'), |
383 self.trUtf8('Create &Everything'), | 383 self.tr('Create &Everything'), |
384 0, 0, | 384 0, 0, |
385 self, 'django_database_sql_create_everything') | 385 self, 'django_database_sql_create_everything') |
386 self.databaseSqlCreateEverythingAct.setStatusTip(self.trUtf8( | 386 self.databaseSqlCreateEverythingAct.setStatusTip(self.tr( |
387 'Prints the CREATE ... SQL statements for one or more' | 387 'Prints the CREATE ... SQL statements for one or more' |
388 ' applications')) | 388 ' applications')) |
389 self.databaseSqlCreateEverythingAct.setWhatsThis(self.trUtf8( | 389 self.databaseSqlCreateEverythingAct.setWhatsThis(self.tr( |
390 """<b>Create Everything</b>""" | 390 """<b>Create Everything</b>""" |
391 """<p>Prints the CREATE TABLE, custom SQL and CREATE INDEX SQL """ | 391 """<p>Prints the CREATE TABLE, custom SQL and CREATE INDEX SQL """ |
392 """statements for one or more applications.</p>""" | 392 """statements for one or more applications.</p>""" |
393 )) | 393 )) |
394 self.databaseSqlCreateEverythingAct.triggered[()].connect( | 394 self.databaseSqlCreateEverythingAct.triggered.connect( |
395 self.__databaseSqlCreateEverything) | 395 self.__databaseSqlCreateEverything) |
396 self.actions.append(self.databaseSqlCreateEverythingAct) | 396 self.actions.append(self.databaseSqlCreateEverythingAct) |
397 | 397 |
398 self.databaseSqlCustomAct = E5Action( | 398 self.databaseSqlCustomAct = E5Action( |
399 self.trUtf8('Custom Statements'), | 399 self.tr('Custom Statements'), |
400 self.trUtf8('&Custom Statements'), | 400 self.tr('&Custom Statements'), |
401 0, 0, | 401 0, 0, |
402 self, 'django_database_sql_custom') | 402 self, 'django_database_sql_custom') |
403 self.databaseSqlCustomAct.setStatusTip(self.trUtf8( | 403 self.databaseSqlCustomAct.setStatusTip(self.tr( |
404 'Prints the custom table modifying SQL statements for ' | 404 'Prints the custom table modifying SQL statements for ' |
405 'one or more applications')) | 405 'one or more applications')) |
406 self.databaseSqlCustomAct.setWhatsThis(self.trUtf8( | 406 self.databaseSqlCustomAct.setWhatsThis(self.tr( |
407 """<b>Custom Statements</b>""" | 407 """<b>Custom Statements</b>""" |
408 """<p>Prints the custom table modifying SQL statements """ | 408 """<p>Prints the custom table modifying SQL statements """ |
409 """for one or more applications.</p>""" | 409 """for one or more applications.</p>""" |
410 )) | 410 )) |
411 self.databaseSqlCustomAct.triggered[()].connect( | 411 self.databaseSqlCustomAct.triggered.connect( |
412 self.__databaseSqlCustom) | 412 self.__databaseSqlCustom) |
413 self.actions.append(self.databaseSqlCustomAct) | 413 self.actions.append(self.databaseSqlCustomAct) |
414 | 414 |
415 self.databaseSqlDropTablesAct = E5Action( | 415 self.databaseSqlDropTablesAct = E5Action( |
416 self.trUtf8('Drop Tables'), | 416 self.tr('Drop Tables'), |
417 self.trUtf8('&Drop Tables'), | 417 self.tr('&Drop Tables'), |
418 0, 0, | 418 0, 0, |
419 self, 'django_database_sql_drop_tables') | 419 self, 'django_database_sql_drop_tables') |
420 self.databaseSqlDropTablesAct.setStatusTip(self.trUtf8( | 420 self.databaseSqlDropTablesAct.setStatusTip(self.tr( |
421 'Prints the DROP TABLE SQL statements for ' | 421 'Prints the DROP TABLE SQL statements for ' |
422 'one or more applications')) | 422 'one or more applications')) |
423 self.databaseSqlDropTablesAct.setWhatsThis(self.trUtf8( | 423 self.databaseSqlDropTablesAct.setWhatsThis(self.tr( |
424 """<b>Drop Tables</b>""" | 424 """<b>Drop Tables</b>""" |
425 """<p>Prints the DROP TABLE SQL statements """ | 425 """<p>Prints the DROP TABLE SQL statements """ |
426 """for one or more applications.</p>""" | 426 """for one or more applications.</p>""" |
427 )) | 427 )) |
428 self.databaseSqlDropTablesAct.triggered[()].connect( | 428 self.databaseSqlDropTablesAct.triggered.connect( |
429 self.__databaseSqlDropTables) | 429 self.__databaseSqlDropTables) |
430 self.actions.append(self.databaseSqlDropTablesAct) | 430 self.actions.append(self.databaseSqlDropTablesAct) |
431 | 431 |
432 self.databaseSqlFlushAct = E5Action( | 432 self.databaseSqlFlushAct = E5Action( |
433 self.trUtf8('Flush Database'), | 433 self.tr('Flush Database'), |
434 self.trUtf8('&Flush Database'), | 434 self.tr('&Flush Database'), |
435 0, 0, | 435 0, 0, |
436 self, 'django_database_sql_flush_database') | 436 self, 'django_database_sql_flush_database') |
437 self.databaseSqlFlushAct.setStatusTip(self.trUtf8( | 437 self.databaseSqlFlushAct.setStatusTip(self.tr( |
438 'Prints a list of statements to return all database tables to the' | 438 'Prints a list of statements to return all database tables to the' |
439 ' state just after their installation')) | 439 ' state just after their installation')) |
440 self.databaseSqlFlushAct.setWhatsThis(self.trUtf8( | 440 self.databaseSqlFlushAct.setWhatsThis(self.tr( |
441 """<b>Flush Database</b>""" | 441 """<b>Flush Database</b>""" |
442 """<p>Prints a list of statements to return all database tables""" | 442 """<p>Prints a list of statements to return all database tables""" |
443 """ to the state just after their installation.</p>""" | 443 """ to the state just after their installation.</p>""" |
444 )) | 444 )) |
445 self.databaseSqlFlushAct.triggered[()].connect( | 445 self.databaseSqlFlushAct.triggered.connect( |
446 self.__databaseSqlFlushDatabase) | 446 self.__databaseSqlFlushDatabase) |
447 self.actions.append(self.databaseSqlFlushAct) | 447 self.actions.append(self.databaseSqlFlushAct) |
448 | 448 |
449 self.databaseSqlResetSeqAct = E5Action( | 449 self.databaseSqlResetSeqAct = E5Action( |
450 self.trUtf8('Reset Sequences'), | 450 self.tr('Reset Sequences'), |
451 self.trUtf8('Reset &Sequences'), | 451 self.tr('Reset &Sequences'), |
452 0, 0, | 452 0, 0, |
453 self, 'django_database_sql_reset_sequences') | 453 self, 'django_database_sql_reset_sequences') |
454 self.databaseSqlResetSeqAct.setStatusTip(self.trUtf8( | 454 self.databaseSqlResetSeqAct.setStatusTip(self.tr( |
455 'Prints the SQL statements for resetting sequences for ' | 455 'Prints the SQL statements for resetting sequences for ' |
456 'one or more applications')) | 456 'one or more applications')) |
457 self.databaseSqlResetSeqAct.setWhatsThis(self.trUtf8( | 457 self.databaseSqlResetSeqAct.setWhatsThis(self.tr( |
458 """<b>Reset Sequences</b>""" | 458 """<b>Reset Sequences</b>""" |
459 """<p>Prints the SQL statements for resetting sequences for """ | 459 """<p>Prints the SQL statements for resetting sequences for """ |
460 """one or more applications.</p>""" | 460 """one or more applications.</p>""" |
461 )) | 461 )) |
462 self.databaseSqlResetSeqAct.triggered[()].connect( | 462 self.databaseSqlResetSeqAct.triggered.connect( |
463 self.__databaseSqlResetSequences) | 463 self.__databaseSqlResetSequences) |
464 self.actions.append(self.databaseSqlResetSeqAct) | 464 self.actions.append(self.databaseSqlResetSeqAct) |
465 | 465 |
466 def __initToolsActions(self): | 466 def __initToolsActions(self): |
467 """ | 467 """ |
468 Private method to define the tool actions. | 468 Private method to define the tool actions. |
469 """ | 469 """ |
470 self.diffSettingsAct = E5Action( | 470 self.diffSettingsAct = E5Action( |
471 self.trUtf8('Diff Settings'), | 471 self.tr('Diff Settings'), |
472 self.trUtf8('&Diff Settings'), | 472 self.tr('&Diff Settings'), |
473 0, 0, | 473 0, 0, |
474 self, 'django_tools_diffsettings') | 474 self, 'django_tools_diffsettings') |
475 self.diffSettingsAct.setStatusTip(self.trUtf8( | 475 self.diffSettingsAct.setStatusTip(self.tr( |
476 'Shows the modification made to the settings')) | 476 'Shows the modification made to the settings')) |
477 self.diffSettingsAct.setWhatsThis(self.trUtf8( | 477 self.diffSettingsAct.setWhatsThis(self.tr( |
478 """<b>Diff Settings</b>""" | 478 """<b>Diff Settings</b>""" |
479 """<p>Shows the modification made to the settings.</p>""" | 479 """<p>Shows the modification made to the settings.</p>""" |
480 )) | 480 )) |
481 self.diffSettingsAct.triggered[()].connect(self.__diffSettings) | 481 self.diffSettingsAct.triggered.connect(self.__diffSettings) |
482 self.actions.append(self.diffSettingsAct) | 482 self.actions.append(self.diffSettingsAct) |
483 | 483 |
484 self.cleanupAct = E5Action( | 484 self.cleanupAct = E5Action( |
485 self.trUtf8('Cleanup'), | 485 self.tr('Cleanup'), |
486 self.trUtf8('&Cleanup'), | 486 self.tr('&Cleanup'), |
487 0, 0, | 487 0, 0, |
488 self, 'django_tools_cleanup') | 488 self, 'django_tools_cleanup') |
489 self.cleanupAct.setStatusTip(self.trUtf8( | 489 self.cleanupAct.setStatusTip(self.tr( |
490 'Cleans out old data from the database')) | 490 'Cleans out old data from the database')) |
491 self.cleanupAct.setWhatsThis(self.trUtf8( | 491 self.cleanupAct.setWhatsThis(self.tr( |
492 """<b>Cleanup</b>""" | 492 """<b>Cleanup</b>""" |
493 """<p>Cleans out old data from the database.</p>""" | 493 """<p>Cleans out old data from the database.</p>""" |
494 )) | 494 )) |
495 self.cleanupAct.triggered[()].connect(self.__cleanup) | 495 self.cleanupAct.triggered.connect(self.__cleanup) |
496 self.actions.append(self.cleanupAct) | 496 self.actions.append(self.cleanupAct) |
497 | 497 |
498 self.validateAct = E5Action( | 498 self.validateAct = E5Action( |
499 self.trUtf8('Validate'), | 499 self.tr('Validate'), |
500 self.trUtf8('&Validate'), | 500 self.tr('&Validate'), |
501 0, 0, | 501 0, 0, |
502 self, 'django_tools_validate') | 502 self, 'django_tools_validate') |
503 self.validateAct.setStatusTip(self.trUtf8( | 503 self.validateAct.setStatusTip(self.tr( |
504 'Validates all installed models')) | 504 'Validates all installed models')) |
505 self.validateAct.setWhatsThis(self.trUtf8( | 505 self.validateAct.setWhatsThis(self.tr( |
506 """<b>Validate</b>""" | 506 """<b>Validate</b>""" |
507 """<p>Validates all installed models.</p>""" | 507 """<p>Validates all installed models.</p>""" |
508 )) | 508 )) |
509 self.validateAct.triggered[()].connect(self.__validate) | 509 self.validateAct.triggered.connect(self.__validate) |
510 self.actions.append(self.validateAct) | 510 self.actions.append(self.validateAct) |
511 | 511 |
512 self.runPythonShellAct = E5Action( | 512 self.runPythonShellAct = E5Action( |
513 self.trUtf8('Start Python Console'), | 513 self.tr('Start Python Console'), |
514 self.trUtf8('Start &Python Console'), | 514 self.tr('Start &Python Console'), |
515 0, 0, | 515 0, 0, |
516 self, 'django_tools_pythonconsole') | 516 self, 'django_tools_pythonconsole') |
517 self.runPythonShellAct.setStatusTip(self.trUtf8( | 517 self.runPythonShellAct.setStatusTip(self.tr( |
518 'Starts a Python interactive interpreter')) | 518 'Starts a Python interactive interpreter')) |
519 self.runPythonShellAct.setWhatsThis(self.trUtf8( | 519 self.runPythonShellAct.setWhatsThis(self.tr( |
520 """<b>Start Python Console</b>""" | 520 """<b>Start Python Console</b>""" |
521 """<p>Starts a Python interactive interpreter.</p>""" | 521 """<p>Starts a Python interactive interpreter.</p>""" |
522 )) | 522 )) |
523 self.runPythonShellAct.triggered[()].connect(self.__runPythonShell) | 523 self.runPythonShellAct.triggered.connect(self.__runPythonShell) |
524 self.actions.append(self.runPythonShellAct) | 524 self.actions.append(self.runPythonShellAct) |
525 | 525 |
526 def __initTestingActions(self): | 526 def __initTestingActions(self): |
527 """ | 527 """ |
528 Private method to define the testing actions. | 528 Private method to define the testing actions. |
529 """ | 529 """ |
530 self.dumpDataAct = E5Action( | 530 self.dumpDataAct = E5Action( |
531 self.trUtf8('Dump Data'), | 531 self.tr('Dump Data'), |
532 self.trUtf8('&Dump Data'), | 532 self.tr('&Dump Data'), |
533 0, 0, | 533 0, 0, |
534 self, 'django_tools_dumpdata') | 534 self, 'django_tools_dumpdata') |
535 self.dumpDataAct.setStatusTip(self.trUtf8( | 535 self.dumpDataAct.setStatusTip(self.tr( |
536 'Dump the database data to a fixture')) | 536 'Dump the database data to a fixture')) |
537 self.dumpDataAct.setWhatsThis(self.trUtf8( | 537 self.dumpDataAct.setWhatsThis(self.tr( |
538 """<b>Dump Data</b>""" | 538 """<b>Dump Data</b>""" |
539 """<p>Dump the database data to a fixture.</p>""" | 539 """<p>Dump the database data to a fixture.</p>""" |
540 )) | 540 )) |
541 self.dumpDataAct.triggered[()].connect(self.__dumpData) | 541 self.dumpDataAct.triggered.connect(self.__dumpData) |
542 self.actions.append(self.dumpDataAct) | 542 self.actions.append(self.dumpDataAct) |
543 | 543 |
544 self.loadDataAct = E5Action( | 544 self.loadDataAct = E5Action( |
545 self.trUtf8('Load Data'), | 545 self.tr('Load Data'), |
546 self.trUtf8('&Load Data'), | 546 self.tr('&Load Data'), |
547 0, 0, | 547 0, 0, |
548 self, 'django_tools_loaddata') | 548 self, 'django_tools_loaddata') |
549 self.loadDataAct.setStatusTip(self.trUtf8( | 549 self.loadDataAct.setStatusTip(self.tr( |
550 'Load data from fixture files')) | 550 'Load data from fixture files')) |
551 self.loadDataAct.setWhatsThis(self.trUtf8( | 551 self.loadDataAct.setWhatsThis(self.tr( |
552 """<b>Load Data</b>""" | 552 """<b>Load Data</b>""" |
553 """<p>Load data from fixture files.</p>""" | 553 """<p>Load data from fixture files.</p>""" |
554 )) | 554 )) |
555 self.loadDataAct.triggered[()].connect(self.__loadData) | 555 self.loadDataAct.triggered.connect(self.__loadData) |
556 self.actions.append(self.loadDataAct) | 556 self.actions.append(self.loadDataAct) |
557 | 557 |
558 self.runTestAct = E5Action( | 558 self.runTestAct = E5Action( |
559 self.trUtf8('Run Testsuite'), | 559 self.tr('Run Testsuite'), |
560 self.trUtf8('Run &Testsuite'), | 560 self.tr('Run &Testsuite'), |
561 0, 0, | 561 0, 0, |
562 self, 'django_tools_run_test') | 562 self, 'django_tools_run_test') |
563 self.runTestAct.setStatusTip(self.trUtf8( | 563 self.runTestAct.setStatusTip(self.tr( |
564 'Run the test suite for applications or the whole site')) | 564 'Run the test suite for applications or the whole site')) |
565 self.runTestAct.setWhatsThis(self.trUtf8( | 565 self.runTestAct.setWhatsThis(self.tr( |
566 """<b>Run Testsuite</b>""" | 566 """<b>Run Testsuite</b>""" |
567 """<p>Run the test suite for applications or the whole site.</p>""" | 567 """<p>Run the test suite for applications or the whole site.</p>""" |
568 )) | 568 )) |
569 self.runTestAct.triggered[()].connect(self.__runTestSuite) | 569 self.runTestAct.triggered.connect(self.__runTestSuite) |
570 self.actions.append(self.runTestAct) | 570 self.actions.append(self.runTestAct) |
571 | 571 |
572 self.runTestServerAct = E5Action( | 572 self.runTestServerAct = E5Action( |
573 self.trUtf8('Run Testserver'), | 573 self.tr('Run Testserver'), |
574 self.trUtf8('Run Test&server'), | 574 self.tr('Run Test&server'), |
575 0, 0, | 575 0, 0, |
576 self, 'django_tools_run_test_server') | 576 self, 'django_tools_run_test_server') |
577 self.runTestServerAct.setStatusTip(self.trUtf8( | 577 self.runTestServerAct.setStatusTip(self.tr( |
578 'Run a development server with data from a set of fixtures')) | 578 'Run a development server with data from a set of fixtures')) |
579 self.runTestServerAct.setWhatsThis(self.trUtf8( | 579 self.runTestServerAct.setWhatsThis(self.tr( |
580 """<b>Run Testserver</b>""" | 580 """<b>Run Testserver</b>""" |
581 """<p>Run a development server with data from a set of""" | 581 """<p>Run a development server with data from a set of""" |
582 """ fixtures.</p>""" | 582 """ fixtures.</p>""" |
583 )) | 583 )) |
584 self.runTestServerAct.triggered[()].connect(self.__runTestServer) | 584 self.runTestServerAct.triggered.connect(self.__runTestServer) |
585 self.actions.append(self.runTestServerAct) | 585 self.actions.append(self.runTestServerAct) |
586 | 586 |
587 def __initAuthorizationActions(self): | 587 def __initAuthorizationActions(self): |
588 """ | 588 """ |
589 Private method to define the authorization actions. | 589 Private method to define the authorization actions. |
590 """ | 590 """ |
591 self.changePasswordAct = E5Action( | 591 self.changePasswordAct = E5Action( |
592 self.trUtf8('Change Password'), | 592 self.tr('Change Password'), |
593 self.trUtf8('Change &Password'), | 593 self.tr('Change &Password'), |
594 0, 0, | 594 0, 0, |
595 self, 'django_auth_changepassword') | 595 self, 'django_auth_changepassword') |
596 self.changePasswordAct.setStatusTip(self.trUtf8( | 596 self.changePasswordAct.setStatusTip(self.tr( |
597 'Change the password of a user')) | 597 'Change the password of a user')) |
598 self.changePasswordAct.setWhatsThis(self.trUtf8( | 598 self.changePasswordAct.setWhatsThis(self.tr( |
599 """<b>Change Password</b>""" | 599 """<b>Change Password</b>""" |
600 """<p>Change the password of a user of the Django project.</p>""" | 600 """<p>Change the password of a user of the Django project.</p>""" |
601 )) | 601 )) |
602 self.changePasswordAct.triggered[()].connect(self.__changePassword) | 602 self.changePasswordAct.triggered.connect(self.__changePassword) |
603 self.actions.append(self.changePasswordAct) | 603 self.actions.append(self.changePasswordAct) |
604 | 604 |
605 self.createSuperUserAct = E5Action( | 605 self.createSuperUserAct = E5Action( |
606 self.trUtf8('Create Superuser'), | 606 self.tr('Create Superuser'), |
607 self.trUtf8('Create &Superuser'), | 607 self.tr('Create &Superuser'), |
608 0, 0, | 608 0, 0, |
609 self, 'django_auth_createsuperuser') | 609 self, 'django_auth_createsuperuser') |
610 self.createSuperUserAct.setStatusTip(self.trUtf8( | 610 self.createSuperUserAct.setStatusTip(self.tr( |
611 'Create a superuser account')) | 611 'Create a superuser account')) |
612 self.createSuperUserAct.setWhatsThis(self.trUtf8( | 612 self.createSuperUserAct.setWhatsThis(self.tr( |
613 """<b>Create Superuser</b>""" | 613 """<b>Create Superuser</b>""" |
614 """<p>Create a superuser account for the Django project.</p>""" | 614 """<p>Create a superuser account for the Django project.</p>""" |
615 )) | 615 )) |
616 self.createSuperUserAct.triggered[()].connect(self.__createSuperUser) | 616 self.createSuperUserAct.triggered.connect(self.__createSuperUser) |
617 self.actions.append(self.createSuperUserAct) | 617 self.actions.append(self.createSuperUserAct) |
618 | 618 |
619 def __initSessionActions(self): | 619 def __initSessionActions(self): |
620 """ | 620 """ |
621 Private method to define the session actions. | 621 Private method to define the session actions. |
622 """ | 622 """ |
623 self.clearSessionsAct = E5Action( | 623 self.clearSessionsAct = E5Action( |
624 self.trUtf8('Clear Sessions'), | 624 self.tr('Clear Sessions'), |
625 self.trUtf8('Clear &Sessions'), | 625 self.tr('Clear &Sessions'), |
626 0, 0, | 626 0, 0, |
627 self, 'django_session_clearsessions') | 627 self, 'django_session_clearsessions') |
628 self.clearSessionsAct.setStatusTip(self.trUtf8( | 628 self.clearSessionsAct.setStatusTip(self.tr( |
629 'Clear expired sessions')) | 629 'Clear expired sessions')) |
630 self.clearSessionsAct.setWhatsThis(self.trUtf8( | 630 self.clearSessionsAct.setWhatsThis(self.tr( |
631 """<b>Clear Sessions</b>""" | 631 """<b>Clear Sessions</b>""" |
632 """<p>Clear expired sessions of the Django project.</p>""" | 632 """<p>Clear expired sessions of the Django project.</p>""" |
633 )) | 633 )) |
634 self.clearSessionsAct.triggered[()].connect(self.__clearSessions) | 634 self.clearSessionsAct.triggered.connect(self.__clearSessions) |
635 self.actions.append(self.clearSessionsAct) | 635 self.actions.append(self.clearSessionsAct) |
636 | 636 |
637 def initMenu(self): | 637 def initMenu(self): |
638 """ | 638 """ |
639 Public slot to initialize the Django menu. | 639 Public slot to initialize the Django menu. |
640 | 640 |
641 @return the menu generated (QMenu) | 641 @return the menu generated (QMenu) |
642 """ | 642 """ |
643 self.__menus = {} # clear menus references | 643 self.__menus = {} # clear menus references |
644 | 644 |
645 menu = QMenu(self.trUtf8('D&jango'), self.__ui) | 645 menu = QMenu(self.tr('D&jango'), self.__ui) |
646 menu.setTearOffEnabled(True) | 646 menu.setTearOffEnabled(True) |
647 | 647 |
648 menu.addAction(self.selectSiteAct) | 648 menu.addAction(self.selectSiteAct) |
649 menu.addSeparator() | 649 menu.addSeparator() |
650 menu.addAction(self.runServerAct) | 650 menu.addAction(self.runServerAct) |
678 """ | 678 """ |
679 Private slot to initialize the database menu. | 679 Private slot to initialize the database menu. |
680 | 680 |
681 @return the menu generated (QMenu) | 681 @return the menu generated (QMenu) |
682 """ | 682 """ |
683 menu = QMenu(self.trUtf8("&Database"), self.__ui) | 683 menu = QMenu(self.tr("&Database"), self.__ui) |
684 menu.setTearOffEnabled(True) | 684 menu.setTearOffEnabled(True) |
685 | 685 |
686 menu.addAction(self.syncDatabaseAct) | 686 menu.addAction(self.syncDatabaseAct) |
687 menu.addSeparator() | 687 menu.addSeparator() |
688 menu.addAction(self.inspectDatabaseAct) | 688 menu.addAction(self.inspectDatabaseAct) |
701 """ | 701 """ |
702 Private slot to initialize the database SQL submenu. | 702 Private slot to initialize the database SQL submenu. |
703 | 703 |
704 @return the menu generated (QMenu) | 704 @return the menu generated (QMenu) |
705 """ | 705 """ |
706 menu = QMenu(self.trUtf8("Show &SQL"), self.__ui) | 706 menu = QMenu(self.tr("Show &SQL"), self.__ui) |
707 menu.setTearOffEnabled(True) | 707 menu.setTearOffEnabled(True) |
708 | 708 |
709 menu.addAction(self.databaseSqlCreateTablesAct) | 709 menu.addAction(self.databaseSqlCreateTablesAct) |
710 menu.addAction(self.databaseSqlCreateIndexesAct) | 710 menu.addAction(self.databaseSqlCreateIndexesAct) |
711 menu.addAction(self.databaseSqlCreateEverythingAct) | 711 menu.addAction(self.databaseSqlCreateEverythingAct) |
725 """ | 725 """ |
726 Private slot to initialize the tools menu. | 726 Private slot to initialize the tools menu. |
727 | 727 |
728 @return the menu generated (QMenu) | 728 @return the menu generated (QMenu) |
729 """ | 729 """ |
730 menu = QMenu(self.trUtf8("&Tools"), self.__ui) | 730 menu = QMenu(self.tr("&Tools"), self.__ui) |
731 menu.setTearOffEnabled(True) | 731 menu.setTearOffEnabled(True) |
732 | 732 |
733 menu.addAction(self.diffSettingsAct) | 733 menu.addAction(self.diffSettingsAct) |
734 menu.addAction(self.cleanupAct) | 734 menu.addAction(self.cleanupAct) |
735 menu.addAction(self.validateAct) | 735 menu.addAction(self.validateAct) |
744 """ | 744 """ |
745 Private slot to initialize the testing menu. | 745 Private slot to initialize the testing menu. |
746 | 746 |
747 @return the menu generated (QMenu) | 747 @return the menu generated (QMenu) |
748 """ | 748 """ |
749 menu = QMenu(self.trUtf8("T&esting"), self.__ui) | 749 menu = QMenu(self.tr("T&esting"), self.__ui) |
750 menu.setTearOffEnabled(True) | 750 menu.setTearOffEnabled(True) |
751 | 751 |
752 menu.addAction(self.dumpDataAct) | 752 menu.addAction(self.dumpDataAct) |
753 menu.addAction(self.loadDataAct) | 753 menu.addAction(self.loadDataAct) |
754 menu.addSeparator() | 754 menu.addSeparator() |
763 """ | 763 """ |
764 Private slot to initialize the authorization menu. | 764 Private slot to initialize the authorization menu. |
765 | 765 |
766 @return the menu generated (QMenu) | 766 @return the menu generated (QMenu) |
767 """ | 767 """ |
768 menu = QMenu(self.trUtf8("&Authorization"), self.__ui) | 768 menu = QMenu(self.tr("&Authorization"), self.__ui) |
769 menu.setTearOffEnabled(True) | 769 menu.setTearOffEnabled(True) |
770 | 770 |
771 menu.addAction(self.changePasswordAct) | 771 menu.addAction(self.changePasswordAct) |
772 menu.addAction(self.createSuperUserAct) | 772 menu.addAction(self.createSuperUserAct) |
773 | 773 |
779 """ | 779 """ |
780 Private slot to initialize the authorization menu. | 780 Private slot to initialize the authorization menu. |
781 | 781 |
782 @return the menu generated (QMenu) | 782 @return the menu generated (QMenu) |
783 """ | 783 """ |
784 menu = QMenu(self.trUtf8("&Session"), self.__ui) | 784 menu = QMenu(self.tr("&Session"), self.__ui) |
785 menu.setTearOffEnabled(True) | 785 menu.setTearOffEnabled(True) |
786 | 786 |
787 menu.addAction(self.clearSessionsAct) | 787 menu.addAction(self.clearSessionsAct) |
788 | 788 |
789 self.__menus["session"] = menu | 789 self.__menus["session"] = menu |
820 Public method to register the open hook to open a translations file | 820 Public method to register the open hook to open a translations file |
821 in a translations editor. | 821 in a translations editor. |
822 """ | 822 """ |
823 if self.__hooksInstalled: | 823 if self.__hooksInstalled: |
824 editor = self.__plugin.getPreferences("TranslationsEditor") | 824 editor = self.__plugin.getPreferences("TranslationsEditor") |
825 try: | 825 if editor: |
826 if editor: | 826 self.__translationsBrowser.addHookMethodAndMenuEntry( |
827 self.__translationsBrowser.addHookMethodAndMenuEntry( | 827 "open", |
828 "open", | 828 self.openPOEditor, |
829 self.openPOEditor, | 829 self.tr("Open with {0}").format( |
830 self.trUtf8("Open with {0}").format( | 830 os.path.basename(editor))) |
831 os.path.basename(editor))) | 831 else: |
832 else: | 832 self.__translationsBrowser.removeHookMethod("open") |
833 self.__translationsBrowser.removeHookMethod("open") | |
834 except KeyError: | |
835 # ignore for older eric5 versions | |
836 pass | |
837 | 833 |
838 def projectOpenedHooks(self): | 834 def projectOpenedHooks(self): |
839 """ | 835 """ |
840 Public method to add our hook methods. | 836 Public method to add our hook methods. |
841 """ | 837 """ |
842 if self.__e5project.getProjectType() == "Django": | 838 if self.__e5project.getProjectType() == "Django": |
843 self.__formsBrowser = \ | 839 self.__formsBrowser = \ |
844 e5App().getObject("ProjectBrowser").getProjectBrowser("forms") | 840 e5App().getObject("ProjectBrowser").getProjectBrowser("forms") |
845 self.__formsBrowser.addHookMethodAndMenuEntry( | 841 self.__formsBrowser.addHookMethodAndMenuEntry( |
846 "newForm", | 842 "newForm", |
847 self.newForm, self.trUtf8("New template...")) | 843 self.newForm, self.tr("New template...")) |
848 | 844 |
849 self.__e5project.projectLanguageAddedByCode.connect( | 845 self.__e5project.projectLanguageAddedByCode.connect( |
850 self.__projectLanguageAdded) | 846 self.__projectLanguageAdded) |
851 self.__translationsBrowser = \ | 847 self.__translationsBrowser = \ |
852 e5App().getObject("ProjectBrowser")\ | 848 e5App().getObject("ProjectBrowser")\ |
853 .getProjectBrowser("translations") | 849 .getProjectBrowser("translations") |
854 self.__translationsBrowser.addHookMethodAndMenuEntry( | 850 self.__translationsBrowser.addHookMethodAndMenuEntry( |
855 "generateAll", | 851 "generateAll", |
856 self.updateCatalogs, self.trUtf8("Update all catalogs")) | 852 self.updateCatalogs, self.tr("Update all catalogs")) |
857 self.__translationsBrowser.addHookMethodAndMenuEntry( | 853 self.__translationsBrowser.addHookMethodAndMenuEntry( |
858 "generateSelected", | 854 "generateSelected", |
859 self.updateSelectedCatalogs, | 855 self.updateSelectedCatalogs, |
860 self.trUtf8("Update selected catalogs")) | 856 self.tr("Update selected catalogs")) |
861 self.__translationsBrowser.addHookMethodAndMenuEntry( | 857 self.__translationsBrowser.addHookMethodAndMenuEntry( |
862 "generateAllWithObsolete", self.updateCatalogsWithObsolete, | 858 "generateAllWithObsolete", self.updateCatalogsWithObsolete, |
863 self.trUtf8("Update all catalogs (with obsolete)")) | 859 self.tr("Update all catalogs (with obsolete)")) |
864 self.__translationsBrowser.addHookMethodAndMenuEntry( | 860 self.__translationsBrowser.addHookMethodAndMenuEntry( |
865 "generateSelectedWithObsolete", | 861 "generateSelectedWithObsolete", |
866 self.updateSelectedCatalogsWithObsolete, | 862 self.updateSelectedCatalogsWithObsolete, |
867 self.trUtf8("Update selected catalogs (with obsolete)")) | 863 self.tr("Update selected catalogs (with obsolete)")) |
868 self.__translationsBrowser.addHookMethodAndMenuEntry( | 864 self.__translationsBrowser.addHookMethodAndMenuEntry( |
869 "releaseAll", | 865 "releaseAll", |
870 self.compileCatalogs, self.trUtf8("Compile all catalogs")) | 866 self.compileCatalogs, self.tr("Compile all catalogs")) |
871 self.__translationsBrowser.addHookMethodAndMenuEntry( | 867 self.__translationsBrowser.addHookMethodAndMenuEntry( |
872 "releaseSelected", | 868 "releaseSelected", |
873 self.compileSelectedCatalogs, | 869 self.compileSelectedCatalogs, |
874 self.trUtf8("Compile selected catalogs")) | 870 self.tr("Compile selected catalogs")) |
875 | 871 |
876 self.__hooksInstalled = True | 872 self.__hooksInstalled = True |
877 | 873 |
878 self.registerOpenHook() | 874 self.registerOpenHook() |
879 | 875 |
897 "generateSelectedWithObsolete") | 893 "generateSelectedWithObsolete") |
898 self.__translationsBrowser.removeHookMethod( | 894 self.__translationsBrowser.removeHookMethod( |
899 "releaseAll") | 895 "releaseAll") |
900 self.__translationsBrowser.removeHookMethod( | 896 self.__translationsBrowser.removeHookMethod( |
901 "releaseSelected") | 897 "releaseSelected") |
902 try: | 898 self.__translationsBrowser.removeHookMethod("open") |
903 self.__translationsBrowser.removeHookMethod("open") | |
904 except KeyError: | |
905 # ignore for older eric5 versions | |
906 pass | |
907 self.__translationsBrowser = None | 899 self.__translationsBrowser = None |
908 | 900 |
909 self.__hooksInstalled = False | 901 self.__hooksInstalled = False |
910 | 902 |
911 def newForm(self, path): | 903 def newForm(self, path): |
914 | 906 |
915 @param path full directory path for the new form file (string) | 907 @param path full directory path for the new form file (string) |
916 """ | 908 """ |
917 fname, selectedFilter = E5FileDialog.getSaveFileNameAndFilter( | 909 fname, selectedFilter = E5FileDialog.getSaveFileNameAndFilter( |
918 self.__ui, | 910 self.__ui, |
919 self.trUtf8("New Form"), | 911 self.tr("New Form"), |
920 path, | 912 path, |
921 filter, | 913 filter, |
922 None, | 914 None, |
923 E5FileDialog.Options(E5FileDialog.DontConfirmOverwrite)) | 915 E5FileDialog.Options(E5FileDialog.DontConfirmOverwrite)) |
924 | 916 |
933 fname += ex | 925 fname += ex |
934 | 926 |
935 if os.path.exists(fname): | 927 if os.path.exists(fname): |
936 res = E5MessageBox.yesNo( | 928 res = E5MessageBox.yesNo( |
937 self.__ui, | 929 self.__ui, |
938 self.trUtf8("New Form"), | 930 self.tr("New Form"), |
939 self.trUtf8("The file already exists! Overwrite it?"), | 931 self.tr("The file already exists! Overwrite it?"), |
940 icon=E5MessageBox.Warning) | 932 icon=E5MessageBox.Warning) |
941 | 933 |
942 if not res: | 934 if not res: |
943 # user selected to not overwrite | 935 # user selected to not overwrite |
944 return | 936 return |
966 f.write('</html>\n') | 958 f.write('</html>\n') |
967 f.close() | 959 f.close() |
968 except (IOError, OSError) as e: | 960 except (IOError, OSError) as e: |
969 E5MessageBox.critical( | 961 E5MessageBox.critical( |
970 self.__ui, | 962 self.__ui, |
971 self.trUtf8("New Form"), | 963 self.tr("New Form"), |
972 self.trUtf8("<p>The new form file <b>{0}</b> could not be" | 964 self.tr("<p>The new form file <b>{0}</b> could not be" |
973 " created.<br> Problem: {1}</p>") | 965 " created.<br> Problem: {1}</p>") |
974 .format(fname, str(e))) | 966 .format(fname, str(e))) |
975 return | 967 return |
976 | 968 |
977 self.__e5project.appendFile(fname) | 969 self.__e5project.appendFile(fname) |
978 self.__formsBrowser.sourceFile.emit(fname) | 970 self.__formsBrowser.sourceFile.emit(fname) |
1163 | 1155 |
1164 return cmd | 1156 return cmd |
1165 | 1157 |
1166 def __getPythonExecutable(self): | 1158 def __getPythonExecutable(self): |
1167 """ | 1159 """ |
1168 Public method to build the Python command. | 1160 Private method to build the Python command. |
1169 | 1161 |
1170 @return python command (string) | 1162 @return python command (string) |
1171 """ | 1163 """ |
1172 language = self.__e5project.getProjectLanguage() | 1164 language = self.__e5project.getProjectLanguage() |
1173 pythonExe = "python" | 1165 pythonExe = "python" |
1202 version = self.getDjangoVersion() | 1194 version = self.getDjangoVersion() |
1203 url = "http://www.djangoproject.com" | 1195 url = "http://www.djangoproject.com" |
1204 | 1196 |
1205 msgBox = E5MessageBox.E5MessageBox( | 1197 msgBox = E5MessageBox.E5MessageBox( |
1206 E5MessageBox.Question, | 1198 E5MessageBox.Question, |
1207 self.trUtf8("About Django"), | 1199 self.tr("About Django"), |
1208 self.trUtf8( | 1200 self.tr( |
1209 "<p>Django is a high-level Python Web framework that" | 1201 "<p>Django is a high-level Python Web framework that" |
1210 " encourages rapid " | 1202 " encourages rapid " |
1211 "development and clean, pragmatic design.</p>" | 1203 "development and clean, pragmatic design.</p>" |
1212 "<p><table>" | 1204 "<p><table>" |
1213 "<tr><td>Version:</td><td>{0}</td></tr>" | 1205 "<tr><td>Version:</td><td>{0}</td></tr>" |
1254 | 1246 |
1255 @return list of application names (list of strings) | 1247 @return list of application names (list of strings) |
1256 """ | 1248 """ |
1257 applStr, ok = QInputDialog.getItem( | 1249 applStr, ok = QInputDialog.getItem( |
1258 self.__ui, | 1250 self.__ui, |
1259 self.trUtf8("Select Applications"), | 1251 self.tr("Select Applications"), |
1260 self.trUtf8("Enter the list of applications separated by spaces."), | 1252 self.tr("Enter the list of applications separated by spaces."), |
1261 self.getRecentApplications(), | 1253 self.getRecentApplications(), |
1262 0, True) | 1254 0, True) |
1263 if ok and applStr != "": | 1255 if ok and applStr != "": |
1264 self.setMostRecentApplication(applStr) | 1256 self.setMostRecentApplication(applStr) |
1265 return applStr.split() | 1257 return applStr.split() |
1309 self.__recentApplications = self.recent[:maxRecentApps] | 1301 self.__recentApplications = self.recent[:maxRecentApps] |
1310 self.__saveRecentApplications() | 1302 self.__saveRecentApplications() |
1311 | 1303 |
1312 def getProjectPath(self): | 1304 def getProjectPath(self): |
1313 """ | 1305 """ |
1314 Public method to get the path of the eric5 project. | 1306 Public method to get the path of the eric6 project. |
1315 | 1307 |
1316 @return path of the eric5 project (string) | 1308 @return path of the eric6 project (string) |
1317 """ | 1309 """ |
1318 return self.__e5project.getProjectPath() | 1310 return self.__e5project.getProjectPath() |
1319 | 1311 |
1320 def __showHelpIndex(self): | 1312 def __showHelpIndex(self): |
1321 """ | 1313 """ |
1346 def startProjectOrApplication(self): | 1338 def startProjectOrApplication(self): |
1347 """ | 1339 """ |
1348 Public slot to start a new Django project or application. | 1340 Public slot to start a new Django project or application. |
1349 """ | 1341 """ |
1350 if self.__e5project.getProjectType() == "Django": | 1342 if self.__e5project.getProjectType() == "Django": |
1351 projectStr = self.trUtf8("Project") | 1343 projectStr = self.tr("Project") |
1352 applStr = self.trUtf8("Application") | 1344 applStr = self.tr("Application") |
1353 selections = ["", projectStr, applStr] | 1345 selections = ["", projectStr, applStr] |
1354 selection, ok = QInputDialog.getItem( | 1346 selection, ok = QInputDialog.getItem( |
1355 self.__ui, | 1347 self.__ui, |
1356 self.trUtf8("Start Django"), | 1348 self.tr("Start Django"), |
1357 self.trUtf8("Select if this project should be a " | 1349 self.tr("Select if this project should be a " |
1358 "Django Project or Application.<br />" | 1350 "Django Project or Application.<br />" |
1359 "Select the empty entry for none."), | 1351 "Select the empty entry for none."), |
1360 selections, | 1352 selections, |
1361 0, False) | 1353 0, False) |
1362 if ok and bool(selection): | 1354 if ok and bool(selection): |
1363 if selection == projectStr: | 1355 if selection == projectStr: |
1364 path, projectName = os.path.split( | 1356 path, projectName = os.path.split( |
1376 @param projectName name of the new project (string) | 1368 @param projectName name of the new project (string) |
1377 @param path the directory where the project should be created | 1369 @param path the directory where the project should be created |
1378 (string) | 1370 (string) |
1379 @return flag indicating a successful creation (boolean) | 1371 @return flag indicating a successful creation (boolean) |
1380 """ | 1372 """ |
1381 title = self.trUtf8("Start Django Project") | 1373 title = self.tr("Start Django Project") |
1382 | 1374 |
1383 args = [] | 1375 args = [] |
1384 if Utilities.isWindowsPlatform(): | 1376 if Utilities.isWindowsPlatform(): |
1385 args.append(self.__getPythonExecutable()) | 1377 args.append(self.__getPythonExecutable()) |
1386 args.append(self.__getDjangoAdminCommand()) | 1378 args.append(self.__getDjangoAdminCommand()) |
1390 args.append(cmd) | 1382 args.append(cmd) |
1391 else: | 1383 else: |
1392 E5MessageBox.critical( | 1384 E5MessageBox.critical( |
1393 self.__ui, | 1385 self.__ui, |
1394 title, | 1386 title, |
1395 self.trUtf8("""<p>The <b>django-admin.py</b> script is""" | 1387 self.tr("""<p>The <b>django-admin.py</b> script is""" |
1396 """ not in the path. Aborting...</p>""")) | 1388 """ not in the path. Aborting...</p>""")) |
1397 return | 1389 return |
1398 | 1390 |
1399 args.append("startproject") | 1391 args.append("startproject") |
1400 args.append(projectName) | 1392 args.append(projectName) |
1401 | 1393 |
1402 dia = DjangoDialog( | 1394 dia = DjangoDialog( |
1403 title, | 1395 title, |
1404 msgSuccess=self.trUtf8("Django project created successfully.")) | 1396 msgSuccess=self.tr("Django project created successfully.")) |
1405 res = dia.startProcess(args, path) | 1397 res = dia.startProcess(args, path) |
1406 if res: | 1398 if res: |
1407 dia.exec_() | 1399 dia.exec_() |
1408 | 1400 |
1409 # create the base directory for translations | 1401 # create the base directory for translations |
1423 """ | 1415 """ |
1424 Private slot to start a new Django project. | 1416 Private slot to start a new Django project. |
1425 """ | 1417 """ |
1426 projectName, ok = QInputDialog.getText( | 1418 projectName, ok = QInputDialog.getText( |
1427 self.__ui, | 1419 self.__ui, |
1428 self.trUtf8("Start Django Project"), | 1420 self.tr("Start Django Project"), |
1429 self.trUtf8("Enter the name of the new Django project."), | 1421 self.tr("Enter the name of the new Django project."), |
1430 QLineEdit.Normal) | 1422 QLineEdit.Normal) |
1431 if ok and projectName != "": | 1423 if ok and projectName != "": |
1432 res = self.__createProject(projectName, | 1424 res = self.__createProject(projectName, |
1433 self.__e5project.getProjectPath()) | 1425 self.__e5project.getProjectPath()) |
1434 if res: | 1426 if res: |
1449 (string) | 1441 (string) |
1450 @param isGlobal flag indicating a standalone Django application | 1442 @param isGlobal flag indicating a standalone Django application |
1451 (boolean) | 1443 (boolean) |
1452 @return flag indicating a successful creation (boolean) | 1444 @return flag indicating a successful creation (boolean) |
1453 """ | 1445 """ |
1454 title = self.trUtf8("Start Django Application") | 1446 title = self.tr("Start Django Application") |
1455 | 1447 |
1456 args = [] | 1448 args = [] |
1457 if isGlobal: | 1449 if isGlobal: |
1458 if Utilities.isWindowsPlatform(): | 1450 if Utilities.isWindowsPlatform(): |
1459 args.append(self.__getPythonExecutable()) | 1451 args.append(self.__getPythonExecutable()) |
1464 args.append(cmd) | 1456 args.append(cmd) |
1465 else: | 1457 else: |
1466 E5MessageBox.critical( | 1458 E5MessageBox.critical( |
1467 self.__ui, | 1459 self.__ui, |
1468 title, | 1460 title, |
1469 self.trUtf8("""<p>The <b>django-admin.py</b> script""" | 1461 self.tr("""<p>The <b>django-admin.py</b> script""" |
1470 """ is not in the path.""" | 1462 """ is not in the path.""" |
1471 """ Aborting...</p>""")) | 1463 """ Aborting...</p>""")) |
1472 return | 1464 return |
1473 else: | 1465 else: |
1474 args.append(self.__getPythonExecutable()) | 1466 args.append(self.__getPythonExecutable()) |
1475 args.append("manage.py") | 1467 args.append("manage.py") |
1476 try: | 1468 try: |
1480 args.append("startapp") | 1472 args.append("startapp") |
1481 args.append(applName) | 1473 args.append(applName) |
1482 | 1474 |
1483 dia = DjangoDialog( | 1475 dia = DjangoDialog( |
1484 title, | 1476 title, |
1485 msgSuccess=self.trUtf8("Django application created successfully.")) | 1477 msgSuccess=self.tr("Django application created successfully.")) |
1486 res = dia.startProcess(args, path) | 1478 res = dia.startProcess(args, path) |
1487 if res: | 1479 if res: |
1488 dia.exec_() | 1480 dia.exec_() |
1489 return res | 1481 return res |
1490 | 1482 |
1492 """ | 1484 """ |
1493 Private slot to start a new global Django application. | 1485 Private slot to start a new global Django application. |
1494 """ | 1486 """ |
1495 applName, ok = QInputDialog.getText( | 1487 applName, ok = QInputDialog.getText( |
1496 self.__ui, | 1488 self.__ui, |
1497 self.trUtf8("Start Global Django Application"), | 1489 self.tr("Start Global Django Application"), |
1498 self.trUtf8("Enter the name of the new global Django" | 1490 self.tr("Enter the name of the new global Django" |
1499 " application."), | 1491 " application."), |
1500 QLineEdit.Normal) | 1492 QLineEdit.Normal) |
1501 if ok and applName != "": | 1493 if ok and applName != "": |
1502 res = self.__createApplication(applName, | 1494 res = self.__createApplication(applName, |
1503 self.__e5project.getProjectPath()) | 1495 self.__e5project.getProjectPath()) |
1504 if res: | 1496 if res: |
1514 """ | 1506 """ |
1515 Private slot to start a new local Django application. | 1507 Private slot to start a new local Django application. |
1516 """ | 1508 """ |
1517 applName, ok = QInputDialog.getText( | 1509 applName, ok = QInputDialog.getText( |
1518 self.__ui, | 1510 self.__ui, |
1519 self.trUtf8("Start Local Django Application"), | 1511 self.tr("Start Local Django Application"), |
1520 self.trUtf8("Enter the name of the new local Django application."), | 1512 self.tr("Enter the name of the new local Django application."), |
1521 QLineEdit.Normal) | 1513 QLineEdit.Normal) |
1522 if ok and applName != "": | 1514 if ok and applName != "": |
1523 res = self.__createApplication(applName, "", False) | 1515 res = self.__createApplication(applName, "", False) |
1524 if res: | 1516 if res: |
1525 try: | 1517 try: |
1563 cur = 0 | 1555 cur = 0 |
1564 else: | 1556 else: |
1565 cur = 0 | 1557 cur = 0 |
1566 site, ok = QInputDialog.getItem( | 1558 site, ok = QInputDialog.getItem( |
1567 self.__ui, | 1559 self.__ui, |
1568 self.trUtf8("Select Project"), | 1560 self.tr("Select Project"), |
1569 self.trUtf8("Select the Django project to work with."), | 1561 self.tr("Select the Django project to work with."), |
1570 sites, | 1562 sites, |
1571 cur, False) | 1563 cur, False) |
1572 if not ok: | 1564 if not ok: |
1573 site = None | 1565 site = None |
1574 self.__setCurrentSite(site) | 1566 self.__setCurrentSite(site) |
1595 | 1587 |
1596 @param site name of the site (string) | 1588 @param site name of the site (string) |
1597 """ | 1589 """ |
1598 self.__currentSite = site | 1590 self.__currentSite = site |
1599 if self.__currentSite is None: | 1591 if self.__currentSite is None: |
1600 curSite = self.trUtf8("None") | 1592 curSite = self.tr("None") |
1601 elif self.__currentSite == "": | 1593 elif self.__currentSite == "": |
1602 curSite = self.trUtf8("Project") | 1594 curSite = self.tr("Project") |
1603 else: | 1595 else: |
1604 curSite = self.__currentSite | 1596 curSite = self.__currentSite |
1605 self.selectSiteAct.setText( | 1597 self.selectSiteAct.setText( |
1606 self.trUtf8('&Current Django project ({0})').format(curSite)) | 1598 self.tr('&Current Django project ({0})').format(curSite)) |
1607 | 1599 |
1608 if self.__currentSite is None: | 1600 if self.__currentSite is None: |
1609 self.__e5project.pdata["TRANSLATIONPATTERN"] = [] | 1601 self.__e5project.pdata["TRANSLATIONPATTERN"] = [] |
1610 else: | 1602 else: |
1611 self.__e5project.pdata["TRANSLATIONPATTERN"] = [ | 1603 self.__e5project.pdata["TRANSLATIONPATTERN"] = [ |
1665 self.__serverProc.start(args[0], args[1:]) | 1657 self.__serverProc.start(args[0], args[1:]) |
1666 serverProcStarted = self.__serverProc.waitForStarted() | 1658 serverProcStarted = self.__serverProc.waitForStarted() |
1667 if not serverProcStarted: | 1659 if not serverProcStarted: |
1668 E5MessageBox.critical( | 1660 E5MessageBox.critical( |
1669 None, | 1661 None, |
1670 self.trUtf8('Process Generation Error'), | 1662 self.tr('Process Generation Error'), |
1671 self.trUtf8('The Django server could not be started.')) | 1663 self.tr('The Django server could not be started.')) |
1672 except DjangoNoSiteSelectedException: | 1664 except DjangoNoSiteSelectedException: |
1673 pass | 1665 pass |
1674 | 1666 |
1675 def __serverProcFinished(self): | 1667 def __serverProcFinished(self): |
1676 """ | 1668 """ |
1710 url = QUrl("http://{0}:{1}".format(addr, port)) | 1702 url = QUrl("http://{0}:{1}".format(addr, port)) |
1711 res = QDesktopServices.openUrl(url) | 1703 res = QDesktopServices.openUrl(url) |
1712 if not res: | 1704 if not res: |
1713 E5MessageBox.critical( | 1705 E5MessageBox.critical( |
1714 None, | 1706 None, |
1715 self.trUtf8('Run Web-Browser'), | 1707 self.tr('Run Web-Browser'), |
1716 self.trUtf8('Could not start the web-browser for the' | 1708 self.tr('Could not start the web-browser for the' |
1717 ' url "{0}".').format(url.toString())) | 1709 ' url "{0}".').format(url.toString())) |
1718 | 1710 |
1719 ################################################################## | 1711 ################################################################## |
1720 ## slots below implement database related functions | 1712 ## slots below implement database related functions |
1721 ################################################################## | 1713 ################################################################## |
1722 | 1714 |
1736 wd = self.__sitePath() | 1728 wd = self.__sitePath() |
1737 started, pid = QProcess.startDetached(args[0], args[1:], wd) | 1729 started, pid = QProcess.startDetached(args[0], args[1:], wd) |
1738 if not started: | 1730 if not started: |
1739 E5MessageBox.critical( | 1731 E5MessageBox.critical( |
1740 None, | 1732 None, |
1741 self.trUtf8('Process Generation Error'), | 1733 self.tr('Process Generation Error'), |
1742 self.trUtf8('The Django process could not be' | 1734 self.tr('The Django process could not be' |
1743 ' started.')) | 1735 ' started.')) |
1744 except DjangoNoSiteSelectedException: | 1736 except DjangoNoSiteSelectedException: |
1745 pass | 1737 pass |
1746 | 1738 |
1747 def __databaseInspect(self): | 1739 def __databaseInspect(self): |
1748 """ | 1740 """ |
1749 Private slot to introspect the database and output a Django model | 1741 Private slot to introspect the database and output a Django model |
1750 module. | 1742 module. |
1751 """ | 1743 """ |
1752 title = self.trUtf8("Introspect Database") | 1744 title = self.tr("Introspect Database") |
1753 | 1745 |
1754 args = [] | 1746 args = [] |
1755 args.append(self.__getPythonExecutable()) | 1747 args.append(self.__getPythonExecutable()) |
1756 args.append("manage.py") | 1748 args.append("manage.py") |
1757 args.append("inspectdb") | 1749 args.append("inspectdb") |
1774 try: | 1766 try: |
1775 path = self.__sitePath() | 1767 path = self.__sitePath() |
1776 except DjangoNoSiteSelectedException: | 1768 except DjangoNoSiteSelectedException: |
1777 return | 1769 return |
1778 | 1770 |
1779 title = self.trUtf8("Flush Database") | 1771 title = self.tr("Flush Database") |
1780 | 1772 |
1781 res = E5MessageBox.yesNo( | 1773 res = E5MessageBox.yesNo( |
1782 self.__ui, | 1774 self.__ui, |
1783 title, | 1775 title, |
1784 self.trUtf8("""Flushing the database will destroy all data.""" | 1776 self.tr("""Flushing the database will destroy all data.""" |
1785 """ Are you sure?""")) | 1777 """ Are you sure?""")) |
1786 if res: | 1778 if res: |
1787 args = [] | 1779 args = [] |
1788 args.append(self.__getPythonExecutable()) | 1780 args.append(self.__getPythonExecutable()) |
1789 args.append("manage.py") | 1781 args.append("manage.py") |
1790 args.append("flush") | 1782 args.append("flush") |
1791 args.append("--noinput") | 1783 args.append("--noinput") |
1792 | 1784 |
1793 dia = DjangoDialog( | 1785 dia = DjangoDialog( |
1794 title, | 1786 title, |
1795 msgSuccess=self.trUtf8("Database tables flushed" | 1787 msgSuccess=self.tr("Database tables flushed" |
1796 " successfully.")) | 1788 " successfully.")) |
1797 res = dia.startProcess(args, path) | 1789 res = dia.startProcess(args, path) |
1798 if res: | 1790 if res: |
1799 dia.exec_() | 1791 dia.exec_() |
1800 | 1792 |
1801 def __runDatabaseClient(self): | 1793 def __runDatabaseClient(self): |
1814 wd = self.__sitePath() | 1806 wd = self.__sitePath() |
1815 started, pid = QProcess.startDetached(args[0], args[1:], wd) | 1807 started, pid = QProcess.startDetached(args[0], args[1:], wd) |
1816 if not started: | 1808 if not started: |
1817 E5MessageBox.critical( | 1809 E5MessageBox.critical( |
1818 None, | 1810 None, |
1819 self.trUtf8('Process Generation Error'), | 1811 self.tr('Process Generation Error'), |
1820 self.trUtf8('The Django process could not be' | 1812 self.tr('The Django process could not be started.')) |
1821 ' started.')) | |
1822 except DjangoNoSiteSelectedException: | 1813 except DjangoNoSiteSelectedException: |
1823 pass | 1814 pass |
1824 | 1815 |
1825 ####################################################################### | 1816 ####################################################################### |
1826 ## slots below implement database functions outputting SQL statements | 1817 ## slots below implement database functions outputting SQL statements |
1851 args.append(self.__getPythonExecutable()) | 1842 args.append(self.__getPythonExecutable()) |
1852 args.append("manage.py") | 1843 args.append("manage.py") |
1853 args.append(command) | 1844 args.append(command) |
1854 args += apps | 1845 args += apps |
1855 | 1846 |
1856 fileFilter = self.trUtf8("SQL Files (*.sql)") | 1847 fileFilter = self.tr("SQL Files (*.sql)") |
1857 | 1848 |
1858 dia = DjangoDialog(title, fixed=True, linewrap=False, | 1849 dia = DjangoDialog(title, fixed=True, linewrap=False, |
1859 saveFilters=fileFilter) | 1850 saveFilters=fileFilter) |
1860 res = dia.startProcess(args, path, False) | 1851 res = dia.startProcess(args, path, False) |
1861 if res: | 1852 if res: |
1864 def __databaseSqlCreateTables(self): | 1855 def __databaseSqlCreateTables(self): |
1865 """ | 1856 """ |
1866 Private slot to print the CREATE TABLE SQL statements for one | 1857 Private slot to print the CREATE TABLE SQL statements for one |
1867 or more applications. | 1858 or more applications. |
1868 """ | 1859 """ |
1869 self.__sqlCommand(self.trUtf8("Create Tables"), "sql") | 1860 self.__sqlCommand(self.tr("Create Tables"), "sql") |
1870 | 1861 |
1871 def __databaseSqlCreateIndexes(self): | 1862 def __databaseSqlCreateIndexes(self): |
1872 """ | 1863 """ |
1873 Private slot to print the CREATE INDEX SQL statements for one | 1864 Private slot to print the CREATE INDEX SQL statements for one |
1874 or more applications. | 1865 or more applications. |
1875 """ | 1866 """ |
1876 self.__sqlCommand(self.trUtf8("Create Indexes"), "sqlindexes") | 1867 self.__sqlCommand(self.tr("Create Indexes"), "sqlindexes") |
1877 | 1868 |
1878 def __databaseSqlCreateEverything(self): | 1869 def __databaseSqlCreateEverything(self): |
1879 """ | 1870 """ |
1880 Private slot to print the CREATE TABLE, custom SQL and | 1871 Private slot to print the CREATE TABLE, custom SQL and |
1881 CREATE INDEX SQL statements for one or more applications. | 1872 CREATE INDEX SQL statements for one or more applications. |
1882 """ | 1873 """ |
1883 self.__sqlCommand(self.trUtf8("Create Everything"), "sqlall") | 1874 self.__sqlCommand(self.tr("Create Everything"), "sqlall") |
1884 | 1875 |
1885 def __databaseSqlCustom(self): | 1876 def __databaseSqlCustom(self): |
1886 """ | 1877 """ |
1887 Private slot to print the custom table modifying SQL statements | 1878 Private slot to print the custom table modifying SQL statements |
1888 for one or more applications. | 1879 for one or more applications. |
1889 """ | 1880 """ |
1890 self.__sqlCommand(self.trUtf8("Custom Statements"), "sqlcustom") | 1881 self.__sqlCommand(self.tr("Custom Statements"), "sqlcustom") |
1891 | 1882 |
1892 def __databaseSqlDropTables(self): | 1883 def __databaseSqlDropTables(self): |
1893 """ | 1884 """ |
1894 Private slot to print the DROP TABLE SQL statements for one or | 1885 Private slot to print the DROP TABLE SQL statements for one or |
1895 more applications. | 1886 more applications. |
1896 """ | 1887 """ |
1897 self.__sqlCommand(self.trUtf8("Drop Tables"), "sqlclear") | 1888 self.__sqlCommand(self.tr("Drop Tables"), "sqlclear") |
1898 | 1889 |
1899 def __databaseSqlFlushDatabase(self): | 1890 def __databaseSqlFlushDatabase(self): |
1900 """ | 1891 """ |
1901 Private slot to print a list of statements to return all database | 1892 Private slot to print a list of statements to return all database |
1902 tables to their initial state. | 1893 tables to their initial state. |
1903 """ | 1894 """ |
1904 self.__sqlCommand(self.trUtf8("Flush Database"), "sqlflush", False) | 1895 self.__sqlCommand(self.tr("Flush Database"), "sqlflush", False) |
1905 | 1896 |
1906 def __databaseSqlResetSequences(self): | 1897 def __databaseSqlResetSequences(self): |
1907 """ | 1898 """ |
1908 Private slot to print the SQL statements for resetting sequences for | 1899 Private slot to print the SQL statements for resetting sequences for |
1909 one or more applications. | 1900 one or more applications. |
1910 """ | 1901 """ |
1911 self.__sqlCommand(self.trUtf8("Reset Sequences"), "sqlsequencereset") | 1902 self.__sqlCommand(self.tr("Reset Sequences"), "sqlsequencereset") |
1912 | 1903 |
1913 ################################################################## | 1904 ################################################################## |
1914 ## slots below implement some tool functions | 1905 ## slots below implement some tool functions |
1915 ################################################################## | 1906 ################################################################## |
1916 | 1907 |
1917 def __diffSettings(self): | 1908 def __diffSettings(self): |
1918 """ | 1909 """ |
1919 Private slot to show the changes made to the settings.py file. | 1910 Private slot to show the changes made to the settings.py file. |
1920 """ | 1911 """ |
1921 title = self.trUtf8("Diff Settings") | 1912 title = self.tr("Diff Settings") |
1922 | 1913 |
1923 args = [] | 1914 args = [] |
1924 args.append(self.__getPythonExecutable()) | 1915 args.append(self.__getPythonExecutable()) |
1925 args.append("manage.py") | 1916 args.append("manage.py") |
1926 args.append("diffsettings") | 1917 args.append("diffsettings") |
1937 | 1928 |
1938 def __cleanup(self): | 1929 def __cleanup(self): |
1939 """ | 1930 """ |
1940 Private slot to clean out old data from the database. | 1931 Private slot to clean out old data from the database. |
1941 """ | 1932 """ |
1942 title = self.trUtf8("Cleanup") | 1933 title = self.tr("Cleanup") |
1943 | 1934 |
1944 args = [] | 1935 args = [] |
1945 args.append(self.__getPythonExecutable()) | 1936 args.append(self.__getPythonExecutable()) |
1946 args.append("manage.py") | 1937 args.append("manage.py") |
1947 args.append("cleanup") | 1938 args.append("cleanup") |
1951 except DjangoNoSiteSelectedException: | 1942 except DjangoNoSiteSelectedException: |
1952 return | 1943 return |
1953 | 1944 |
1954 dia = DjangoDialog( | 1945 dia = DjangoDialog( |
1955 title, | 1946 title, |
1956 msgSuccess=self.trUtf8("Database cleaned up successfully.")) | 1947 msgSuccess=self.tr("Database cleaned up successfully.")) |
1957 res = dia.startProcess(args, path) | 1948 res = dia.startProcess(args, path) |
1958 if res: | 1949 if res: |
1959 dia.exec_() | 1950 dia.exec_() |
1960 | 1951 |
1961 def __validate(self): | 1952 def __validate(self): |
1962 """ | 1953 """ |
1963 Private slot to validate all installed models. | 1954 Private slot to validate all installed models. |
1964 """ | 1955 """ |
1965 title = self.trUtf8("Validate") | 1956 title = self.tr("Validate") |
1966 | 1957 |
1967 args = [] | 1958 args = [] |
1968 args.append(self.__getPythonExecutable()) | 1959 args.append(self.__getPythonExecutable()) |
1969 args.append("manage.py") | 1960 args.append("manage.py") |
1970 args.append("validate") | 1961 args.append("validate") |
2002 wd = self.__sitePath() | 1993 wd = self.__sitePath() |
2003 started, pid = QProcess.startDetached(args[0], args[1:], wd) | 1994 started, pid = QProcess.startDetached(args[0], args[1:], wd) |
2004 if not started: | 1995 if not started: |
2005 E5MessageBox.critical( | 1996 E5MessageBox.critical( |
2006 None, | 1997 None, |
2007 self.trUtf8('Process Generation Error'), | 1998 self.tr('Process Generation Error'), |
2008 self.trUtf8('The Django process could not be' | 1999 self.tr('The Django process could not be started.')) |
2009 ' started.')) | |
2010 except DjangoNoSiteSelectedException: | 2000 except DjangoNoSiteSelectedException: |
2011 pass | 2001 pass |
2012 | 2002 |
2013 ################################################################## | 2003 ################################################################## |
2014 ## slots below implement caching functions | 2004 ## slots below implement caching functions |
2016 | 2006 |
2017 def __createCacheTables(self): | 2007 def __createCacheTables(self): |
2018 """ | 2008 """ |
2019 Private slot to create the tables for the SQL caching backend. | 2009 Private slot to create the tables for the SQL caching backend. |
2020 """ | 2010 """ |
2021 title = self.trUtf8("Create Cache Tables") | 2011 title = self.tr("Create Cache Tables") |
2022 | 2012 |
2023 try: | 2013 try: |
2024 wd = self.__sitePath() | 2014 wd = self.__sitePath() |
2025 except DjangoNoSiteSelectedException: | 2015 except DjangoNoSiteSelectedException: |
2026 return | 2016 return |
2027 | 2017 |
2028 tblStr, ok = QInputDialog.getText( | 2018 tblStr, ok = QInputDialog.getText( |
2029 self.__ui, | 2019 self.__ui, |
2030 title, | 2020 title, |
2031 self.trUtf8("Enter the names of the cache tables separated by" | 2021 self.tr("Enter the names of the cache tables separated by" |
2032 " spaces."), | 2022 " spaces."), |
2033 QLineEdit.Normal) | 2023 QLineEdit.Normal) |
2034 if ok and tblStr != "": | 2024 if ok and tblStr != "": |
2035 tableNames = tblStr.split() | 2025 tableNames = tblStr.split() |
2036 | 2026 |
2037 args = [] | 2027 args = [] |
2040 args.append("createcachetable") | 2030 args.append("createcachetable") |
2041 args += tableNames | 2031 args += tableNames |
2042 | 2032 |
2043 dia = DjangoDialog( | 2033 dia = DjangoDialog( |
2044 title, | 2034 title, |
2045 msgSuccess=self.trUtf8("Cache tables created successfully.")) | 2035 msgSuccess=self.tr("Cache tables created successfully.")) |
2046 res = dia.startProcess(args, wd) | 2036 res = dia.startProcess(args, wd) |
2047 if res: | 2037 if res: |
2048 dia.exec_() | 2038 dia.exec_() |
2049 | 2039 |
2050 ################################################################## | 2040 ################################################################## |
2053 | 2043 |
2054 def __dumpData(self): | 2044 def __dumpData(self): |
2055 """ | 2045 """ |
2056 Private slot to dump the database data to a fixture. | 2046 Private slot to dump the database data to a fixture. |
2057 """ | 2047 """ |
2058 title = self.trUtf8("Dump Data") | 2048 title = self.tr("Dump Data") |
2059 | 2049 |
2060 try: | 2050 try: |
2061 wd = self.__sitePath() | 2051 wd = self.__sitePath() |
2062 except DjangoNoSiteSelectedException: | 2052 except DjangoNoSiteSelectedException: |
2063 return | 2053 return |
2076 for excl in excls: | 2066 for excl in excls: |
2077 args.append("--exclude={0}".format(excl)) | 2067 args.append("--exclude={0}".format(excl)) |
2078 args += appls | 2068 args += appls |
2079 | 2069 |
2080 if format == "json": | 2070 if format == "json": |
2081 fileFilters = self.trUtf8("JSON Files (*.json)") | 2071 fileFilters = self.tr("JSON Files (*.json)") |
2082 elif format == "xml": | 2072 elif format == "xml": |
2083 fileFilters = self.trUtf8("XML Files (*.xml)") | 2073 fileFilters = self.tr("XML Files (*.xml)") |
2084 elif format == "yaml": | 2074 elif format == "yaml": |
2085 fileFilters = self.trUtf8("YAML Files (*.yaml)") | 2075 fileFilters = self.tr("YAML Files (*.yaml)") |
2086 | 2076 |
2087 dia = DjangoDialog( | 2077 dia = DjangoDialog( |
2088 title, fixed=True, linewrap=False, saveFilters=fileFilters) | 2078 title, fixed=True, linewrap=False, saveFilters=fileFilters) |
2089 res = dia.startProcess(args, wd, showCommand=False) | 2079 res = dia.startProcess(args, wd, showCommand=False) |
2090 if res: | 2080 if res: |
2092 | 2082 |
2093 def __loadData(self): | 2083 def __loadData(self): |
2094 """ | 2084 """ |
2095 Private slot to load data from fixture files. | 2085 Private slot to load data from fixture files. |
2096 """ | 2086 """ |
2097 title = self.trUtf8("Load Data") | 2087 title = self.tr("Load Data") |
2098 | 2088 |
2099 try: | 2089 try: |
2100 wd = self.__sitePath() | 2090 wd = self.__sitePath() |
2101 except DjangoNoSiteSelectedException: | 2091 except DjangoNoSiteSelectedException: |
2102 return | 2092 return |
2138 | 2128 |
2139 started, pid = QProcess.startDetached(args[0], args[1:], wd) | 2129 started, pid = QProcess.startDetached(args[0], args[1:], wd) |
2140 if not started: | 2130 if not started: |
2141 E5MessageBox.critical( | 2131 E5MessageBox.critical( |
2142 None, | 2132 None, |
2143 self.trUtf8('Process Generation Error'), | 2133 self.tr('Process Generation Error'), |
2144 self.trUtf8('The Django process could not be started.')) | 2134 self.tr('The Django process could not be started.')) |
2145 | 2135 |
2146 def __runTestServer(self): | 2136 def __runTestServer(self): |
2147 """ | 2137 """ |
2148 Private slot to run a development server with data from a set of | 2138 Private slot to run a development server with data from a set of |
2149 fixtures. | 2139 fixtures. |
2185 serverProcStarted = \ | 2175 serverProcStarted = \ |
2186 self.__testServerProc.waitForStarted() | 2176 self.__testServerProc.waitForStarted() |
2187 if not serverProcStarted: | 2177 if not serverProcStarted: |
2188 E5MessageBox.critical( | 2178 E5MessageBox.critical( |
2189 None, | 2179 None, |
2190 self.trUtf8('Process Generation Error'), | 2180 self.tr('Process Generation Error'), |
2191 self.trUtf8('The Django test server could not be' | 2181 self.tr('The Django test server could not be' |
2192 ' started.')) | 2182 ' started.')) |
2193 except DjangoNoSiteSelectedException: | 2183 except DjangoNoSiteSelectedException: |
2194 pass | 2184 pass |
2195 | 2185 |
2196 def __testServerProcFinished(self): | 2186 def __testServerProcFinished(self): |
2197 """ | 2187 """ |
2215 consoleCmd = self.__isSpawningConsole( | 2205 consoleCmd = self.__isSpawningConsole( |
2216 self.__plugin.getPreferences("ConsoleCommandNoClose"))[1] | 2206 self.__plugin.getPreferences("ConsoleCommandNoClose"))[1] |
2217 if consoleCmd: | 2207 if consoleCmd: |
2218 userName, ok = QInputDialog.getText( | 2208 userName, ok = QInputDialog.getText( |
2219 self.__ui, | 2209 self.__ui, |
2220 self.trUtf8("Change Password"), | 2210 self.tr("Change Password"), |
2221 self.trUtf8("Enter the name of the user:"), | 2211 self.tr("Enter the name of the user:"), |
2222 QLineEdit.Normal) | 2212 QLineEdit.Normal) |
2223 if ok and userName != "": | 2213 if ok and userName != "": |
2224 args = Utilities.parseOptionString(consoleCmd) | 2214 args = Utilities.parseOptionString(consoleCmd) |
2225 args[0] = Utilities.getExecutablePath(args[0]) | 2215 args[0] = Utilities.getExecutablePath(args[0]) |
2226 args.append(self.__getPythonExecutable()) | 2216 args.append(self.__getPythonExecutable()) |
2232 started, pid = QProcess.startDetached( | 2222 started, pid = QProcess.startDetached( |
2233 args[0], args[1:], wd) | 2223 args[0], args[1:], wd) |
2234 if not started: | 2224 if not started: |
2235 E5MessageBox.critical( | 2225 E5MessageBox.critical( |
2236 None, | 2226 None, |
2237 self.trUtf8('Process Generation Error'), | 2227 self.tr('Process Generation Error'), |
2238 self.trUtf8('The Django process could not be' | 2228 self.tr('The Django process could not be' |
2239 ' started.')) | 2229 ' started.')) |
2240 except DjangoNoSiteSelectedException: | 2230 except DjangoNoSiteSelectedException: |
2241 pass | 2231 pass |
2242 | 2232 |
2243 def __createSuperUser(self): | 2233 def __createSuperUser(self): |
2244 """ | 2234 """ |
2256 wd = self.__sitePath() | 2246 wd = self.__sitePath() |
2257 started, pid = QProcess.startDetached(args[0], args[1:], wd) | 2247 started, pid = QProcess.startDetached(args[0], args[1:], wd) |
2258 if not started: | 2248 if not started: |
2259 E5MessageBox.critical( | 2249 E5MessageBox.critical( |
2260 None, | 2250 None, |
2261 self.trUtf8('Process Generation Error'), | 2251 self.tr('Process Generation Error'), |
2262 self.trUtf8('The Django process could not be' | 2252 self.tr('The Django process could not be started.')) |
2263 ' started.')) | |
2264 except DjangoNoSiteSelectedException: | 2253 except DjangoNoSiteSelectedException: |
2265 pass | 2254 pass |
2266 | 2255 |
2267 ################################################################## | 2256 ################################################################## |
2268 ## slots below implement session functions | 2257 ## slots below implement session functions |
2270 | 2259 |
2271 def __clearSessions(self): | 2260 def __clearSessions(self): |
2272 """ | 2261 """ |
2273 Private slot to clear expired sessions. | 2262 Private slot to clear expired sessions. |
2274 """ | 2263 """ |
2275 title = self.trUtf8("Clear Sessions") | 2264 title = self.tr("Clear Sessions") |
2276 | 2265 |
2277 try: | 2266 try: |
2278 wd = self.__sitePath() | 2267 wd = self.__sitePath() |
2279 except DjangoNoSiteSelectedException: | 2268 except DjangoNoSiteSelectedException: |
2280 return | 2269 return |
2284 args.append("manage.py") | 2273 args.append("manage.py") |
2285 args.append("clearsessions") | 2274 args.append("clearsessions") |
2286 | 2275 |
2287 dia = DjangoDialog( | 2276 dia = DjangoDialog( |
2288 title, | 2277 title, |
2289 msgSuccess=self.trUtf8("Expired sessions cleared successfully.")) | 2278 msgSuccess=self.tr("Expired sessions cleared successfully.")) |
2290 res = dia.startProcess(args, wd) | 2279 res = dia.startProcess(args, wd) |
2291 if res: | 2280 if res: |
2292 dia.exec_() | 2281 dia.exec_() |
2293 | 2282 |
2294 ################################################################## | 2283 ################################################################## |
2351 """ | 2340 """ |
2352 Private slot handling the addition of a new language. | 2341 Private slot handling the addition of a new language. |
2353 | 2342 |
2354 @param code language code of the new language (string) | 2343 @param code language code of the new language (string) |
2355 """ | 2344 """ |
2356 title = self.trUtf8("Initializing message catalog for '{0}'")\ | 2345 title = self.tr("Initializing message catalog for '{0}'")\ |
2357 .format(code) | 2346 .format(code) |
2358 | 2347 |
2359 args = [] | 2348 args = [] |
2360 args.append(self.__getPythonExecutable()) | 2349 args.append(self.__getPythonExecutable()) |
2361 args.append("manage.py") | 2350 args.append("manage.py") |
2367 wd = self.__sitePath() | 2356 wd = self.__sitePath() |
2368 except DjangoNoSiteSelectedException: | 2357 except DjangoNoSiteSelectedException: |
2369 E5MessageBox.warning( | 2358 E5MessageBox.warning( |
2370 None, | 2359 None, |
2371 title, | 2360 title, |
2372 self.trUtf8('No current site selected or no site created yet.' | 2361 self.tr('No current site selected or no site created yet.' |
2373 ' Aborting...')) | 2362 ' Aborting...')) |
2374 return | 2363 return |
2375 | 2364 |
2376 dia = DjangoDialog( | 2365 dia = DjangoDialog( |
2377 title, | 2366 title, |
2378 msgSuccess=self.trUtf8( | 2367 msgSuccess=self.tr( |
2379 "\nMessage catalog initialized successfully.")) | 2368 "\nMessage catalog initialized successfully.")) |
2380 res = dia.startProcess(args, wd) | 2369 res = dia.startProcess(args, wd) |
2381 if res: | 2370 if res: |
2382 dia.exec_() | 2371 dia.exec_() |
2383 | 2372 |
2389 """ | 2378 """ |
2390 Public method to update the message catalogs. | 2379 Public method to update the message catalogs. |
2391 | 2380 |
2392 @param filenames list of file names (list of strings) | 2381 @param filenames list of file names (list of strings) |
2393 """ | 2382 """ |
2394 title = self.trUtf8("Updating message catalogs") | 2383 title = self.tr("Updating message catalogs") |
2395 | 2384 |
2396 try: | 2385 try: |
2397 wd = self.__sitePath() | 2386 wd = self.__sitePath() |
2398 except DjangoNoSiteSelectedException: | 2387 except DjangoNoSiteSelectedException: |
2399 E5MessageBox.warning( | 2388 E5MessageBox.warning( |
2400 None, | 2389 None, |
2401 title, | 2390 title, |
2402 self.trUtf8('No current site selected or no site created yet.' | 2391 self.tr('No current site selected or no site created yet.' |
2403 ' Aborting...')) | 2392 ' Aborting...')) |
2404 return | 2393 return |
2405 | 2394 |
2406 argsLists = [] | 2395 argsLists = [] |
2407 | 2396 |
2408 for filename in self.__normalizeList( | 2397 for filename in self.__normalizeList( |
2420 | 2409 |
2421 if len(argsLists) == 0: | 2410 if len(argsLists) == 0: |
2422 E5MessageBox.warning( | 2411 E5MessageBox.warning( |
2423 None, | 2412 None, |
2424 title, | 2413 title, |
2425 self.trUtf8('No locales detected. Aborting...')) | 2414 self.tr('No locales detected. Aborting...')) |
2426 return | 2415 return |
2427 | 2416 |
2428 dia = DjangoDialog( | 2417 dia = DjangoDialog( |
2429 title, | 2418 title, |
2430 msgSuccess=self.trUtf8("\nMessage catalogs updated successfully.")) | 2419 msgSuccess=self.tr("\nMessage catalogs updated successfully.")) |
2431 res = dia.startBatchProcesses(argsLists, wd) | 2420 res = dia.startBatchProcesses(argsLists, wd) |
2432 if res: | 2421 if res: |
2433 dia.exec_() | 2422 dia.exec_() |
2434 | 2423 |
2435 def updateSelectedCatalogsWithObsolete(self, filenames): | 2424 def updateSelectedCatalogsWithObsolete(self, filenames): |
2436 """ | 2425 """ |
2437 Public method to update the message catalogs keeping obsolete messages. | 2426 Public method to update the message catalogs keeping obsolete messages. |
2438 | 2427 |
2439 @param filenames list of filenames | 2428 @param filenames list of filenames |
2440 """ | 2429 """ |
2441 title = self.trUtf8("Updating message catalogs (keeping obsolete" | 2430 title = self.tr("Updating message catalogs (keeping obsolete" |
2442 " messages)") | 2431 " messages)") |
2443 | 2432 |
2444 try: | 2433 try: |
2445 wd = self.__sitePath() | 2434 wd = self.__sitePath() |
2446 except DjangoNoSiteSelectedException: | 2435 except DjangoNoSiteSelectedException: |
2447 E5MessageBox.warning( | 2436 E5MessageBox.warning( |
2448 None, | 2437 None, |
2449 title, | 2438 title, |
2450 self.trUtf8('No current site selected or no site created yet.' | 2439 self.tr('No current site selected or no site created yet.' |
2451 ' Aborting...')) | 2440 ' Aborting...')) |
2452 return | 2441 return |
2453 | 2442 |
2454 argsLists = [] | 2443 argsLists = [] |
2455 | 2444 |
2456 for filename in self.__normalizeList( | 2445 for filename in self.__normalizeList( |
2467 | 2456 |
2468 if len(argsLists) == 0: | 2457 if len(argsLists) == 0: |
2469 E5MessageBox.warning( | 2458 E5MessageBox.warning( |
2470 None, | 2459 None, |
2471 title, | 2460 title, |
2472 self.trUtf8('No locales detected. Aborting...')) | 2461 self.tr('No locales detected. Aborting...')) |
2473 return | 2462 return |
2474 | 2463 |
2475 dia = DjangoDialog( | 2464 dia = DjangoDialog( |
2476 title, | 2465 title, |
2477 msgSuccess=self.trUtf8("\nMessage catalogs updated successfully.")) | 2466 msgSuccess=self.tr("\nMessage catalogs updated successfully.")) |
2478 res = dia.startBatchProcesses(argsLists, wd) | 2467 res = dia.startBatchProcesses(argsLists, wd) |
2479 if res: | 2468 if res: |
2480 dia.exec_() | 2469 dia.exec_() |
2481 | 2470 |
2482 def updateCatalogs(self, filenames): | 2471 def updateCatalogs(self, filenames): |
2483 """ | 2472 """ |
2484 Public method to update the message catalogs. | 2473 Public method to update the message catalogs. |
2485 | 2474 |
2486 @param filenames list of filenames (not used) | 2475 @param filenames list of filenames (not used) |
2487 """ | 2476 """ |
2488 title = self.trUtf8("Updating message catalogs") | 2477 title = self.tr("Updating message catalogs") |
2489 | 2478 |
2490 args = [] | 2479 args = [] |
2491 args.append(self.__getPythonExecutable()) | 2480 args.append(self.__getPythonExecutable()) |
2492 args.append("manage.py") | 2481 args.append("manage.py") |
2493 args.append("makemessages") | 2482 args.append("makemessages") |
2498 wd = self.__sitePath() | 2487 wd = self.__sitePath() |
2499 except DjangoNoSiteSelectedException: | 2488 except DjangoNoSiteSelectedException: |
2500 E5MessageBox.warning( | 2489 E5MessageBox.warning( |
2501 None, | 2490 None, |
2502 title, | 2491 title, |
2503 self.trUtf8('No current site selected or no site created yet.' | 2492 self.tr('No current site selected or no site created yet.' |
2504 ' Aborting...')) | 2493 ' Aborting...')) |
2505 return | 2494 return |
2506 | 2495 |
2507 dia = DjangoDialog( | 2496 dia = DjangoDialog( |
2508 title, | 2497 title, |
2509 msgSuccess=self.trUtf8("\nMessage catalogs updated successfully.")) | 2498 msgSuccess=self.tr("\nMessage catalogs updated successfully.")) |
2510 res = dia.startProcess(args, wd) | 2499 res = dia.startProcess(args, wd) |
2511 if res: | 2500 if res: |
2512 dia.exec_() | 2501 dia.exec_() |
2513 | 2502 |
2514 def updateCatalogsWithObsolete(self, filenames): | 2503 def updateCatalogsWithObsolete(self, filenames): |
2515 """ | 2504 """ |
2516 Public method to update the message catalogs keeping obsolete messages. | 2505 Public method to update the message catalogs keeping obsolete messages. |
2517 | 2506 |
2518 @param filenames list of filenames (not used) | 2507 @param filenames list of filenames (not used) |
2519 """ | 2508 """ |
2520 title = self.trUtf8("Updating message catalogs (keeping obsolete" | 2509 title = self.tr("Updating message catalogs (keeping obsolete" |
2521 " messages)") | 2510 " messages)") |
2522 | 2511 |
2523 args = [] | 2512 args = [] |
2524 args.append(self.__getPythonExecutable()) | 2513 args.append(self.__getPythonExecutable()) |
2525 args.append("manage.py") | 2514 args.append("manage.py") |
2526 args.append("makemessages") | 2515 args.append("makemessages") |
2530 wd = self.__sitePath() | 2519 wd = self.__sitePath() |
2531 except DjangoNoSiteSelectedException: | 2520 except DjangoNoSiteSelectedException: |
2532 E5MessageBox.warning( | 2521 E5MessageBox.warning( |
2533 None, | 2522 None, |
2534 title, | 2523 title, |
2535 self.trUtf8('No current site selected or no site created yet.' | 2524 self.tr('No current site selected or no site created yet.' |
2536 ' Aborting...')) | 2525 ' Aborting...')) |
2537 return | 2526 return |
2538 | 2527 |
2539 dia = DjangoDialog( | 2528 dia = DjangoDialog( |
2540 title, | 2529 title, |
2541 msgSuccess=self.trUtf8("\nMessage catalogs updated successfully.")) | 2530 msgSuccess=self.tr("\nMessage catalogs updated successfully.")) |
2542 res = dia.startProcess(args, wd) | 2531 res = dia.startProcess(args, wd) |
2543 if res: | 2532 if res: |
2544 dia.exec_() | 2533 dia.exec_() |
2545 | 2534 |
2546 def compileSelectedCatalogs(self, filenames): | 2535 def compileSelectedCatalogs(self, filenames): |
2547 """ | 2536 """ |
2548 Public method to update the message catalogs. | 2537 Public method to update the message catalogs. |
2549 | 2538 |
2550 @param filenames list of filenames | 2539 @param filenames list of filenames |
2551 """ | 2540 """ |
2552 title = self.trUtf8("Compiling message catalogs") | 2541 title = self.tr("Compiling message catalogs") |
2553 | 2542 |
2554 try: | 2543 try: |
2555 wd = self.__sitePath() | 2544 wd = self.__sitePath() |
2556 except DjangoNoSiteSelectedException: | 2545 except DjangoNoSiteSelectedException: |
2557 E5MessageBox.warning( | 2546 E5MessageBox.warning( |
2558 None, | 2547 None, |
2559 title, | 2548 title, |
2560 self.trUtf8('No current site selected or no site created yet.' | 2549 self.tr('No current site selected or no site created yet.' |
2561 ' Aborting...')) | 2550 ' Aborting...')) |
2562 return | 2551 return |
2563 | 2552 |
2564 argsLists = [] | 2553 argsLists = [] |
2565 | 2554 |
2566 for filename in self.__normalizeList( | 2555 for filename in self.__normalizeList( |
2577 | 2566 |
2578 if len(argsLists) == 0: | 2567 if len(argsLists) == 0: |
2579 E5MessageBox.warning( | 2568 E5MessageBox.warning( |
2580 None, | 2569 None, |
2581 title, | 2570 title, |
2582 self.trUtf8('No locales detected. Aborting...')) | 2571 self.tr('No locales detected. Aborting...')) |
2583 return | 2572 return |
2584 | 2573 |
2585 dia = DjangoDialog( | 2574 dia = DjangoDialog( |
2586 title, | 2575 title, |
2587 msgSuccess=self.trUtf8( | 2576 msgSuccess=self.tr( |
2588 "\nMessage catalogs compiled successfully.")) | 2577 "\nMessage catalogs compiled successfully.")) |
2589 res = dia.startBatchProcesses(argsLists, wd, mergedOutput=True) | 2578 res = dia.startBatchProcesses(argsLists, wd, mergedOutput=True) |
2590 if res: | 2579 if res: |
2591 dia.exec_() | 2580 dia.exec_() |
2592 | 2581 |
2600 """ | 2589 """ |
2601 Public method to compile the message catalogs. | 2590 Public method to compile the message catalogs. |
2602 | 2591 |
2603 @param filenames list of filenames (not used) | 2592 @param filenames list of filenames (not used) |
2604 """ | 2593 """ |
2605 title = self.trUtf8("Compiling message catalogs") | 2594 title = self.tr("Compiling message catalogs") |
2606 | 2595 |
2607 args = [] | 2596 args = [] |
2608 args.append(self.__getPythonExecutable()) | 2597 args.append(self.__getPythonExecutable()) |
2609 args.append("manage.py") | 2598 args.append("manage.py") |
2610 args.append("compilemessages") | 2599 args.append("compilemessages") |
2613 wd = self.__sitePath() | 2602 wd = self.__sitePath() |
2614 except DjangoNoSiteSelectedException: | 2603 except DjangoNoSiteSelectedException: |
2615 E5MessageBox.warning( | 2604 E5MessageBox.warning( |
2616 None, | 2605 None, |
2617 title, | 2606 title, |
2618 self.trUtf8('No current site selected or no site created yet.' | 2607 self.tr('No current site selected or no site created yet.' |
2619 ' Aborting...')) | 2608 ' Aborting...')) |
2620 return | 2609 return |
2621 | 2610 |
2622 dia = DjangoDialog( | 2611 dia = DjangoDialog( |
2623 title, | 2612 title, |
2624 msgSuccess=self.trUtf8( | 2613 msgSuccess=self.tr( |
2625 "\nMessage catalogs compiled successfully.")) | 2614 "\nMessage catalogs compiled successfully.")) |
2626 res = dia.startProcess(args, wd, mergedOutput=True) | 2615 res = dia.startProcess(args, wd, mergedOutput=True) |
2627 if res: | 2616 if res: |
2628 dia.exec_() | 2617 dia.exec_() |
2629 | 2618 |
2647 wd = "" | 2636 wd = "" |
2648 started, pid = QProcess.startDetached(editor, [poFile], wd) | 2637 started, pid = QProcess.startDetached(editor, [poFile], wd) |
2649 if not started: | 2638 if not started: |
2650 E5MessageBox.critical( | 2639 E5MessageBox.critical( |
2651 None, | 2640 None, |
2652 self.trUtf8('Process Generation Error'), | 2641 self.tr('Process Generation Error'), |
2653 self.trUtf8('The translations editor process ({0}) could' | 2642 self.tr('The translations editor process ({0}) could' |
2654 ' not be started.') | 2643 ' not be started.') |
2655 .format(os.path.basename(editor))) | 2644 .format(os.path.basename(editor))) |