Commit 77067bba authored by Lukas Riedel's avatar Lukas Riedel

Remove falsely committed cli/cmds.py

cmds.py is configured from cmds.py.in. The appropriate .gitignore
path is wrong.
parent 2f01b72f
import os
import sys
import shutil
import subprocess
try: # Python 2.x compatibility
input = raw_input
except NameError:
pass
# paths set by cmake
DORIEDIR = "/home/saospina/Codes/DUNE_INSTALL/Debug/dorie"
MPIEXEC = "/usr/bin/mpiexec"
MPIEXEC_NUMPROC_FLAG = "-n"
MPIEXEC_PREFLAG = ""
MPIEXEC_POSTFLAGS = ""
# set some paths
DORIE_EXECUTABLE = os.path.join(DORIEDIR, "dune/dorie/dorie")
PARAMETERDIR = os.path.join(DORIEDIR, "doc/default_files")
def MPIRUN(nproc,exe,*args,**kwargs):
mpi_flags = kwargs.get("mpi_flags") or []
return [k for k in [MPIEXEC,MPIEXEC_NUMPROC_FLAG,str(nproc)] \
+ mpi_flags + [MPIEXEC_PREFLAG,str(exe),
MPIEXEC_POSTFLAGS] + list(args) if k]
def run(args):
if not os.path.isfile(args["config"]):
raise IOError("Configuration file {} not found".format(args["config"]))
try:
if args["parallel"] == 1:
subprocess.check_call([DORIE_EXECUTABLE, args["config"]])
else:
subprocess.check_call(MPIRUN(args["parallel"], DORIE_EXECUTABLE,
args["config"], mpi_flags=args["mpi_flags"]))
except subprocess.CalledProcessError:
print("Error while running DORiE")
sys.exit(1)
def create(args):
for f in ("config.ini", "parfield.ini", "2d_infiltr.bcdat", "3d_infiltr.bcdat"):
newfile = os.path.join(os.getcwd(),f)
if os.path.exists(newfile) and not args["force"]:
override = (input("File {} exists. Override? [Y/n] ".format(f)) or "Y") in ["Y","y"]
if not override:
continue
shutil.copyfile(os.path.join(PARAMETERDIR, f), newfile)
print("Folder initialized")
def pfg(args):
if not os.path.isfile(args["config"]):
raise IOError("Configuration file {} not found".format(args["config"]))
try:
if args["parallel"] == 1:
subprocess.check_call(["pf_from_file.py", args["config"]])
else:
if args["mpi_flags"]:
mpi_flags = ["--mpi-flags=" + f for f in args["mpi_flags"]]
else:
mpi_flags = []
subprocess.check_call(["pf_from_file.py", args["config"],
"--parallel", str(args["parallel"])] + mpi_flags)
except subprocess.CalledProcessError:
print("Error while running DORiE")
sys.exit(1)
def plot(args):
if not os.path.isfile(args["vtk"]):
raise IOError("File {} not found".format(args["vtk"]))
try:
if args["var"]:
subprocess.check_call(["plot_vtk.py", "-f", args["vtk"], "--var", args["var"]])
else:
subprocess.check_call(["plot_vtk.py", "-f", args["vtk"]])
except subprocess.CalledProcessError:
print("Error while running DORiE")
sys.exit(1)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment