Skip to content

Commit

Permalink
Using Popen(shell=True) rather than shell=False for launching Gmsh
Browse files Browse the repository at this point in the history
This is needed as part of a test to get a minimal Buildbot environment
configured. For some reason when `shell=False`, the local `gmsh`
executable in the virtualenv from which the script is launched is not
used, but the version in `/usr/bin` is used instead. There are some
risks with using `shell=True`, but I want to see what Buildbot does.
  • Loading branch information
wd15 committed Dec 17, 2012
1 parent 935a605 commit 1634eb6
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions fipy/meshes/gmshMesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,13 @@ class GmshException(Exception):
class MeshExportError(GmshException):
pass

def gmshPopen(cmd, stderr=None, stdout=None, shell=True):
cmd = ['gmsh'] + cmd
if shell:
cmd = ' '.join(cmd)
return Popen(cmd, stderr=stderr, stdout=stdout, shell=shell)


def gmshVersion(communicator=parallel):
"""Determine the version of Gmsh.
Expand All @@ -98,7 +105,7 @@ def gmshVersion(communicator=parallel):
if communicator.procID == 0:
while True:
try:
p = Popen(["gmsh", "--version"], stderr=PIPE)
p = gmshPopen(["--version"], stderr=PIPE)
except OSError, e:
verStr = None
break
Expand Down Expand Up @@ -224,7 +231,7 @@ def openMSHFile(name, dimensions=None, coordDimensions=None, communicator=parall
fileIsTemporary = True

while True:
p = Popen(["gmsh", geoFile] + gmshFlags + ["-o", mshFile],
p = gmshPopen([geoFile] + gmshFlags + ["-o", mshFile],
stdout=PIPE)

try:
Expand Down Expand Up @@ -1208,7 +1215,7 @@ def _test(self):
>>> f.close() # doctest: +GMSH
>>> if __name__ == "__main__":
... p = Popen(["gmsh", os.path.join(dir, "g.msh")]) # doctest: +GMSH
... p = gmshPopen([os.path.join(dir, "g.msh")]) # doctest: +GMSH
... doctest_raw_input("Grid2D... Press enter.")
>>> gg = GmshGrid2D(dx=1., dy=1., nx=10, ny=10)
Expand All @@ -1218,7 +1225,7 @@ def _test(self):
>>> f.close() # doctest: +GMSH
>>> if __name__ == "__main__":
... p = Popen(["gmsh", os.path.join(dir, "gg.msh")]) # doctest: +GMSH
... p = gmshPopen([os.path.join(dir, "gg.msh")]) # doctest: +GMSH
... doctest_raw_input("GmshGrid2D... Press enter.")
>>> ug = UniformGrid2D(nx = 10, ny = 10)
Expand All @@ -1237,7 +1244,7 @@ def _test(self):
>>> f.close() # doctest: +GMSH
>>> if __name__ == "__main__":
... p = Popen(["gmsh", os.path.join(dir, "concat.msh")]) # doctest: +GMSH
... p = gmshPopen([os.path.join(dir, "concat.msh")]) # doctest: +GMSH
... doctest_raw_input("Tri2D + Grid2D... Press enter.")
>>> g3d = Grid3D(nx=10, ny=10, nz=30)
Expand All @@ -1246,7 +1253,7 @@ def _test(self):
>>> f.close() # doctest: +GMSH
>>> if __name__ == "__main__":
... p = Popen(["gmsh", os.path.join(dir, "g3d.msh")]) # doctest: +GMSH
... p = gmshPopen([os.path.join(dir, "g3d.msh")]) # doctest: +GMSH
... doctest_raw_input("Grid3D... Press enter.")
>>> cyl = CylindricalGrid2D(nx=10, ny=10)
Expand All @@ -1255,7 +1262,7 @@ def _test(self):
>>> f.close() # doctest: +GMSH
>>> if __name__ == "__main__":
... p = Popen(["gmsh", os.path.join(dir, "cyl.msh")]) # doctest: +GMSH
... p = gmshPopen([os.path.join(dir, "cyl.msh")]) # doctest: +GMSH
... doctest_raw_input("CylindricalGrid2D... Press enter.")
>>> import shutil
Expand Down Expand Up @@ -1700,7 +1707,7 @@ def _test(self):
>>> from fipy import doctest_raw_input
>>> if __name__ == "__main__":
... p = Popen(["gmsh", mshFile]) # doctest: +GMSH
... p = gmshPopen([mshFile]) # doctest: +GMSH
... doctest_raw_input("Circle... Press enter.")
>>> os.remove(mshFile)
Expand Down

0 comments on commit 1634eb6

Please sign in to comment.