Trisurf Monte Carlo simulator
Samo Penic
2016-05-15 38cb4ac927272256b636c014a9aec1a119958fb6
Added check if trisurf executable exists in path, ETA is empty or N/A at appropriate moments, PID is empty if stopped, fix in getPID (some pythons like str some functions ) ;)
2 files modified
19 ■■■■ changed files
python/myTestConfig.py 1 ●●●● patch | view | raw | blame | history
python/trisurf/trisurf.py 18 ●●●● patch | view | raw | blame | history
python/myTestConfig.py
old mode 100644 new mode 100755
@@ -1,3 +1,4 @@
#!/usr/bin/python3
from trisurf import tsmgr
from trisurf import trisurf
python/trisurf/trisurf.py
@@ -13,6 +13,7 @@
import time
import datetime
import subprocess
import shutil
# Process status
TS_NOLOCK=0 # lock file does not exist
@@ -323,8 +324,8 @@
            return TS_NOLOCK
        if(psutil.pid_exists(int(pid))):
            proc= psutil.Process(int(pid))
            if proc.name()=="trisurf":
                if proc.status()=="stopped":
            if proc.name=="trisurf":
                if proc.status=="stopped":
                    return TS_STOPPED
                else:
                    return TS_RUNNING
@@ -335,6 +336,10 @@
    def start(self):
        if(self.getStatus()==0 or self.getStatus()==TS_COMPLETED):
            #check if executable exists
            if(shutil.which('trisurf')==None):
                print("Error. Trisurf executable not found in PATH. Please install trisurf prior to running trisurf manager.")
                exit(1)
            self.Dir=Directory(maindir=self.maindir,simdir=self.subdir)
#Symlinks tape file to the directory or create tape file from snapshot in the direcory...
            if(self.Dir.makeifnotexist()):
@@ -400,20 +405,25 @@
        self.Dir=Directory(maindir=self.maindir,simdir=self.subdir)
        self.statistics=Statistics(self.Dir.fullpath(), statfile)
        self.Comment=FileContent(os.path.join(self.Dir.fullpath(),".comment"))
        pid=self.getPID();
        pid=self.getPID()
        status=self.getStatus()
        ETA=str(datetime.timedelta(microseconds=(int(self.tape.config['iterations'])-int(self.statistics.last))*self.statistics.dT)*1000000)
        if(status==TS_NONEXISTANT or status==TS_NOLOCK):
            statustxt="Not running"
            pid=""
            ETA=""
        elif status==TS_STOPPED:
            statustxt="Stopped"
            ETA="N/A"
        elif status==TS_COMPLETED:
            statustxt="Completed"
            pid=""
            ETA=""
        else:
            statustxt="Running"
        if(self.statistics.fileOK):
            report=[time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(int(self.statistics.startDate))),str(datetime.timedelta(microseconds=(int(self.tape.config['iterations'])-int(self.statistics.last))*self.statistics.dT)*1000000), statustxt, pid, str(self.Dir.fullpath()), self.Comment.getText()]
            report=[time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(int(self.statistics.startDate))),ETA, statustxt, pid, str(self.Dir.fullpath()), self.Comment.getText()]
        else:
            report=["N/A","N/A\t",statustxt, pid, str(self.Dir.fullpath()), self.Comment.getText()]
        return report