From 258fad3a4556915c9fba9981e52fd1289071f7f8 Mon Sep 17 00:00:00 2001 From: rahulp13 Date: Mon, 20 Apr 2020 11:45:43 +0530 Subject: resolves issue with netlist path --- src/ngspicetoModelica/ModelicaUI.py | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) (limited to 'src/ngspicetoModelica/ModelicaUI.py') diff --git a/src/ngspicetoModelica/ModelicaUI.py b/src/ngspicetoModelica/ModelicaUI.py index aa7cb330..f8889cce 100644 --- a/src/ngspicetoModelica/ModelicaUI.py +++ b/src/ngspicetoModelica/ModelicaUI.py @@ -1,4 +1,5 @@ import os +import traceback from PyQt4 import QtGui, QtCore from configuration.Appconfig import Appconfig from projManagement import Worker @@ -45,7 +46,7 @@ class OpenModelicaEditor(QtGui.QWidget): def browseFile(self): self.ngspiceNetlist = QtGui.QFileDialog.getOpenFileName( - self, 'Open Ngspice file', BROWSE_LOCATION) + self, 'Open Ngspice Netlist', BROWSE_LOCATION) self.FileEdit.setText(self.ngspiceNetlist) def callConverter(self): @@ -158,9 +159,11 @@ class OpenModelicaEditor(QtGui.QWidget): ) # Adding 'numNodesSub' by Fahim # Creating Final Output file - newfile = self.ngspiceNetlist.split('.') - newfilename = newfile[0] + fileDir = os.path.dirname(self.ngspiceNetlist) + newfile = os.path.basename(self.ngspiceNetlist) + newfilename = os.path.join(fileDir, newfile.split('.')[0]) outfile = newfilename + ".mo" + out = open(outfile, "w") out.writelines('model ' + os.path.basename(newfilename)) out.writelines('\n') @@ -207,24 +210,25 @@ class OpenModelicaEditor(QtGui.QWidget): self.msg = QtGui.QMessageBox() self.msg.setText( - "Ngspice netlist successfully converted to OpenModelica" + + "Ngspice netlist successfully converted to OpenModelica " + "netlist" ) self.obj_appconfig.print_info( - "Ngspice netlist successfully converted to OpenModelica" + + "Ngspice netlist successfully converted to OpenModelica " + "netlist" ) self.msg.exec_() - except Exception as e: + except BaseException as e: + traceback.print_exc() + print("================") self.msg = QtGui.QErrorMessage() self.msg.setModal(True) - self.msg.setWindowTitle("Ngspice to Modelica conversion error") + self.msg.setWindowTitle("Conversion Error") self.msg.showMessage( - 'Unable to convert NgSpice netlist to Modelica netlist.' + - 'Check the netlist :' + - str(e)) - self.msg.setWindowTitle("Ngspice to Modelica conversion error") + 'Unable to convert Ngspice netlist to Modelica netlist. ' + + 'Check the netlist : ' + repr(e) + ) def callOMEdit(self): -- cgit