diff options
Diffstat (limited to 'src/converter/LtspiceLibConverter.py')
-rw-r--r-- | src/converter/LtspiceLibConverter.py | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/src/converter/LtspiceLibConverter.py b/src/converter/LtspiceLibConverter.py index 1914f8ba..2f652659 100644 --- a/src/converter/LtspiceLibConverter.py +++ b/src/converter/LtspiceLibConverter.py @@ -18,15 +18,24 @@ class LTspiceLibConverter: script_dir = os.path.dirname(os.path.abspath(__file__)) # Define the relative path to parser.py from the current script's directory - relative_parser_path = "LTSpiceToKiCadConverter/src/Ubuntu" + # Check the current operating system + if os.name == 'nt': # Windows + relative_parser_path = "LTSpiceToKiCadConverter/src/Windows" + else: + relative_parser_path = "LTSpiceToKiCadConverter/src/Ubuntu" + + # Construct the full path to libParser.py parser_path = os.path.join(script_dir, relative_parser_path) print(parser_path) - command = f"cd {parser_path} ; python3 lib_LTspice2Kicad.py {file_path}" - print(f"cd {parser_path} ; python3 lib_LTspice2Kicad.py {file_path}") + # Strip the .asy extension + file_path_no_ext = os.path.splitext(file_path)[0] + command = ["python3", "lib_LTspice2Kicad.py", file_path_no_ext] + print("Running command:", " ".join(command), "in", parser_path) try: - subprocess.run(command, shell=True, check=True) + subprocess.run(command, check=True, cwd=parser_path) + # Message box with the conversion success message msg_box = QMessageBox() msg_box.setIcon(QMessageBox.Information) @@ -81,4 +90,4 @@ class LTspiceLibConverter: msg_box.setWindowTitle("No File Selected") msg_box.setText("Please select a file before uploading.") msg_box.setStandardButtons(QMessageBox.Ok) - msg_box.exec_()
\ No newline at end of file + msg_box.exec_() |