def find_julia_version(self):
     julia_path = self._toolbox.qsettings().value("appSettings/juliaPath",
                                                  defaultValue="")
     if julia_path != "":
         self.julia_exe = julia_path
     else:
         self.julia_exe = JULIA_EXECUTABLE
     self.julia_project_path = self._toolbox.qsettings().value(
         "appSettings/juliaProjectPath", defaultValue="")
     if self.julia_project_path == "":
         self.julia_project_path = "@."
     args = list()
     args.append("-e")
     args.append("println(VERSION)")
     exec_mngr = QProcessExecutionManager(self._toolbox,
                                          self.julia_exe,
                                          args,
                                          silent=True)
     exec_mngr.start_execution()
     if exec_mngr.wait_for_process_finished(msecs=5000):
         self._julia_version = exec_mngr.process_output
     args = list()
     args.append(f"--project={self.julia_project_path}")
     args.append("-e")
     args.append("println(Base.active_project())")
     exec_mngr = QProcessExecutionManager(self._toolbox,
                                          self.julia_exe,
                                          args,
                                          silent=True)
     exec_mngr.start_execution()
     if exec_mngr.wait_for_process_finished(msecs=5000):
         self._julia_active_project = exec_mngr.process_output
 def test_execute_python_interpreter(self):
     program = sys.executable
     logger = MagicMock()
     manager = QProcessExecutionManager(logger, program, args=["--version"])
     manager.start_execution()
     self.assertTrue(manager.wait_for_process_finished())
     self.assertFalse(manager.process_failed_to_start)
     self.assertFalse(manager.process_failed)
 def find_julia_version(self):
     args = list()
     args.append("-e")
     args.append("println(VERSION)")
     exec_mngr = QProcessExecutionManager(self._toolbox,
                                          self.julia_exe,
                                          args,
                                          silent=True)
     exec_mngr.start_execution()
     if exec_mngr.wait_for_process_finished(msecs=5000):
         self._julia_version = exec_mngr.process_output
     args = list()
     args.append(f"--project={self.julia_project_path}")
     args.append("-e")
     args.append("println(Base.active_project())")
     exec_mngr = QProcessExecutionManager(self._toolbox,
                                          self.julia_exe,
                                          args,
                                          silent=True)
     exec_mngr.start_execution()
     if exec_mngr.wait_for_process_finished(msecs=5000):
         self._julia_active_project = exec_mngr.process_output
示例#4
0
def python_exists(program, logger):
    """Checks that Python is set up correctly in Settings.
    This executes 'python -V' in a QProcess and if the process
    finishes successfully, the python is ready to be used.

    Args:
        program (str): Python executable to check
        logger (LoggerInterface)

    Returns:
        bool: True if Python is found, False otherwise
    """
    args = ["-V"]
    python_check_process = QProcessExecutionManager(logger,
                                                    program,
                                                    args,
                                                    silent=True)
    python_check_process.start_execution()
    if not python_check_process.wait_for_process_finished(msecs=3000):
        logger.msg_error.emit(
            "Couldn't execute Python. Please check the <b>Python interpreter</b> option in Settings."
        )
        return False
    return True
 def test_execute_nothing(self):
     logger = MagicMock()
     manager = QProcessExecutionManager(logger)
     manager.start_execution()
     self.assertFalse(manager.wait_for_process_finished())
     self.assertTrue(manager.process_failed_to_start)