Skip to content

Commit ddba638

Browse files
committed
??? cleanup duplicated code
1 parent 8c94f1c commit ddba638

1 file changed

Lines changed: 0 additions & 39 deletions

File tree

OMPython/OMCSession.py

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -687,45 +687,6 @@ def run_model_executable(cmd_run_data: OMCSessionRunData) -> int:
687687

688688
return returncode
689689

690-
@staticmethod
691-
def run_model_executable(cmd_run_data: OMCSessionRunData) -> int:
692-
"""
693-
Run the command defined in cmd_run_data. This class is defined as static method such that there is no need to
694-
keep instances of over classes around.
695-
"""
696-
697-
my_env = os.environ.copy()
698-
if isinstance(cmd_run_data.cmd_library_path, str):
699-
my_env["PATH"] = cmd_run_data.cmd_library_path + os.pathsep + my_env["PATH"]
700-
701-
cmdl = cmd_run_data.get_cmd()
702-
703-
logger.debug("Run OM command %s in %s", repr(cmdl), cmd_run_data.cmd_path)
704-
try:
705-
cmdres = subprocess.run(
706-
cmdl,
707-
capture_output=True,
708-
text=True,
709-
env=my_env,
710-
cwd=cmd_run_data.cmd_cwd_local,
711-
timeout=cmd_run_data.cmd_timeout,
712-
check=True,
713-
)
714-
stdout = cmdres.stdout.strip()
715-
stderr = cmdres.stderr.strip()
716-
returncode = cmdres.returncode
717-
718-
logger.debug("OM output for command %s:\n%s", repr(cmdl), stdout)
719-
720-
if stderr:
721-
raise OMCSessionException(f"Error running model executable {repr(cmdl)}: {stderr}")
722-
except subprocess.TimeoutExpired as ex:
723-
raise OMCSessionException(f"Timeout running model executable {repr(cmdl)}") from ex
724-
except subprocess.CalledProcessError as ex:
725-
raise OMCSessionException(f"Error running model executable {repr(cmdl)}") from ex
726-
727-
return returncode
728-
729690
def execute(self, command: str):
730691
warnings.warn("This function is depreciated and will be removed in future versions; "
731692
"please use sendExpression() instead", DeprecationWarning, stacklevel=2)

0 commit comments

Comments
 (0)