From 2d731a3ee8b36cb7623e15eb60b2a7428452a28d Mon Sep 17 00:00:00 2001 From: xywei Date: Sat, 11 May 2019 15:25:56 -0500 Subject: [PATCH 1/2] Bug fix --- gmsh_interop/runner.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/gmsh_interop/runner.py b/gmsh_interop/runner.py index 9ef66e1..b489e0b 100644 --- a/gmsh_interop/runner.py +++ b/gmsh_interop/runner.py @@ -291,10 +291,14 @@ class GmshRunner(object): decision = None while not decision: i, o, e = select.select([sys.stdin], [], [], 10) - if i == "N" or i == "n": + if i: + resp = sys.stdin.readline().strip() + if resp == "N" or resp == "n": + logger.info("Not overwriting.") decision = 0 - elif i == "Y" or i == "y" or not i: + elif resp == "Y" or resp == "y" or not i: decision = 1 + logger.info("Overwriting.") else: print("Illegal input %s, please retry." % i) if decision == 0: -- GitLab From 475e9a68d62c27f4df0d3c273d273a4aa666463f Mon Sep 17 00:00:00 2001 From: xywei Date: Wed, 8 Jul 2020 16:27:15 -0500 Subject: [PATCH 2/2] Make keeping/overwriting temp file behave right --- gmsh_interop/reader.py | 5 +++-- gmsh_interop/runner.py | 23 ++++++++++++++--------- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/gmsh_interop/reader.py b/gmsh_interop/reader.py index 5720ccb..46ea9bb 100644 --- a/gmsh_interop/reader.py +++ b/gmsh_interop/reader.py @@ -616,7 +616,7 @@ def read_gmsh(receiver, filename, force_dimension=None): def generate_gmsh(receiver, source, dimensions=None, order=None, other_options=[], extension="geo", gmsh_executable="gmsh", force_dimension=None, - output_file_name="output.msh"): + output_file_name=None, save_tmp_files_in=None): """Run gmsh and feed the output to *receiver*. :arg receiver: a class that implements the :class:`GmshMeshReceiverBase` @@ -627,7 +627,8 @@ def generate_gmsh(receiver, source, dimensions=None, order=None, other_options=[ runner = GmshRunner(source, dimensions, order=order, other_options=other_options, extension=extension, gmsh_executable=gmsh_executable, - output_file_name=output_file_name) + output_file_name=output_file_name, + save_tmp_files_in=save_tmp_files_in) runner.__enter__() try: diff --git a/gmsh_interop/runner.py b/gmsh_interop/runner.py index 682f49c..112d93e 100644 --- a/gmsh_interop/runner.py +++ b/gmsh_interop/runner.py @@ -124,7 +124,7 @@ class GmshRunner(object): def __init__(self, source, dimensions=None, order=None, incomplete_elements=None, other_options=[], extension="geo", gmsh_executable="gmsh", - output_file_name="output.msh", + output_file_name=None, target_unit=None, save_tmp_files_in=None): if isinstance(source, str): @@ -141,6 +141,9 @@ class GmshRunner(object): warn("Not specifying target_unit is deprecated. Set target_unit='MM' " "to retain prior behavior.", DeprecationWarning, stacklevel=2) + if output_file_name is None: + output_file_name = "output.msh" + self.source = source self.dimensions = dimensions self.order = order @@ -291,18 +294,20 @@ class GmshRunner(object): print("%s exists! Overwrite? (Y/N, will default to Y in 10sec)." % self.save_tmp_files_in) decision = None - while not decision: + while decision is None: i, o, e = select.select([sys.stdin], [], [], 10) if i: resp = sys.stdin.readline().strip() - if resp == "N" or resp == "n": - logger.info("Not overwriting.") - decision = 0 - elif resp == "Y" or resp == "y" or not i: - decision = 1 - logger.info("Overwriting.") + if resp == "N" or resp == "n": + logger.info("Not overwriting.") + decision = 0 + elif resp == "Y" or resp == "y" or not i: + decision = 1 + logger.info("Overwriting.") + else: + print("Illegal input %s, please retry." % i) else: - print("Illegal input %s, please retry." % i) + decision = 1 # default if decision == 0: pass else: -- GitLab