Skip to content

Commit

Permalink
Do not do chdir
Browse files Browse the repository at this point in the history
  • Loading branch information
dkratzert committed Sep 10, 2023
1 parent a438500 commit 7286f7a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion finalcif/appwindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
5 changes: 3 additions & 2 deletions finalcif/tools/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,21 @@ 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()
self.output_widget.clear()
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)
Expand Down

0 comments on commit 7286f7a

Please sign in to comment.