From 2151c084526e98ad076357f59706829f36946512 Mon Sep 17 00:00:00 2001 From: Eyantra698Sumanto Date: Wed, 25 Aug 2021 18:17:23 +0530 Subject: Fixed Crash on closing Xterm while simulation running --- src/frontEnd/Application.py | 57 ++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 51 insertions(+), 6 deletions(-) diff --git a/src/frontEnd/Application.py b/src/frontEnd/Application.py index 94bce4ae..a260bda6 100644 --- a/src/frontEnd/Application.py +++ b/src/frontEnd/Application.py @@ -11,13 +11,14 @@ # NOTES: --- # AUTHOR: Fahim Khan, fahim.elex@gmail.com # MODIFIED: Rahul Paknikar, rahulp@iitb.ac.in +# Sumanto Kar, jeetsumanto123@gmail.com # ORGANIZATION: eSim Team at FOSSEE, IIT Bombay # CREATED: Tuesday 24 February 2015 -# REVISION: Sunday 13 December 2020 +# REVISION: Wednesday 25 August 2021 # ========================================================================= import os - +import traceback if os.name == 'nt': # noqa from frontEnd import pathmagic # noqa:F401 init_path = '' @@ -39,9 +40,11 @@ from PyQt5.Qt import QSize import shutil import time import sys - +import psutil # Its our main window of application. + + class Application(QtWidgets.QMainWindow): """This class initializes all objects used in this file.""" global project_name @@ -523,18 +526,60 @@ class Application(QtWidgets.QMainWindow): print("Current Project is : ", self.obj_appconfig.current_project) self.obj_Mainview.obj_dockarea.usermanual() + def checkIfProcessRunning(self, processName): + ''' + Check if there is any running process + that contains the given name processName. + ''' + # Iterate over the all the running process + for proc in psutil.process_iter(): + try: + # Check if process name contains the given name string. + if processName.lower() in proc.name().lower(): + return True + except (psutil.NoSuchProcess, + psutil.AccessDenied, psutil.ZombieProcess): + pass + return False + def open_ngspice(self): """This Function execute ngspice on current project.""" self.projDir = self.obj_appconfig.current_project["ProjectName"] if self.projDir is not None: - self.obj_Mainview.obj_dockarea.ngspiceEditor(self.projDir) + # Edited by Sumanto Kar 25/08/2021 + if self.obj_Mainview.obj_dockarea.ngspiceEditor( + self.projDir) is False: + print( + "No .cir.out file" + "Check netlist file to change simulation parameters." + ) + self.msg = QtWidgets.QErrorMessage() + self.msg.setModal(True) + self.msg.setWindowTitle("Warning Message") + self.msg.showMessage( + 'No .cir.out file' + ) + self.msg.exec_() + return currTime = time.time() count = 0 while True: try: + # Edited by Sumanto Kar 25/08/2021 st = os.stat(os.path.join(self.projDir, "plot_data_i.txt")) + if self.checkIfProcessRunning('xterm') is False: + self.msg = QtWidgets.QErrorMessage() + self.msg.setModal(True) + self.msg.setWindowTitle("Warning Message") + self.msg.showMessage( + 'Simulation was interuppted. ' + 'Please close all the Xterm windows.' + 'And then rerun the simulation' + ) + self.msg.exec_() + return if st.st_mtime >= currTime: break except Exception: @@ -543,7 +588,7 @@ class Application(QtWidgets.QMainWindow): # Fail Safe ===> count += 1 - if count >= 10: + if count >= 1000: print( "Ngspice taking too long for simulation. " "Check netlist file to change simulation parameters." @@ -572,7 +617,7 @@ class Application(QtWidgets.QMainWindow): ' Please look at console for more details.' ) self.msg.exec_() - print("Exception Message:", str(e)) + print("Exception Message:", str(e), traceback.format_exc()) self.obj_appconfig.print_error('Exception Message : ' + str(e)) else: -- cgit From efec9833774c8a8b3ad8dd36447881e6123fa8b7 Mon Sep 17 00:00:00 2001 From: Eyantra698Sumanto Date: Wed, 25 Aug 2021 18:19:04 +0530 Subject: Fixed Crash on .cir.out not found --- src/frontEnd/DockArea.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/frontEnd/DockArea.py b/src/frontEnd/DockArea.py index b96c468a..a446b833 100644 --- a/src/frontEnd/DockArea.py +++ b/src/frontEnd/DockArea.py @@ -122,7 +122,9 @@ class DockArea(QtWidgets.QMainWindow): self.projName = os.path.basename(self.projDir) self.ngspiceNetlist = os.path.join( self.projDir, self.projName + ".cir.out") - + # Edited by Sumanto Kar 25/08/2021 + if os.path.isfile(self.ngspiceNetlist) is False: + return False global count self.ngspiceWidget = QtWidgets.QWidget() @@ -322,3 +324,4 @@ class DockArea(QtWidgets.QMainWindow): self.temp = self.obj_appconfig.current_project['ProjectName'] for dockwidget in self.obj_appconfig.dock_dict[self.temp]: dockwidget.close() + -- cgit From 859a5e80688d98567735cf9fe95b856146517ef6 Mon Sep 17 00:00:00 2001 From: Eyantra698Sumanto Date: Wed, 25 Aug 2021 18:25:44 +0530 Subject: Resolved pep8 issue in DockArea.py --- src/frontEnd/DockArea.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/frontEnd/DockArea.py b/src/frontEnd/DockArea.py index a446b833..c1ed0588 100644 --- a/src/frontEnd/DockArea.py +++ b/src/frontEnd/DockArea.py @@ -324,4 +324,3 @@ class DockArea(QtWidgets.QMainWindow): self.temp = self.obj_appconfig.current_project['ProjectName'] for dockwidget in self.obj_appconfig.dock_dict[self.temp]: dockwidget.close() - -- cgit From 11567784e1f4bd344a0b95a77edf01eb89d55815 Mon Sep 17 00:00:00 2001 From: Eyantra698Sumanto Date: Tue, 25 Jan 2022 19:33:10 +0530 Subject: Fixed netlist name --- src/frontEnd/Application.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/frontEnd/Application.py b/src/frontEnd/Application.py index a260bda6..2620fc9c 100644 --- a/src/frontEnd/Application.py +++ b/src/frontEnd/Application.py @@ -551,7 +551,7 @@ class Application(QtWidgets.QMainWindow): if self.obj_Mainview.obj_dockarea.ngspiceEditor( self.projDir) is False: print( - "No .cir.out file" + "No netlist file (*.cir.out)" "Check netlist file to change simulation parameters." ) @@ -559,7 +559,7 @@ class Application(QtWidgets.QMainWindow): self.msg.setModal(True) self.msg.setWindowTitle("Warning Message") self.msg.showMessage( - 'No .cir.out file' + 'No netlist file (*.cir.out)' ) self.msg.exec_() return @@ -591,7 +591,8 @@ class Application(QtWidgets.QMainWindow): if count >= 1000: print( "Ngspice taking too long for simulation. " - "Check netlist file to change simulation parameters." + "Check netlist file (*.cir.out) " + "to change simulation parameters." ) self.msg = QtWidgets.QErrorMessage() @@ -599,7 +600,8 @@ class Application(QtWidgets.QMainWindow): self.msg.setWindowTitle("Warning Message") self.msg.showMessage( 'Ngspice taking too long for simulation. ' - 'Check netlist file to change simulation parameters.' + 'Check netlist file (*.cir.out) ' + 'to change simulation parameters.' ) self.msg.exec_() @@ -752,7 +754,7 @@ class Application(QtWidgets.QMainWindow): else: self.msg = QtWidgets.QErrorMessage() self.msg.setModal(True) - self.msg.setWindowTitle("Missing Ngspice netlist") + self.msg.setWindowTitle("Missing Ngspice Netlist") self.msg.showMessage( 'Current project does not contain any Ngspice file. ' + 'Please create Ngspice file with extension .cir.out' -- cgit From 1d044a719c68488dd90cef2faf5b1101c005ab4c Mon Sep 17 00:00:00 2001 From: Eyantra698Sumanto Date: Tue, 25 Jan 2022 19:34:39 +0530 Subject: revert simulation wait count to 10 --- src/frontEnd/Application.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/frontEnd/Application.py b/src/frontEnd/Application.py index 2620fc9c..aa441405 100644 --- a/src/frontEnd/Application.py +++ b/src/frontEnd/Application.py @@ -588,7 +588,7 @@ class Application(QtWidgets.QMainWindow): # Fail Safe ===> count += 1 - if count >= 1000: + if count >= 10: print( "Ngspice taking too long for simulation. " "Check netlist file (*.cir.out) " -- cgit