Skip to content

Commit

Permalink
Bypass prompt with env var, run mordm example
Browse files Browse the repository at this point in the history
  • Loading branch information
dhadka committed Sep 5, 2024
1 parent 73d5d25 commit 24132d6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ jobs:
"Basic/sensitivity_analysis.py",
"Basic/dps_example.py",
"Eijgenraam/eijgenraam.py",
"Eijgenraam/eijgenraam_mordm.py",
"Languages/Python/lakeModelInPython.py",
"Languages/R/lakeModelInR.py",
#"Languages/Excel/lakeModelInExcel.py" # requires Windows
Expand Down Expand Up @@ -70,7 +71,8 @@ jobs:
make
fi
LD_LIBRARY_PATH="$(pwd):${LD_LIBRARY_PATH}"
export RHODIUM_NO_PROMPT=true
export LD_LIBRARY_PATH="$(pwd):${LD_LIBRARY_PATH}"
python "${EXAMPLE_FILE}"
- name: Upload figures
Expand Down
20 changes: 12 additions & 8 deletions rhodium/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,24 @@
#
# You should have received a copy of the GNU General Public License
# along with Rhodium. If not, see <http://www.gnu.org/licenses/>.
import os
import sys

def promptToRun(message, default="yes"):
if default == "yes":
prompt = "[Y/n]"
elif default == "no":
prompt = "[y/N]"
if os.getenv("RHODIUM_NO_PROMPT"):
response = ""
else:
raise ValueError("invalid default answer")
if default == "yes":
prompt = "[Y/n]"
elif default == "no":
prompt = "[y/N]"
else:
raise ValueError("invalid default answer")

print(message + " " + prompt + " ", end='')
sys.stdout.flush()
print(message + " " + prompt + " ", end='')
sys.stdout.flush()

response = sys.stdin.readline().strip()
response = sys.stdin.readline().strip()

if response == "":
response = default[0]
Expand Down

0 comments on commit 24132d6

Please sign in to comment.