Skip to content

Commit 7517262

Browse files
fix autocompile for pythia8
1 parent 145bd44 commit 7517262

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

smodels/tools/pythia8Wrapper.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -122,18 +122,19 @@ def checkInstallation ( self, compile : bool = True ):
122122
exists = os.path.exists ( self.includeFile )
123123
xmldoc = self.getXmldoc()
124124
sleep = 0.
125-
while not os.path.exists ( xmldoc ): # if this disappears, start from scratch
125+
while not os.path.exists ( xmldoc ) or not os.path.exists ( self.executablePath ): # if this disappears, start from scratch
126126
import time
127127
sleep += .5
128128
time.sleep ( sleep )
129-
if sleep > .5 and not os.path.exists ( xmldoc ):
129+
if sleep > .5 and not os.path.exists ( xmldoc ) or not os.path.exists ( self.executablePath ):
130130
if compile:
131131
# after a few seconds, delete, if compile is true
132132
import shutil
133133
p = xmldoc.find ( "share" )
134134
rm = xmldoc[:p-1]
135135
if False:
136136
shutil.rmtree ( rm, ignore_errors = True )
137+
self.compile()
137138
exists = False
138139
break
139140

@@ -148,12 +149,12 @@ def checkInstallation ( self, compile : bool = True ):
148149

149150
def getXmldoc ( self ):
150151
""" get the content of xml.doc """
151-
xmldoc = self.executablePath.replace("pythia8.exe", "xml.doc")
152-
logger.debug("exe path=%s" % self.executablePath)
152+
xmldoc = self.executablePath.replace( "pythia8.exe", "xml.doc" )
153+
logger.debug( f"exe path={self.executablePath}" )
153154
if not os.path.exists ( xmldoc ):
154155
return None
155156
if os.path.exists(xmldoc):
156-
logger.debug("xml.doc found at %s." % xmldoc)
157+
logger.debug(f"xml.doc found at {xmldoc}.")
157158
with open(xmldoc) as f:
158159
xmlDir = f.read()
159160
toadd = os.path.join(os.path.dirname(xmldoc), xmlDir.strip())

smodels/tools/wrapperBase.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,23 +66,23 @@ def chmod(self):
6666
os.chmod ( self.executablePath, mode )
6767
return True
6868

69-
def compile(self):
69+
def compile ( self ):
7070
"""
7171
Try to compile the tool.
7272
"""
7373
if not self.maycompile:
7474
logger.error("Asking to compile, but auto-compilation turned off for %s", self.name )
7575
return
76-
logger.debug("Trying to compile %s", self.name)
77-
cmd = "cd %s; make" % self.srcPath
76+
logger.info( f"Trying to compile {self.name}" )
77+
cmd = f"cd {self.srcPath}; make"
7878
out = executor.getoutput(cmd)
7979
# out = subprocess.check_output ( cmd, shell=True, universal_newlines=True )
8080
logger.debug(out)
8181
if not os.path.exists ( self.executablePath ):
8282
if self.maycompile: ## should have worked
83-
logger.error ( "Compilation of %s failed. Is the %s compiler installed?" % ( self.name, self.compiler ) )
83+
logger.error ( f"Compilation of {self.name} failed. Is the {self.compiler} compiler installed?" )
8484
sys.exit()
85-
logger.info ( "Compilation of %s succeeded!" % ( self.name ) )
85+
logger.info ( f"Compilation of {self.name} succeeded!" )
8686
return True
8787

8888

@@ -96,10 +96,10 @@ def checkInstallation(self, compile=True ):
9696
"""
9797
if not os.path.exists(self.executablePath):
9898
if compile:
99-
logger.warning("%s executable not found. Trying to compile it now. This may take a while." % self.name )
99+
logger.warning( f"{self.name} executable not found. Trying to compile it now. This may take a while." )
100100
self.compile()
101101
else:
102-
logger.warning("%s executable not found." % self.name )
102+
logger.warning( f"{self.name} executable not found." )
103103
self.complain()
104104
return False
105105
if not os.path.exists(self.executablePath):

0 commit comments

Comments
 (0)