diff --git a/finalcif/appwindow.py b/finalcif/appwindow.py index d49120a0..2b16e252 100644 --- a/finalcif/appwindow.py +++ b/finalcif/appwindow.py @@ -12,6 +12,7 @@ from datetime import datetime from math import sin, radians from pathlib import Path, WindowsPath +from shutil import which from typing import Union, Dict, Tuple, List, Optional import gemmi.cif @@ -1009,7 +1010,7 @@ def do_offline_checkcif(self) -> None: log_widget=self.ui.CheckCifLogPlainTextEdit, output_widget=self.ui.CheckcifPlaintextEdit, cif_file=self.cif.fileobj) - if not Path(runner.platon_exe).resolve().exists(): + if not Path(which(runner.platon_exe)).exists(): self.ui.CheckCifLogPlainTextEdit.setPlainText('\nPlaton executable not found!') self.ui.CheckCifLogPlainTextEdit.appendPlainText('You can download Platon at http://www.platonsoft.nl/platon/\n') runner.tick.connect(self.append_to_ciflog_without_newline) diff --git a/finalcif/tools/process.py b/finalcif/tools/process.py index bb011998..d38041e4 100644 --- a/finalcif/tools/process.py +++ b/finalcif/tools/process.py @@ -30,7 +30,7 @@ def __init__(self, parent, output_widget: QPlainTextEdit, log_widget: QPlainText def run_process(self): self._origdir = os.curdir - os.chdir(self.cif_file.parent) + #os.chdir(self.cif_file.parent) self.formula_moiety = '' self.Z = '' self.process = QProcess() @@ -38,12 +38,13 @@ def run_process(self): threading.Thread(target=self._monitor_output_log).start() # self.process.readyReadStandardOutput.connect(self.on_ready_read) self.process.finished.connect(self._onfinished) + self.process.setWorkingDirectory(str(self.cif_file.parent)) self.cif_file.with_suffix('.chk').unlink(missing_ok=True) self.process.start(self.platon_exe, ["-U", str(self.cif_file.name)]) def _onfinished(self): self._on_ready_read() - os.chdir(self._origdir) + #os.chdir(self._origdir) self._parse_chk_file() self.output_widget.setPlainText(self.chk_file_text) self.finished.emit(True)