Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 23 additions & 3 deletions src/ansys/mapdl/core/mapdl_grpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -1236,6 +1236,7 @@ def input(
# file.
tmp_name = "_input_tmp_.inp"
tmp_out = "_input_tmp_.out"

if "CDRE" in orig_cmd.upper():
# Using CDREAD
option = kwargs.get("cd_read_option", "COMB")
Expand All @@ -1250,6 +1251,7 @@ def input(
f.write(tmp_dat)
else:
self._upload_raw(tmp_dat.encode(), tmp_name)

request = pb_types.InputFileRequest(filename=tmp_name)

# even though we don't care about the output, we still
Expand All @@ -1259,12 +1261,30 @@ def input(
_ = [chunk.cmdout for chunk in chunks] # unstable

# all output (unless redirected) has been written to a temp output
if self._local:
if self._local: # pragma: no cover
with open(os.path.join(local_path, tmp_out)) as f:
return f.read()
output = f.read()

# delete the files to avoid overwriting:
try:
os.remove(tmp_name)
except OSError:
pass

try:
os.remove(tmp_out)
except OSError:
pass

# otherwise, read remote file
return self._download_as_raw(tmp_out).decode("latin-1")
else:
output = self._download_as_raw(tmp_out).decode("latin-1")

# Deleting the previous files
self.slashdelete(tmp_name)
self.slashdelete(tmp_out)

return output

def _get_file_path(self, fname, progress_bar=False):
"""Find files in the Python and MAPDL working directories.
Expand Down