349 |
349 |
350 self.__e5project.appendFile(fname) |
350 self.__e5project.appendFile(fname) |
351 self.__formsBrowser.sourceFile.emit(fname) |
351 self.__formsBrowser.sourceFile.emit(fname) |
352 |
352 |
353 ################################################################## |
353 ################################################################## |
354 ## slots below implement general functionality |
354 ## methods below implement virtual environment handling |
|
355 ################################################################## |
|
356 |
|
357 def getVirtualEnvironment(self): |
|
358 """ |
|
359 Private method to get the path of the virtual environment. |
|
360 |
|
361 @return path of the virtual environment |
|
362 @rtype str |
|
363 """ |
|
364 language = self.__e5project.getProjectLanguage() |
|
365 if language == "Python3": |
|
366 venvName = self.__plugin.getPreferences( |
|
367 "VirtualEnvironmentNamePy3") |
|
368 else: |
|
369 venvName = "" |
|
370 if venvName: |
|
371 virtEnv = self.__virtualEnvManager.getVirtualenvDirectory( |
|
372 venvName) |
|
373 else: |
|
374 virtEnv = "" |
|
375 |
|
376 if virtEnv and not os.path.exists(virtEnv): |
|
377 virtEnv = "" |
|
378 |
|
379 return virtEnv # __IGNORE_WARNING_M834__ |
|
380 |
|
381 def getVirtualenvInterpreter(self): |
|
382 """ |
|
383 Public method to get the path of the Python interpreter to be used |
|
384 with the current project. |
|
385 |
|
386 @return path of the Python interpreter |
|
387 @rtype str |
|
388 """ |
|
389 return self.getFullCommand("python") |
|
390 |
|
391 def getFullCommand(self, command): |
|
392 """ |
|
393 Public method to get the full command for a given command name. |
|
394 |
|
395 @param command command name |
|
396 @type str |
|
397 @return full command |
|
398 @rtype str |
|
399 """ |
|
400 virtualEnv = self.getVirtualEnvironment() |
|
401 if isWindowsPlatform(): |
|
402 fullCmds = [ |
|
403 os.path.join(virtualEnv, "Scripts", command + '.exe'), |
|
404 os.path.join(virtualEnv, "bin", command + '.exe'), |
|
405 command # fall back to just cmd |
|
406 ] |
|
407 else: |
|
408 fullCmds = [ |
|
409 os.path.join(virtualEnv, "bin", command), |
|
410 os.path.join(virtualEnv, "local", "bin", command), |
|
411 Utilities.getExecutablePath(command), |
|
412 command # fall back to just cmd |
|
413 ] |
|
414 for command in fullCmds: |
|
415 if os.path.exists(command): |
|
416 break |
|
417 return command |
|
418 |
|
419 ################################################################## |
|
420 ## methods below implement general functionality |
355 ################################################################## |
421 ################################################################## |
356 |
422 |
357 def projectClosed(self): |
423 def projectClosed(self): |
358 """ |
424 """ |
359 Public method to handle the closing of a project. |
425 Public method to handle the closing of a project. |
412 "{0}.".format(variant[-1]) in l0) |
478 "{0}.".format(variant[-1]) in l0) |
413 ok |= "pypy3" in l0 |
479 ok |= "pypy3" in l0 |
414 |
480 |
415 return ok |
481 return ok |
416 |
482 |
417 def __getVirtualEnvironment(self): |
|
418 """ |
|
419 Private method to get the path of the virtual environment. |
|
420 |
|
421 @return path of the virtual environment |
|
422 @rtype str |
|
423 """ |
|
424 language = self.__e5project.getProjectLanguage() |
|
425 if language == "Python3": |
|
426 venvName = self.__plugin.getPreferences( |
|
427 "VirtualEnvironmentNamePy3") |
|
428 else: |
|
429 venvName = "" |
|
430 if venvName: |
|
431 virtEnv = self.__virtualEnvManager.getVirtualenvDirectory( |
|
432 venvName) |
|
433 else: |
|
434 virtEnv = "" |
|
435 |
|
436 if virtEnv and not os.path.exists(virtEnv): |
|
437 virtEnv = "" |
|
438 |
|
439 return virtEnv # __IGNORE_WARNING_M834__ |
|
440 |
|
441 def getFlaskCommand(self): |
483 def getFlaskCommand(self): |
442 """ |
484 """ |
443 Public method to build the Flask command. |
485 Public method to build the Flask command. |
444 |
486 |
445 @return full flask command |
487 @return full flask command |
446 @rtype str |
488 @rtype str |
447 """ |
489 """ |
448 return self.getFullCommand("flask") |
490 return self.getFullCommand("flask") |
449 |
|
450 def getFullCommand(self, command): |
|
451 """ |
|
452 Public method to get the full command for a given command name. |
|
453 |
|
454 @param command command name |
|
455 @type str |
|
456 @return full command |
|
457 @rtype str |
|
458 """ |
|
459 virtualEnv = self.__getVirtualEnvironment() |
|
460 if isWindowsPlatform(): |
|
461 fullCmds = [ |
|
462 os.path.join(virtualEnv, "Scripts", command + '.exe'), |
|
463 os.path.join(virtualEnv, "bin", command + '.exe'), |
|
464 command # fall back to just cmd |
|
465 ] |
|
466 else: |
|
467 fullCmds = [ |
|
468 os.path.join(virtualEnv, "bin", command), |
|
469 os.path.join(virtualEnv, "local", "bin", command), |
|
470 Utilities.getExecutablePath(command), |
|
471 command # fall back to just cmd |
|
472 ] |
|
473 for command in fullCmds: |
|
474 if os.path.exists(command): |
|
475 break |
|
476 return command |
|
477 |
491 |
478 @pyqtSlot() |
492 @pyqtSlot() |
479 def __flaskInfo(self): |
493 def __flaskInfo(self): |
480 """ |
494 """ |
481 Private slot to show some info about Flask. |
495 Private slot to show some info about Flask. |