78 |
80 |
79 ############################### |
81 ############################### |
80 ## create actions below ## |
82 ## create actions below ## |
81 ############################### |
83 ############################### |
82 |
84 |
83 self.createProjectAct = E5Action(self.trUtf8('Create Pyramid Project'), |
85 self.createProjectAct = E5Action( |
84 self.trUtf8('Create Pyramid &Project'), |
86 self.trUtf8('Create Pyramid Project'), |
85 0, 0, |
87 self.trUtf8('Create Pyramid &Project'), |
86 self, 'pyramid_create_project') |
88 0, 0, |
|
89 self, 'pyramid_create_project') |
87 self.createProjectAct.setStatusTip(self.trUtf8( |
90 self.createProjectAct.setStatusTip(self.trUtf8( |
88 'Creates a new Pyramid project')) |
91 'Creates a new Pyramid project')) |
89 self.createProjectAct.setWhatsThis(self.trUtf8( |
92 self.createProjectAct.setWhatsThis(self.trUtf8( |
90 """<b>Create Pyramid Project</b>""" |
93 """<b>Create Pyramid Project</b>""" |
91 """<p>Creates a new Pyramid project using "pcreate".</p>""" |
94 """<p>Creates a new Pyramid project using "pcreate".</p>""" |
95 |
98 |
96 ############################## |
99 ############################## |
97 ## run actions below ## |
100 ## run actions below ## |
98 ############################## |
101 ############################## |
99 |
102 |
100 self.runServerAct = E5Action(self.trUtf8('Run Server'), |
103 self.runServerAct = E5Action( |
101 self.trUtf8('Run &Server'), |
104 self.trUtf8('Run Server'), |
102 0, 0, |
105 self.trUtf8('Run &Server'), |
103 self, 'pyramid_run_server') |
106 0, 0, |
|
107 self, 'pyramid_run_server') |
104 self.runServerAct.setStatusTip(self.trUtf8( |
108 self.runServerAct.setStatusTip(self.trUtf8( |
105 'Starts the Pyramid Web server')) |
109 'Starts the Pyramid Web server')) |
106 self.runServerAct.setWhatsThis(self.trUtf8( |
110 self.runServerAct.setWhatsThis(self.trUtf8( |
107 """<b>Run Server</b>""" |
111 """<b>Run Server</b>""" |
108 """<p>Starts the Pyramid Web server using""" |
112 """<p>Starts the Pyramid Web server using""" |
109 """ "pserve --reload development.ini".</p>""" |
113 """ "pserve --reload development.ini".</p>""" |
110 )) |
114 )) |
111 self.runServerAct.triggered[()].connect(self.__runServer) |
115 self.runServerAct.triggered[()].connect(self.__runServer) |
112 self.actions.append(self.runServerAct) |
116 self.actions.append(self.runServerAct) |
113 |
117 |
114 self.runLoggingServerAct = E5Action(self.trUtf8('Run Server with Logging'), |
118 self.runLoggingServerAct = E5Action( |
115 self.trUtf8('Run Server with &Logging'), |
119 self.trUtf8('Run Server with Logging'), |
116 0, 0, |
120 self.trUtf8('Run Server with &Logging'), |
117 self, 'pyramid_run_logging_server') |
121 0, 0, |
|
122 self, 'pyramid_run_logging_server') |
118 self.runLoggingServerAct.setStatusTip(self.trUtf8( |
123 self.runLoggingServerAct.setStatusTip(self.trUtf8( |
119 'Starts the Pyramid Web server with logging')) |
124 'Starts the Pyramid Web server with logging')) |
120 self.runLoggingServerAct.setWhatsThis(self.trUtf8( |
125 self.runLoggingServerAct.setWhatsThis(self.trUtf8( |
121 """<b>Run Server with Logging</b>""" |
126 """<b>Run Server with Logging</b>""" |
122 """<p>Starts the Pyramid Web server with logging using""" |
127 """<p>Starts the Pyramid Web server with logging using""" |
123 """ "pserve --log-file=server.log --reload development.ini".</p>""" |
128 """ "pserve --log-file=server.log --reload development.ini".</p>""" |
124 )) |
129 )) |
125 self.runLoggingServerAct.triggered[()].connect(self.__runLoggingServer) |
130 self.runLoggingServerAct.triggered[()].connect(self.__runLoggingServer) |
126 self.actions.append(self.runLoggingServerAct) |
131 self.actions.append(self.runLoggingServerAct) |
127 |
132 |
128 self.runBrowserAct = E5Action(self.trUtf8('Run Web-Browser'), |
133 self.runBrowserAct = E5Action( |
129 self.trUtf8('Run &Web-Browser'), |
134 self.trUtf8('Run Web-Browser'), |
130 0, 0, |
135 self.trUtf8('Run &Web-Browser'), |
131 self, 'pyramid_run_browser') |
136 0, 0, |
|
137 self, 'pyramid_run_browser') |
132 self.runBrowserAct.setStatusTip(self.trUtf8( |
138 self.runBrowserAct.setStatusTip(self.trUtf8( |
133 'Starts the default Web-Browser with the URL of the Pyramid Web server')) |
139 'Starts the default Web-Browser with the URL of the Pyramid Web' |
|
140 ' server')) |
134 self.runBrowserAct.setWhatsThis(self.trUtf8( |
141 self.runBrowserAct.setWhatsThis(self.trUtf8( |
135 """<b>Run Web-Browser</b>""" |
142 """<b>Run Web-Browser</b>""" |
136 """<p>Starts the default Web-Browser with the URL of the """ |
143 """<p>Starts the default Web-Browser with the URL of the """ |
137 """Pyramid Web server.</p>""" |
144 """Pyramid Web server.</p>""" |
138 )) |
145 )) |
139 self.runBrowserAct.triggered[()].connect(self.__runBrowser) |
146 self.runBrowserAct.triggered[()].connect(self.__runBrowser) |
140 self.actions.append(self.runBrowserAct) |
147 self.actions.append(self.runBrowserAct) |
141 |
148 |
142 self.runPythonShellAct = E5Action(self.trUtf8('Start Pyramid Python Console'), |
149 self.runPythonShellAct = E5Action( |
143 self.trUtf8('Start Pyramid &Python Console'), |
150 self.trUtf8('Start Pyramid Python Console'), |
144 0, 0, |
151 self.trUtf8('Start Pyramid &Python Console'), |
145 self, 'pyramid_python_console') |
152 0, 0, |
|
153 self, 'pyramid_python_console') |
146 self.runPythonShellAct.setStatusTip(self.trUtf8( |
154 self.runPythonShellAct.setStatusTip(self.trUtf8( |
147 'Starts an interactive Python interpreter')) |
155 'Starts an interactive Python interpreter')) |
148 self.runPythonShellAct.setWhatsThis(self.trUtf8( |
156 self.runPythonShellAct.setWhatsThis(self.trUtf8( |
149 """<b>Start Pyramid Python Console</b>""" |
157 """<b>Start Pyramid Python Console</b>""" |
150 """<p>Starts an interactive Python interpreter.</p>""" |
158 """<p>Starts an interactive Python interpreter.</p>""" |
154 |
162 |
155 ############################## |
163 ############################## |
156 ## setup actions below ## |
164 ## setup actions below ## |
157 ############################## |
165 ############################## |
158 |
166 |
159 self.setupDevelopAct = E5Action(self.trUtf8('Setup Development Environment'), |
167 self.setupDevelopAct = E5Action( |
160 self.trUtf8('Setup &Development Environment'), |
168 self.trUtf8('Setup Development Environment'), |
161 0, 0, |
169 self.trUtf8('Setup &Development Environment'), |
162 self, 'pyramid_setup_development') |
170 0, 0, |
|
171 self, 'pyramid_setup_development') |
163 self.setupDevelopAct.setStatusTip(self.trUtf8( |
172 self.setupDevelopAct.setStatusTip(self.trUtf8( |
164 'Setup the Pyramid project in development mode')) |
173 'Setup the Pyramid project in development mode')) |
165 self.setupDevelopAct.setWhatsThis(self.trUtf8( |
174 self.setupDevelopAct.setWhatsThis(self.trUtf8( |
166 """<b>Setup Development Environment</b>""" |
175 """<b>Setup Development Environment</b>""" |
167 """<p>Setup the Pyramid project in development mode using""" |
176 """<p>Setup the Pyramid project in development mode using""" |
172 |
181 |
173 ############################### |
182 ############################### |
174 ## database actions below ## |
183 ## database actions below ## |
175 ############################### |
184 ############################### |
176 |
185 |
177 self.initializeDbAct = E5Action(self.trUtf8('Initialize Database'), |
186 self.initializeDbAct = E5Action( |
178 self.trUtf8('Initialize &Database'), |
187 self.trUtf8('Initialize Database'), |
179 0, 0, |
188 self.trUtf8('Initialize &Database'), |
180 self, 'pyramid_initialize_database') |
189 0, 0, |
|
190 self, 'pyramid_initialize_database') |
181 self.initializeDbAct.setStatusTip(self.trUtf8( |
191 self.initializeDbAct.setStatusTip(self.trUtf8( |
182 'Initializes (or re-initializes) the database of the current' |
192 'Initializes (or re-initializes) the database of the current' |
183 ' Pyramid project')) |
193 ' Pyramid project')) |
184 self.initializeDbAct.setWhatsThis(self.trUtf8( |
194 self.initializeDbAct.setWhatsThis(self.trUtf8( |
185 """<b>Initialize Database</b>""" |
195 """<b>Initialize Database</b>""" |
186 """<p>Initializes (or re-initializes) the database of the current""" |
196 """<p>Initializes (or re-initializes) the database of the""" |
187 """ Pyramid project.</p>""" |
197 """ current Pyramid project.</p>""" |
188 )) |
198 )) |
189 self.initializeDbAct.triggered[()].connect(self.__initializeDatabase) |
199 self.initializeDbAct.triggered[()].connect(self.__initializeDatabase) |
190 self.actions.append(self.initializeDbAct) |
200 self.actions.append(self.initializeDbAct) |
191 |
201 |
192 ############################### |
202 ############################### |
193 ## show actions below ## |
203 ## show actions below ## |
194 ############################### |
204 ############################### |
195 |
205 |
196 self.showViewsAct = E5Action(self.trUtf8('Show Matching Views'), |
206 self.showViewsAct = E5Action( |
197 self.trUtf8('Show Matching &Views'), |
207 self.trUtf8('Show Matching Views'), |
198 0, 0, |
208 self.trUtf8('Show Matching &Views'), |
199 self, 'pyramid_show_views') |
209 0, 0, |
|
210 self, 'pyramid_show_views') |
200 self.showViewsAct.setStatusTip(self.trUtf8( |
211 self.showViewsAct.setStatusTip(self.trUtf8( |
201 'Show views matching a given URL')) |
212 'Show views matching a given URL')) |
202 self.showViewsAct.setWhatsThis(self.trUtf8( |
213 self.showViewsAct.setWhatsThis(self.trUtf8( |
203 """<b>Show Matching Views</b>""" |
214 """<b>Show Matching Views</b>""" |
204 """<p>Show views matching a given URL.</p>""" |
215 """<p>Show views matching a given URL.</p>""" |
205 )) |
216 )) |
206 self.showViewsAct.triggered[()].connect(self.__showMatchingViews) |
217 self.showViewsAct.triggered[()].connect(self.__showMatchingViews) |
207 self.actions.append(self.showViewsAct) |
218 self.actions.append(self.showViewsAct) |
208 |
219 |
209 self.showRoutesAct = E5Action(self.trUtf8('Show Routes'), |
220 self.showRoutesAct = E5Action( |
210 self.trUtf8('Show &Routes'), |
221 self.trUtf8('Show Routes'), |
211 0, 0, |
222 self.trUtf8('Show &Routes'), |
212 self, 'pyramid_show_routes') |
223 0, 0, |
|
224 self, 'pyramid_show_routes') |
213 self.showRoutesAct.setStatusTip(self.trUtf8( |
225 self.showRoutesAct.setStatusTip(self.trUtf8( |
214 'Show all URL dispatch routes used by a Pyramid application')) |
226 'Show all URL dispatch routes used by a Pyramid application')) |
215 self.showRoutesAct.setWhatsThis(self.trUtf8( |
227 self.showRoutesAct.setWhatsThis(self.trUtf8( |
216 """<b>Show Routes</b>""" |
228 """<b>Show Routes</b>""" |
217 """<p>Show all URL dispatch routes used by a Pyramid application""" |
229 """<p>Show all URL dispatch routes used by a Pyramid application""" |
218 """ in the order in which they are evaluated.</p>""" |
230 """ in the order in which they are evaluated.</p>""" |
219 )) |
231 )) |
220 self.showRoutesAct.triggered[()].connect(self.__showRoutes) |
232 self.showRoutesAct.triggered[()].connect(self.__showRoutes) |
221 self.actions.append(self.showRoutesAct) |
233 self.actions.append(self.showRoutesAct) |
222 |
234 |
223 self.showTweensAct = E5Action(self.trUtf8('Show Tween Objects'), |
235 self.showTweensAct = E5Action( |
224 self.trUtf8('Show &Tween Objects'), |
236 self.trUtf8('Show Tween Objects'), |
225 0, 0, |
237 self.trUtf8('Show &Tween Objects'), |
226 self, 'pyramid_show_routes') |
238 0, 0, |
|
239 self, 'pyramid_show_routes') |
227 self.showTweensAct.setStatusTip(self.trUtf8( |
240 self.showTweensAct.setStatusTip(self.trUtf8( |
228 'Show all implicit and explicit tween objects used by a Pyramid application')) |
241 'Show all implicit and explicit tween objects used by a Pyramid' |
|
242 ' application')) |
229 self.showTweensAct.setWhatsThis(self.trUtf8( |
243 self.showTweensAct.setWhatsThis(self.trUtf8( |
230 """<b>Show Tween Objects</b>""" |
244 """<b>Show Tween Objects</b>""" |
231 """<p>Show all implicit and explicit tween objects used by a""" |
245 """<p>Show all implicit and explicit tween objects used by a""" |
232 """ Pyramid application.</p>""" |
246 """ Pyramid application.</p>""" |
233 )) |
247 )) |
236 |
250 |
237 ################################## |
251 ################################## |
238 ## distribution actions below ## |
252 ## distribution actions below ## |
239 ################################## |
253 ################################## |
240 |
254 |
241 self.buildDistroAct = E5Action(self.trUtf8('Build Distribution'), |
255 self.buildDistroAct = E5Action( |
242 self.trUtf8('Build &Distribution'), |
256 self.trUtf8('Build Distribution'), |
243 0, 0, |
257 self.trUtf8('Build &Distribution'), |
244 self, 'pyramid_build_distribution') |
258 0, 0, |
|
259 self, 'pyramid_build_distribution') |
245 self.buildDistroAct.setStatusTip(self.trUtf8( |
260 self.buildDistroAct.setStatusTip(self.trUtf8( |
246 'Builds a distribution file for the Pyramid project')) |
261 'Builds a distribution file for the Pyramid project')) |
247 self.buildDistroAct.setWhatsThis(self.trUtf8( |
262 self.buildDistroAct.setWhatsThis(self.trUtf8( |
248 """<b>Build Distribution</b>""" |
263 """<b>Build Distribution</b>""" |
249 """<p>Builds a distribution file for the Pyramid project using""" |
264 """<p>Builds a distribution file for the Pyramid project using""" |
254 |
269 |
255 ################################## |
270 ################################## |
256 ## documentation action below ## |
271 ## documentation action below ## |
257 ################################## |
272 ################################## |
258 |
273 |
259 self.documentationAct = E5Action(self.trUtf8('Documentation'), |
274 self.documentationAct = E5Action( |
260 self.trUtf8('D&ocumentation'), |
275 self.trUtf8('Documentation'), |
261 0, 0, |
276 self.trUtf8('D&ocumentation'), |
262 self, 'pyramid_documentation') |
277 0, 0, |
|
278 self, 'pyramid_documentation') |
263 self.documentationAct.setStatusTip(self.trUtf8( |
279 self.documentationAct.setStatusTip(self.trUtf8( |
264 'Shows the help viewer with the Pyramid documentation')) |
280 'Shows the help viewer with the Pyramid documentation')) |
265 self.documentationAct.setWhatsThis(self.trUtf8( |
281 self.documentationAct.setWhatsThis(self.trUtf8( |
266 """<b>Documentation</b>""" |
282 """<b>Documentation</b>""" |
267 """<p>Shows the help viewer with the Pyramid documentation.</p>""" |
283 """<p>Shows the help viewer with the Pyramid documentation.</p>""" |
271 |
287 |
272 ############################## |
288 ############################## |
273 ## about action below ## |
289 ## about action below ## |
274 ############################## |
290 ############################## |
275 |
291 |
276 self.aboutPyramidAct = E5Action(self.trUtf8('About Pyramid'), |
292 self.aboutPyramidAct = E5Action( |
277 self.trUtf8('About P&yramid'), |
293 self.trUtf8('About Pyramid'), |
278 0, 0, |
294 self.trUtf8('About P&yramid'), |
279 self, 'pyramid_about') |
295 0, 0, |
|
296 self, 'pyramid_about') |
280 self.aboutPyramidAct.setStatusTip(self.trUtf8( |
297 self.aboutPyramidAct.setStatusTip(self.trUtf8( |
281 'Shows some information about Pyramid')) |
298 'Shows some information about Pyramid')) |
282 self.aboutPyramidAct.setWhatsThis(self.trUtf8( |
299 self.aboutPyramidAct.setWhatsThis(self.trUtf8( |
283 """<b>About Pyramid</b>""" |
300 """<b>About Pyramid</b>""" |
284 """<p>Shows some information about Pyramid.</p>""" |
301 """<p>Shows some information about Pyramid.</p>""" |
347 Public method to add our hook methods. |
365 Public method to add our hook methods. |
348 """ |
366 """ |
349 if self.__e5project.getProjectType() == "Pyramid": |
367 if self.__e5project.getProjectType() == "Pyramid": |
350 self.__formsBrowser = \ |
368 self.__formsBrowser = \ |
351 e5App().getObject("ProjectBrowser").getProjectBrowser("forms") |
369 e5App().getObject("ProjectBrowser").getProjectBrowser("forms") |
352 self.__formsBrowser.addHookMethodAndMenuEntry("newForm", |
370 self.__formsBrowser.addHookMethodAndMenuEntry( |
353 self.newForm, self.trUtf8("New template...")) |
371 "newForm", self.newForm, self.trUtf8("New template...")) |
354 |
372 |
355 if self.__e5project.getProjectLanguage() == "Python2": |
373 if self.__e5project.getProjectLanguage() == "Python2": |
356 # Babel and lingua are not yet available for Python 3 |
374 # Babel and lingua are not yet available for Python 3 |
357 self.__e5project.projectLanguageAddedByCode.connect( |
375 self.__e5project.projectLanguageAddedByCode.connect( |
358 self.__projectLanguageAdded) |
376 self.__projectLanguageAdded) |
359 self.__translationsBrowser = \ |
377 self.__translationsBrowser = \ |
360 e5App().getObject("ProjectBrowser").getProjectBrowser("translations") |
378 e5App().getObject("ProjectBrowser")\ |
361 self.__translationsBrowser.addHookMethodAndMenuEntry("extractMessages", |
379 .getProjectBrowser("translations") |
362 self.extractMessages, self.trUtf8("Extract Messages")) |
380 self.__translationsBrowser.addHookMethodAndMenuEntry( |
363 self.__translationsBrowser.addHookMethodAndMenuEntry("releaseAll", |
381 "extractMessages", self.extractMessages, |
364 self.compileCatalogs, self.trUtf8("Compile All Catalogs")) |
382 self.trUtf8("Extract Messages")) |
365 self.__translationsBrowser.addHookMethodAndMenuEntry("releaseSelected", |
383 self.__translationsBrowser.addHookMethodAndMenuEntry( |
366 self.compileSelectedCatalogs, |
384 "releaseAll", self.compileCatalogs, |
|
385 self.trUtf8("Compile All Catalogs")) |
|
386 self.__translationsBrowser.addHookMethodAndMenuEntry( |
|
387 "releaseSelected", self.compileSelectedCatalogs, |
367 self.trUtf8("Compile Selected Catalogs")) |
388 self.trUtf8("Compile Selected Catalogs")) |
368 self.__translationsBrowser.addHookMethodAndMenuEntry("generateAll", |
389 self.__translationsBrowser.addHookMethodAndMenuEntry( |
369 self.updateCatalogs, self.trUtf8("Update All Catalogs")) |
390 "generateAll", self.updateCatalogs, |
370 self.__translationsBrowser.addHookMethodAndMenuEntry("generateSelected", |
391 self.trUtf8("Update All Catalogs")) |
371 self.updateSelectedCatalogs, self.trUtf8("Update Selected Catalogs")) |
392 self.__translationsBrowser.addHookMethodAndMenuEntry( |
|
393 "generateSelected", self.updateSelectedCatalogs, |
|
394 self.trUtf8("Update Selected Catalogs")) |
372 |
395 |
373 self.__hooksInstalled = True |
396 self.__hooksInstalled = True |
374 |
397 |
375 self.registerOpenHook() |
398 self.registerOpenHook() |
376 |
399 |
431 ex = selectedFilter.split("(*")[1].split(")")[0] |
454 ex = selectedFilter.split("(*")[1].split(")")[0] |
432 if ex: |
455 if ex: |
433 fname += ex |
456 fname += ex |
434 |
457 |
435 if os.path.exists(fname): |
458 if os.path.exists(fname): |
436 res = E5MessageBox.yesNo(self.__ui, |
459 res = E5MessageBox.yesNo( |
|
460 self.__ui, |
437 self.trUtf8("New Form"), |
461 self.trUtf8("New Form"), |
438 self.trUtf8("""The file already exists! Overwrite it?"""), |
462 self.trUtf8("""The file already exists! Overwrite""" |
|
463 """ it?"""), |
439 icon=E5MessageBox.Warning) |
464 icon=E5MessageBox.Warning) |
440 if not res: |
465 if not res: |
441 # user selected to not overwrite |
466 # user selected to not overwrite |
442 return |
467 return |
443 |
468 |
444 try: |
469 try: |
445 f = open(fname, "w", encoding="utf-8") |
470 f = open(fname, "w", encoding="utf-8") |
446 f.write(template) |
471 f.write(template) |
447 f.close() |
472 f.close() |
448 except IOError as e: |
473 except IOError as e: |
449 E5MessageBox.critical(self, |
474 E5MessageBox.critical( |
|
475 self.__ui, |
450 self.trUtf8("New Form"), |
476 self.trUtf8("New Form"), |
451 self.trUtf8("<p>The new form file <b>{0}</b> could not be" |
477 self.trUtf8("<p>The new form file <b>{0}</b> could" |
452 " created.<br/>" |
478 " not be created.<br/> Problem: {1}</p>") |
453 "Problem: {1}</p>").format(fname, e)) |
479 .format(fname, e)) |
454 return |
480 return |
455 |
481 |
456 self.__e5project.appendFile(fname) |
482 self.__e5project.appendFile(fname) |
457 self.__formsBrowser.sourceFile.emit(fname) |
483 self.__formsBrowser.sourceFile.emit(fname) |
458 |
484 |
694 if simulate: |
722 if simulate: |
695 args.append("--simulate") |
723 args.append("--simulate") |
696 args.append("--scaffold={0}".format(scaffold)) |
724 args.append("--scaffold={0}".format(scaffold)) |
697 args.append(project) |
725 args.append(project) |
698 dlg = PyramidDialog(self.trUtf8("Create Pyramid Project"), |
726 dlg = PyramidDialog(self.trUtf8("Create Pyramid Project"), |
699 linewrap=False, parent=self.__ui) |
727 linewrap=False, parent=self.__ui) |
700 if dlg.startProcess(cmd, args, self.__e5project.getProjectPath()): |
728 if dlg.startProcess(cmd, args, self.__e5project.getProjectPath()): |
701 dlg.exec_() |
729 dlg.exec_() |
702 if dlg.normalExit() and not simulate: |
730 if dlg.normalExit() and not simulate: |
703 # search for files created by pcreate and add them to the project |
731 # search for files created by pcreate and add them to the |
704 projectPath = os.path.join(self.__e5project.getProjectPath(), project) |
732 # project |
|
733 projectPath = os.path.join( |
|
734 self.__e5project.getProjectPath(), project) |
705 for entry in os.walk(projectPath): |
735 for entry in os.walk(projectPath): |
706 for fileName in entry[2]: |
736 for fileName in entry[2]: |
707 fullName = os.path.join(entry[0], fileName) |
737 fullName = os.path.join(entry[0], fileName) |
708 self.__e5project.appendFile(fullName) |
738 self.__e5project.appendFile(fullName) |
709 |
739 |
710 # create the base directory for translations |
740 # create the base directory for translations |
711 i18nPath = os.path.join(projectPath, project.lower(), "i18n") |
741 i18nPath = os.path.join( |
|
742 projectPath, project.lower(), "i18n") |
712 if not os.path.exists(i18nPath): |
743 if not os.path.exists(i18nPath): |
713 os.makedirs(i18nPath) |
744 os.makedirs(i18nPath) |
714 self.__e5project.setDirty(True) |
745 self.__e5project.setDirty(True) |
715 |
746 |
716 self.__setCurrentProject(project) |
747 self.__setCurrentProject(project) |
899 Private slot to start the default web browser with the server URL. |
932 Private slot to start the default web browser with the server URL. |
900 """ |
933 """ |
901 try: |
934 try: |
902 projectPath = self.__projectPath() |
935 projectPath = self.__projectPath() |
903 except PyramidNoProjectSelectedException: |
936 except PyramidNoProjectSelectedException: |
904 E5MessageBox.warning(self.__ui, |
937 E5MessageBox.warning( |
|
938 self.__ui, |
905 self.trUtf8('Run Web-Browser'), |
939 self.trUtf8('Run Web-Browser'), |
906 self.trUtf8('No current Pyramid project selected or no Pyramid project' |
940 self.trUtf8('No current Pyramid project selected or no Pyramid' |
907 ' created yet. Aborting...')) |
941 ' project created yet. Aborting...')) |
908 return |
942 return |
909 |
943 |
910 config = configparser.ConfigParser() |
944 config = configparser.ConfigParser() |
911 config.read(os.path.join(projectPath, "development.ini")) |
945 config.read(os.path.join(projectPath, "development.ini")) |
912 port = config.get("server:main", "port", fallback="6543") |
946 port = config.get("server:main", "port", fallback="6543") |
913 url = QUrl("http://localhost:{0}".format(port)) |
947 url = QUrl("http://localhost:{0}".format(port)) |
914 res = QDesktopServices.openUrl(url) |
948 res = QDesktopServices.openUrl(url) |
915 if not res: |
949 if not res: |
916 E5MessageBox.critical(self.__ui, |
950 E5MessageBox.critical( |
|
951 self.__ui, |
917 self.trUtf8('Run Web-Browser'), |
952 self.trUtf8('Run Web-Browser'), |
918 self.trUtf8('Could not start the web-browser for the URL "{0}".')\ |
953 self.trUtf8('Could not start the web-browser for the URL' |
919 .format(url.toString())) |
954 ' "{0}".').format(url.toString())) |
920 |
955 |
921 def __runPythonShell(self): |
956 def __runPythonShell(self): |
922 """ |
957 """ |
923 Private slot to start a Python console for a Pyramid project. |
958 Private slot to start a Python console for a Pyramid project. |
924 """ |
959 """ |
926 self.__plugin.getPreferences("ConsoleCommand"))[1] |
961 self.__plugin.getPreferences("ConsoleCommand"))[1] |
927 if consoleCmd: |
962 if consoleCmd: |
928 try: |
963 try: |
929 projectPath = self.__projectPath() |
964 projectPath = self.__projectPath() |
930 except PyramidNoProjectSelectedException: |
965 except PyramidNoProjectSelectedException: |
931 E5MessageBox.warning(self.__ui, |
966 E5MessageBox.warning( |
|
967 self.__ui, |
932 self.trUtf8('Start Pyramid Python Console'), |
968 self.trUtf8('Start Pyramid Python Console'), |
933 self.trUtf8('No current Pyramid project selected or no Pyramid ' |
969 self.trUtf8('No current Pyramid project selected or no' |
934 'project created yet. Aborting...')) |
970 ' Pyramid project created yet. Aborting...')) |
935 return |
971 return |
936 |
972 |
937 args = Utilities.parseOptionString(consoleCmd) |
973 args = Utilities.parseOptionString(consoleCmd) |
938 args[0] = Utilities.getExecutablePath(args[0]) |
974 args[0] = Utilities.getExecutablePath(args[0]) |
939 args.append(self.getPyramidCommand("pshell")) |
975 args.append(self.getPyramidCommand("pshell")) |
940 language = self.__e5project.getProjectLanguage() |
976 language = self.__e5project.getProjectLanguage() |
941 if language == "Python2": |
977 if language == "Python2": |
942 consoleType = self.__plugin.getPreferences("Python2ConsoleType") |
978 consoleType = self.__plugin.getPreferences( |
|
979 "Python2ConsoleType") |
943 else: |
980 else: |
944 consoleType = self.__plugin.getPreferences("Python3ConsoleType") |
981 consoleType = self.__plugin.getPreferences( |
|
982 "Python3ConsoleType") |
945 args.append("--python-shell={0}".format(consoleType)) |
983 args.append("--python-shell={0}".format(consoleType)) |
946 args.append(os.path.join(projectPath, "development.ini")) |
984 args.append(os.path.join(projectPath, "development.ini")) |
947 |
985 |
948 started, pid = QProcess.startDetached(args[0], args[1:], projectPath) |
986 started, pid = QProcess.startDetached( |
|
987 args[0], args[1:], projectPath) |
949 if not started: |
988 if not started: |
950 E5MessageBox.critical(self.__ui, |
989 E5MessageBox.critical( |
|
990 self.__ui, |
951 self.trUtf8('Process Generation Error'), |
991 self.trUtf8('Process Generation Error'), |
952 self.trUtf8('The Pyramid Shell process could not be started.')) |
992 self.trUtf8('The Pyramid Shell process could not be' |
|
993 ' started.')) |
953 |
994 |
954 ################################################################## |
995 ################################################################## |
955 ## slots below implement setup functions |
996 ## slots below implement setup functions |
956 ################################################################## |
997 ################################################################## |
957 |
998 |
958 def __setupDevelop(self): |
999 def __setupDevelop(self): |
959 """ |
1000 """ |
960 Private slot to set up the development environment for the current project. |
1001 Private slot to set up the development environment for the current |
|
1002 project. |
961 """ |
1003 """ |
962 title = self.trUtf8("Setup Development Environment") |
1004 title = self.trUtf8("Setup Development Environment") |
963 try: |
1005 try: |
964 wd = self.__projectPath() |
1006 wd = self.__projectPath() |
965 except PyramidNoProjectSelectedException: |
1007 except PyramidNoProjectSelectedException: |
966 E5MessageBox.warning(self.__ui, |
1008 E5MessageBox.warning( |
|
1009 self.__ui, |
967 title, |
1010 title, |
968 self.trUtf8('No current Pyramid project selected or no Pyramid project' |
1011 self.trUtf8('No current Pyramid project selected or no Pyramid' |
969 ' created yet. Aborting...')) |
1012 ' project created yet. Aborting...')) |
970 return |
1013 return |
971 |
1014 |
972 cmd = self.getPythonCommand() |
1015 cmd = self.getPythonCommand() |
973 args = [] |
1016 args = [] |
974 args.append("setup.py") |
1017 args.append("setup.py") |
975 args.append("develop") |
1018 args.append("develop") |
976 |
1019 |
977 dia = PyramidDialog(title, |
1020 dia = PyramidDialog( |
978 msgSuccess=self.trUtf8("Pyramid development environment setup successfully.")) |
1021 title, |
|
1022 msgSuccess=self.trUtf8("Pyramid development environment setup" |
|
1023 " successfully.")) |
979 res = dia.startProcess(cmd, args, wd) |
1024 res = dia.startProcess(cmd, args, wd) |
980 if res: |
1025 if res: |
981 dia.exec_() |
1026 dia.exec_() |
982 |
1027 |
983 ################################################################## |
1028 ################################################################## |
984 ## slots below implement distribution functions |
1029 ## slots below implement distribution functions |
985 ################################################################## |
1030 ################################################################## |
986 |
1031 |
987 def __buildDistribution(self): |
1032 def __buildDistribution(self): |
988 """ |
1033 """ |
989 Private slot to build a distribution file for the current Pyramid project. |
1034 Private slot to build a distribution file for the current Pyramid |
|
1035 project. |
990 """ |
1036 """ |
991 title = self.trUtf8("Build Distribution File") |
1037 title = self.trUtf8("Build Distribution File") |
992 try: |
1038 try: |
993 projectPath = self.__projectPath() |
1039 projectPath = self.__projectPath() |
994 except PyramidNoProjectSelectedException: |
1040 except PyramidNoProjectSelectedException: |
995 E5MessageBox.warning(self.__ui, |
1041 E5MessageBox.warning( |
|
1042 self.__ui, |
996 title, |
1043 title, |
997 self.trUtf8('No current Pyramid project selected or no Pyramid project' |
1044 self.trUtf8('No current Pyramid project selected or no Pyramid' |
998 ' created yet. Aborting...')) |
1045 ' project created yet. Aborting...')) |
999 return |
1046 return |
1000 |
1047 |
1001 from .DistributionTypeSelectionDialog import DistributionTypeSelectionDialog |
1048 from .DistributionTypeSelectionDialog import \ |
|
1049 DistributionTypeSelectionDialog |
1002 |
1050 |
1003 dlg = DistributionTypeSelectionDialog(self, projectPath, self.__ui) |
1051 dlg = DistributionTypeSelectionDialog(self, projectPath, self.__ui) |
1004 if dlg.exec_() == QDialog.Accepted: |
1052 if dlg.exec_() == QDialog.Accepted: |
1005 formats = dlg.getFormats() |
1053 formats = dlg.getFormats() |
1006 cmd = self.getPythonCommand() |
1054 cmd = self.getPythonCommand() |
1028 """ |
1078 """ |
1029 try: |
1079 try: |
1030 cmd = "initialize_{0}_db".format(self.__project()) |
1080 cmd = "initialize_{0}_db".format(self.__project()) |
1031 return self.getPyramidCommand(cmd) |
1081 return self.getPyramidCommand(cmd) |
1032 except PyramidNoProjectSelectedException: |
1082 except PyramidNoProjectSelectedException: |
1033 E5MessageBox.warning(self.__ui, |
1083 E5MessageBox.warning( |
|
1084 self.__ui, |
1034 self.trUtf8("Initialize Database"), |
1085 self.trUtf8("Initialize Database"), |
1035 self.trUtf8('No current Pyramid project selected or no Pyramid project' |
1086 self.trUtf8('No current Pyramid project selected or no Pyramid' |
1036 ' created yet. Aborting...')) |
1087 ' project created yet. Aborting...')) |
1037 return "" |
1088 return "" |
1038 |
1089 |
1039 def __initializeDatabase(self): |
1090 def __initializeDatabase(self): |
1040 """ |
1091 """ |
1041 Private slot to initialize the database of the Pyramid project. |
1092 Private slot to initialize the database of the Pyramid project. |
1042 """ |
1093 """ |
1043 title = self.trUtf8("Initialize Database") |
1094 title = self.trUtf8("Initialize Database") |
1044 try: |
1095 try: |
1045 projectPath = self.__projectPath() |
1096 projectPath = self.__projectPath() |
1046 except PyramidNoProjectSelectedException: |
1097 except PyramidNoProjectSelectedException: |
1047 E5MessageBox.warning(self.__ui, |
1098 E5MessageBox.warning( |
|
1099 self.__ui, |
1048 title, |
1100 title, |
1049 self.trUtf8('No current Pyramid project selected or no Pyramid project' |
1101 self.trUtf8('No current Pyramid project selected or no Pyramid' |
1050 ' created yet. Aborting...')) |
1102 ' project created yet. Aborting...')) |
1051 return |
1103 return |
1052 |
1104 |
1053 cmd = self.__getInitDbCommand() |
1105 cmd = self.__getInitDbCommand() |
1054 args = [] |
1106 args = [] |
1055 args.append("development.ini") |
1107 args.append("development.ini") |
1056 |
1108 |
1057 dia = PyramidDialog(title, |
1109 dia = PyramidDialog( |
|
1110 title, |
1058 msgSuccess=self.trUtf8("Database initialized successfully.")) |
1111 msgSuccess=self.trUtf8("Database initialized successfully.")) |
1059 res = dia.startProcess(cmd, args, projectPath) |
1112 res = dia.startProcess(cmd, args, projectPath) |
1060 if res: |
1113 if res: |
1061 dia.exec_() |
1114 dia.exec_() |
1062 |
1115 |
1214 """ |
1270 """ |
1215 title = self.trUtf8("Extract messages") |
1271 title = self.trUtf8("Extract messages") |
1216 try: |
1272 try: |
1217 projectPath = self.__projectPath() |
1273 projectPath = self.__projectPath() |
1218 except PyramidNoProjectSelectedException: |
1274 except PyramidNoProjectSelectedException: |
1219 E5MessageBox.warning(self.__ui, |
1275 E5MessageBox.warning( |
|
1276 self.__ui, |
1220 title, |
1277 title, |
1221 self.trUtf8('No current Pyramid project selected or no Pyramid project' |
1278 self.trUtf8('No current Pyramid project selected or no Pyramid' |
1222 ' created yet. Aborting...')) |
1279 ' project created yet. Aborting...')) |
1223 return |
1280 return |
1224 |
1281 |
1225 cmd = self.getPythonCommand() |
1282 cmd = self.getPythonCommand() |
1226 args = [] |
1283 args = [] |
1227 args.append("setup.py") |
1284 args.append("setup.py") |
1228 args.append("extract_messages") |
1285 args.append("extract_messages") |
1229 |
1286 |
1230 dia = PyramidDialog(title, |
1287 dia = PyramidDialog( |
|
1288 title, |
1231 msgSuccess=self.trUtf8("\nMessages extracted successfully.")) |
1289 msgSuccess=self.trUtf8("\nMessages extracted successfully.")) |
1232 res = dia.startProcess(cmd, args, projectPath) |
1290 res = dia.startProcess(cmd, args, projectPath) |
1233 if res: |
1291 if res: |
1234 dia.exec_() |
1292 dia.exec_() |
1235 |
1293 |
1240 self.__e5project.appendFile(os.path.join(projectPath, potFile)) |
1298 self.__e5project.appendFile(os.path.join(projectPath, potFile)) |
1241 else: |
1299 else: |
1242 try: |
1300 try: |
1243 lowerProject = self.__project().lower() |
1301 lowerProject = self.__project().lower() |
1244 except PyramidNoProjectSelectedException: |
1302 except PyramidNoProjectSelectedException: |
1245 E5MessageBox.warning(self.__ui, |
1303 E5MessageBox.warning( |
|
1304 self.__ui, |
1246 title, |
1305 title, |
1247 self.trUtf8('No current Pyramid project selected or no Pyramid' |
1306 self.trUtf8('No current Pyramid project selected or no' |
1248 ' project created yet. Aborting...')) |
1307 ' Pyramid project created yet.' |
|
1308 ' Aborting...')) |
1249 return |
1309 return |
1250 |
1310 |
1251 self.__e5project.appendFile(os.path.join( |
1311 self.__e5project.appendFile(os.path.join( |
1252 projectPath, lowerProject, "locale", "%s.pot" % lowerProject)) |
1312 projectPath, lowerProject, "locale", |
|
1313 "{0}.pot".format(lowerProject))) |
1253 |
1314 |
1254 def __projectLanguageAdded(self, code): |
1315 def __projectLanguageAdded(self, code): |
1255 """ |
1316 """ |
1256 Private slot handling the addition of a new language. |
1317 Private slot handling the addition of a new language. |
1257 |
1318 |
1258 @param code language code of the new language (string) |
1319 @param code language code of the new language (string) |
1259 """ |
1320 """ |
1260 title = self.trUtf8("Initializing message catalog for '{0}'").format(code) |
1321 title = self.trUtf8("Initializing message catalog for '{0}'")\ |
|
1322 .format(code) |
1261 try: |
1323 try: |
1262 projectPath = self.__projectPath() |
1324 projectPath = self.__projectPath() |
1263 except PyramidNoProjectSelectedException: |
1325 except PyramidNoProjectSelectedException: |
1264 E5MessageBox.warning(self.__ui, |
1326 E5MessageBox.warning( |
|
1327 self.__ui, |
1265 title, |
1328 title, |
1266 self.trUtf8('No current Pyramid project selected or no Pyramid project' |
1329 self.trUtf8('No current Pyramid project selected or no Pyramid' |
1267 ' created yet. Aborting...')) |
1330 ' project created yet. Aborting...')) |
1268 return |
1331 return |
1269 |
1332 |
1270 cmd = self.getPythonCommand() |
1333 cmd = self.getPythonCommand() |
1271 args = [] |
1334 args = [] |
1272 args.append("setup.py") |
1335 args.append("setup.py") |
1273 args.append("init_catalog") |
1336 args.append("init_catalog") |
1274 args.append("-l") |
1337 args.append("-l") |
1275 args.append(code) |
1338 args.append(code) |
1276 |
1339 |
1277 dia = PyramidDialog(title, |
1340 dia = PyramidDialog( |
1278 msgSuccess=self.trUtf8("\nMessage catalog initialized successfully.")) |
1341 title, |
|
1342 msgSuccess=self.trUtf8("\nMessage catalog initialized" |
|
1343 " successfully.")) |
1279 res = dia.startProcess(cmd, args, projectPath) |
1344 res = dia.startProcess(cmd, args, projectPath) |
1280 if res: |
1345 if res: |
1281 dia.exec_() |
1346 dia.exec_() |
1282 |
1347 |
1283 langFile = self.__e4project.pdata["TRANSLATIONPATTERN"][0]\ |
1348 langFile = self.__e4project.pdata["TRANSLATIONPATTERN"][0]\ |
1292 """ |
1357 """ |
1293 title = self.trUtf8("Compiling message catalogs") |
1358 title = self.trUtf8("Compiling message catalogs") |
1294 try: |
1359 try: |
1295 projectPath = self.__projectPath() |
1360 projectPath = self.__projectPath() |
1296 except PyramidNoProjectSelectedException: |
1361 except PyramidNoProjectSelectedException: |
1297 E5MessageBox.warning(self.__ui, |
1362 E5MessageBox.warning( |
|
1363 self.__ui, |
1298 title, |
1364 title, |
1299 self.trUtf8('No current Pyramid project selected or no Pyramid project' |
1365 self.trUtf8('No current Pyramid project selected or no Pyramid' |
1300 ' created yet. Aborting...')) |
1366 ' project created yet. Aborting...')) |
1301 return |
1367 return |
1302 |
1368 |
1303 cmd = self.getPythonCommand() |
1369 cmd = self.getPythonCommand() |
1304 args = [] |
1370 args = [] |
1305 args.append("setup.py") |
1371 args.append("setup.py") |
1306 args.append("compile_catalog") |
1372 args.append("compile_catalog") |
1307 |
1373 |
1308 dia = PyramidDialog(title, |
1374 dia = PyramidDialog( |
1309 msgSuccess=self.trUtf8("\nMessage catalogs compiled successfully.")) |
1375 title, |
|
1376 msgSuccess=self.trUtf8("\nMessage catalogs compiled" |
|
1377 " successfully.")) |
1310 res = dia.startProcess(cmd, args, projectPath) |
1378 res = dia.startProcess(cmd, args, projectPath) |
1311 if res: |
1379 if res: |
1312 dia.exec_() |
1380 dia.exec_() |
1313 |
1381 |
1314 for entry in os.walk(projectPath): |
1382 for entry in os.walk(projectPath): |
1372 """ |
1445 """ |
1373 title = self.trUtf8("Updating message catalogs") |
1446 title = self.trUtf8("Updating message catalogs") |
1374 try: |
1447 try: |
1375 projectPath = self.__projectPath() |
1448 projectPath = self.__projectPath() |
1376 except PyramidNoProjectSelectedException: |
1449 except PyramidNoProjectSelectedException: |
1377 E5MessageBox.warning(self.__ui, |
1450 E5MessageBox.warning( |
|
1451 self.__ui, |
1378 title, |
1452 title, |
1379 self.trUtf8('No current Pyramid project selected or no Pyramid project' |
1453 self.trUtf8('No current Pyramid project selected or no Pyramid' |
1380 ' created yet. Aborting...')) |
1454 ' project created yet. Aborting...')) |
1381 return |
1455 return |
1382 |
1456 |
1383 cmd = self.getPythonCommand() |
1457 cmd = self.getPythonCommand() |
1384 args = [] |
1458 args = [] |
1385 args.append("setup.py") |
1459 args.append("setup.py") |
1386 args.append("update_catalog") |
1460 args.append("update_catalog") |
1387 |
1461 |
1388 dia = PyramidDialog(title, |
1462 dia = PyramidDialog( |
|
1463 title, |
1389 msgSuccess=self.trUtf8("\nMessage catalogs updated successfully.")) |
1464 msgSuccess=self.trUtf8("\nMessage catalogs updated successfully.")) |
1390 res = dia.startProcess(cmd, args, projectPath) |
1465 res = dia.startProcess(cmd, args, projectPath) |
1391 if res: |
1466 if res: |
1392 dia.exec_() |
1467 dia.exec_() |
1393 |
1468 |