Skip to content

Commit

Permalink
refactor(exe_name): remove unnecessary ".exe" suffix
Browse files Browse the repository at this point in the history
  • Loading branch information
mwtoews committed Sep 29, 2022
1 parent 14d69cb commit 31a2dc1
Show file tree
Hide file tree
Showing 34 changed files with 34 additions and 111 deletions.
6 changes: 0 additions & 6 deletions examples/Notebooks/flopy3.3_PlotCrossSection.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
"source": [
"import sys\n",
"import os\n",
"import platform\n",
"import numpy as np\n",
"import matplotlib as mpl\n",
"import matplotlib.pyplot as plt\n",
Expand Down Expand Up @@ -90,11 +89,6 @@
"exe_name_2005 = \"mf2005\"\n",
"vmf6 = \"mf6\"\n",
"exe_name_mf6 = \"mf6\"\n",
"exe_mp = \"mp6\"\n",
"if platform.system() == \"Windows\":\n",
" exe_name_2005 += \".exe\"\n",
" exe_name_mf6 += \".exe\"\n",
" exe_mp += \".exe\"\n",
"\n",
"# Set the paths\n",
"prj_root = notebook_utils.get_project_root_path()\n",
Expand Down
6 changes: 0 additions & 6 deletions examples/Notebooks/flopy3.3_PlotMapView.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
"source": [
"import sys\n",
"import os\n",
"import platform\n",
"import numpy as np\n",
"import matplotlib as mpl\n",
"import matplotlib.pyplot as plt\n",
Expand Down Expand Up @@ -92,11 +91,6 @@
"vmf6 = \"mf6\"\n",
"exe_name_mf6 = \"mf6\"\n",
"exe_mp = \"mp6\"\n",
"if platform.system() == \"Windows\":\n",
" exe_name_2005 += \".exe\"\n",
" exe_name_mf6 += \".exe\"\n",
" exe_mp += \".exe\"\n",
"\n",
"\n",
"# Set the paths\n",
"prj_root = notebook_utils.get_project_root_path()\n",
Expand Down
4 changes: 0 additions & 4 deletions examples/Notebooks/flopy3_MT3D-USGS_example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
"source": [
"import sys\n",
"import os\n",
"import platform\n",
"import string\n",
"from tempfile import TemporaryDirectory\n",
"from io import StringIO, BytesIO\n",
Expand Down Expand Up @@ -88,9 +87,6 @@
"modelname = \"CrnkNic\"\n",
"mfexe = \"mfnwt\"\n",
"mtexe = \"mt3dusgs\"\n",
"if platform.system() == \"Windows\":\n",
" mfexe += \".exe\"\n",
" mtexe += \".exe\"\n",
"\n",
"# Make sure modelpth directory exists\n",
"if not os.path.isdir(modelpth):\n",
Expand Down
4 changes: 0 additions & 4 deletions examples/Notebooks/flopy3_PlotArrayExample.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
"from IPython.display import Image\n",
"import sys\n",
"import os\n",
"import platform\n",
"from tempfile import TemporaryDirectory\n",
"\n",
"import numpy as np\n",
Expand Down Expand Up @@ -76,9 +75,6 @@
"# assumes executable is in users path statement\n",
"version = \"mf2005\"\n",
"exe_name = \"mf2005\"\n",
"if platform.system() == \"Windows\":\n",
" exe_name = \"mf2005.exe\"\n",
"mfexe = exe_name\n",
"\n",
"# Set the paths\n",
"loadpth = os.path.join(\"..\", \"data\", \"secp\")\n",
Expand Down
1 change: 0 additions & 1 deletion examples/Notebooks/flopy3_WatertableRecharge_example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
"source": [
"import os\n",
"import sys\n",
"import platform\n",
"from tempfile import TemporaryDirectory\n",
"\n",
"import numpy as np\n",
Expand Down
6 changes: 1 addition & 5 deletions examples/Notebooks/flopy3_Zaidel_example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
"source": [
"import os\n",
"import sys\n",
"import platform\n",
"from tempfile import TemporaryDirectory\n",
"\n",
"import numpy as np\n",
Expand Down Expand Up @@ -79,10 +78,7 @@
"source": [
"# Set name of MODFLOW exe\n",
"# assumes executable is in users path statement\n",
"exe_name = \"mfusg\"\n",
"if platform.system() == \"Windows\":\n",
" exe_name += \".exe\"\n",
"mfexe = exe_name\n",
"mfexe = \"mfusg\"\n",
"\n",
"modelname = \"zaidel\"\n",
"temp_dir = TemporaryDirectory()\n",
Expand Down
4 changes: 0 additions & 4 deletions examples/Notebooks/flopy3_ZoneBudget_example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
"source": [
"import os\n",
"import sys\n",
"import platform\n",
"from tempfile import TemporaryDirectory\n",
"\n",
"import numpy as np\n",
Expand Down Expand Up @@ -1635,9 +1634,6 @@
"source": [
"mf6_exe = \"mf6\"\n",
"zb6_exe = \"zbud6\"\n",
"if platform.system().lower() == \"windows\":\n",
" mf6_exe += \".exe\"\n",
" zb6_exe += \".exe\"\n",
"\n",
"sim_ws = os.path.join(\"..\", \"data\", \"mf6-freyberg\")\n",
"cpth = os.path.join(\".\", \"temp\")\n",
Expand Down
1 change: 0 additions & 1 deletion examples/Notebooks/flopy3_array_outputformat_options.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
"source": [
"import sys\n",
"import os\n",
"import platform\n",
"from tempfile import TemporaryDirectory\n",
"\n",
"import numpy as np\n",
Expand Down
6 changes: 1 addition & 5 deletions examples/Notebooks/flopy3_demo_of_modelgrid_classes.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
"import numpy as np\n",
"import matplotlib as mpl\n",
"import matplotlib.pyplot as plt\n",
"import platform\n",
"\n",
"# run installed version of flopy or add local path\n",
"try:\n",
Expand Down Expand Up @@ -85,10 +84,7 @@
"# set the names of our modflow executables\n",
"# assumes that the executable is in users path statement\n",
"mf6_exe = \"mf6\"\n",
"gridgen_exe = \"gridgen\"\n",
"if platform.system().lower() == \"windows\":\n",
" mf6_exe += \".exe\"\n",
" gridgen_exe += \".exe\""
"gridgen_exe = \"gridgen\""
]
},
{
Expand Down
1 change: 0 additions & 1 deletion examples/Notebooks/flopy3_grid_intersection_demo.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@
],
"source": [
"import os\n",
"import platform\n",
"import sys\n",
"\n",
"import matplotlib as mpl\n",
Expand Down
5 changes: 0 additions & 5 deletions examples/Notebooks/flopy3_gridgen.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
"source": [
"import os\n",
"import sys\n",
"import platform\n",
"import shutil\n",
"from tempfile import TemporaryDirectory\n",
"\n",
Expand Down Expand Up @@ -89,10 +88,6 @@
}
],
"source": [
"gridgen_exe = \"gridgen\"\n",
"if platform.system() in \"Windows\":\n",
" gridgen_exe += \".exe\"\n",
"\n",
"gridgen_exe = flopy.which(\"gridgen\")\n",
"if gridgen_exe is None:\n",
" msg = (\n",
Expand Down
1 change: 0 additions & 1 deletion examples/Notebooks/flopy3_mf6_A_simple-model.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
"source": [
"import sys\n",
"import os\n",
"import platform\n",
"from tempfile import TemporaryDirectory\n",
"\n",
"import numpy as np\n",
Expand Down
1 change: 0 additions & 1 deletion examples/Notebooks/flopy3_mf6_B_complex-model.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
"source": [
"import sys\n",
"import os\n",
"import platform\n",
"from tempfile import TemporaryDirectory\n",
"\n",
"import numpy as np\n",
Expand Down
2 changes: 1 addition & 1 deletion examples/Notebooks/flopy3_mf6_tutorial.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
"\n",
"version='mf6'\n",
"\n",
"exe_name='mf6.exe'\n",
"exe_name='mf6'\n",
"\n",
"sim_ws='.'\n",
"\n",
Expand Down
6 changes: 1 addition & 5 deletions examples/Notebooks/flopy3_modpath7_create_simulation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
"import numpy as np\n",
"import matplotlib as mpl\n",
"import matplotlib.pyplot as plt\n",
"import platform\n",
"\n",
"# run installed version of flopy or add local path\n",
"try:\n",
Expand Down Expand Up @@ -77,10 +76,7 @@
"source": [
"# define executable names\n",
"mpexe = \"mp7\"\n",
"mfexe = \"mf6\"\n",
"if platform.system() == \"Windows\":\n",
" mpexe += \".exe\"\n",
" mfexe += \".exe\""
"mfexe = \"mf6\""
]
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
"source": [
"import os\n",
"import sys\n",
"import platform\n",
"from tempfile import TemporaryDirectory\n",
"\n",
"import numpy as np\n",
Expand Down Expand Up @@ -97,10 +96,6 @@
"mfexe = \"mfnwt\"\n",
"mtexe = \"mt3dusgs\"\n",
"\n",
"if platform.system() == \"Windows\":\n",
" mfexe += \".exe\"\n",
" mtexe += \".exe\"\n",
"\n",
"# Make sure modelpth directory exists\n",
"if not os.path.isdir(modelpth):\n",
" os.makedirs(modelpth, exist_ok=True)\n",
Expand Down
4 changes: 0 additions & 4 deletions examples/Notebooks/flopy3_nwt_options.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
"source": [
"import os\n",
"import sys\n",
"import platform\n",
"from tempfile import TemporaryDirectory\n",
"\n",
"try:\n",
Expand Down Expand Up @@ -121,9 +120,6 @@
"source": [
"mfexe = \"mfnwt\"\n",
"\n",
"if platform.system() == \"Windows\":\n",
" mfexe += \".exe\"\n",
"\n",
"ml = flopy.modflow.Modflow.load(\n",
" \"sagehen.nam\", model_ws=load_ws, exe_name=mfexe, version=\"mfnwt\"\n",
")\n",
Expand Down
5 changes: 1 addition & 4 deletions examples/Notebooks/flopy3_sfrpackage_example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
],
"source": [
"import sys\n",
"import platform\n",
"import os\n",
"import glob\n",
"import shutil\n",
Expand Down Expand Up @@ -90,9 +89,7 @@
"source": [
"# Set name of MODFLOW exe\n",
"# assumes executable is in users path statement\n",
"exe_name = \"mf2005\"\n",
"if platform.system() == \"Windows\":\n",
" exe_name += \".exe\""
"exe_name = \"mf2005\""
]
},
{
Expand Down
3 changes: 0 additions & 3 deletions examples/Notebooks/flopy3_swi2package_ex1.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
"source": [
"import os\n",
"import sys\n",
"import platform\n",
"from tempfile import TemporaryDirectory\n",
"\n",
"import numpy as np\n",
Expand Down Expand Up @@ -95,8 +94,6 @@
"# Set name of MODFLOW exe\n",
"# assumes executable is in users path statement\n",
"exe_name = \"mf2005\"\n",
"if platform.system() == \"Windows\":\n",
" exe_name = \"mf2005.exe\"\n",
"\n",
"temp_dir = TemporaryDirectory()\n",
"workspace = temp_dir.name\n",
Expand Down
3 changes: 0 additions & 3 deletions examples/Notebooks/flopy3_swi2package_ex4.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@
"source": [
"import os\n",
"import sys\n",
"import platform\n",
"from tempfile import TemporaryDirectory\n",
"\n",
"import numpy as np\n",
Expand Down Expand Up @@ -98,8 +97,6 @@
"# Set name of MODFLOW exe\n",
"# assumes executable is in users path statement\n",
"exe_name = \"mf2005\"\n",
"if platform.system() == \"Windows\":\n",
" exe_name = \"mf2005.exe\"\n",
"\n",
"temp_dir = TemporaryDirectory()\n",
"workspace = temp_dir.name"
Expand Down
5 changes: 1 addition & 4 deletions examples/Notebooks/flopy3_uzf_example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
"import os\n",
"import sys\n",
"import glob\n",
"import platform\n",
"import shutil\n",
"from tempfile import TemporaryDirectory\n",
"\n",
Expand Down Expand Up @@ -88,9 +87,7 @@
"source": [
"# Set name of MODFLOW exe\n",
"# assumes executable is in users path statement\n",
"exe_name = \"mf2005\"\n",
"if platform.system() == \"Windows\":\n",
" exe_name += \".exe\""
"exe_name = \"mf2005\""
]
},
{
Expand Down
3 changes: 0 additions & 3 deletions examples/Tutorials/modflow6output/tutorial01_mf6_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
# package object

import os
import platform
from pathlib import Path
from tempfile import TemporaryDirectory

Expand All @@ -31,8 +30,6 @@
# ## Load a simple demonstration model

exe_name = "mf6"
if platform.system().lower() == "windows":
exe_name += ".exe"


def get_project_root_path(path=None):
Expand Down
3 changes: 0 additions & 3 deletions examples/scripts/flopy_swi2_ex4.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import os
import platform
import sys
from tempfile import TemporaryDirectory

Expand Down Expand Up @@ -67,8 +66,6 @@ def run(workspace, quiet):

# Set path and name of MODFLOW exe
exe_name = "mf2005"
if platform.system() == "Windows":
exe_name = "mf2005"

ncol = 61
nrow = 61
Expand Down
12 changes: 4 additions & 8 deletions flopy/mbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ class BaseModel(ModelInterface):
Name of the model, which is also used for model file names.
namefile_ext : str, default "nam"
Name file extension, without "."
exe_name : str, default "mf2k.exe"
exe_name : str, default "mf2005"
Name of the modflow executable.
model_ws : str, optional
Path to the model workspace. Model files will be created in this
Expand All @@ -326,7 +326,7 @@ def __init__(
self,
modelname="modflowtest",
namefile_ext="nam",
exe_name="mf2k.exe",
exe_name="mf2005",
model_ws=None,
structured=True,
verbose=False,
Expand Down Expand Up @@ -1698,12 +1698,8 @@ def run_model(
# Check to make sure that program and namefile exist
exe = which(exe_name)
if exe is None:
import platform

if platform.system() in "Windows":
if not exe_name.lower().endswith(".exe"):
exe = which(exe_name + ".exe")
elif exe_name.lower().endswith(".exe"):
if exe_name.lower().endswith(".exe"):
# try removing .exe suffix
exe = which(exe_name[:-4])
if exe is None:
raise Exception(
Expand Down
Loading

0 comments on commit 31a2dc1

Please sign in to comment.