Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ExpandObjects command retrieval issue #526

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
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
19 changes: 7 additions & 12 deletions archetypal/eplus_interface/expand_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ def __init__(self, idf, tmp_dir):
super().__init__(idf)
self.running_directory = tmp_dir

@property
def cmd(self):
"""Get the command line to run ExpandObjects."""
return shutil.which("ExpandObjects", path=self.eplus_home)


class ExpandObjectsThread(Thread):
"""ExpandObjects program manager."""
Expand All @@ -41,12 +46,6 @@ def __init__(self, idf, tmp):
self.name = "ExpandObjects_" + self.idf.name
self.tmp = tmp

@property
def cmd(self):
"""Get the command."""
cmd_path = Path(shutil.which("ExpandObjects", path=self.run_dir))
return [str(cmd_path.name)]

def run(self):
"""Wrapper around the ExpandObject command line interface."""

Expand All @@ -55,13 +54,9 @@ def run(self):
self.idfname = Path(self.idf.savecopy(self.run_dir / "in.idf")).expand()
self.idd = self.idf.iddname.copy(self.run_dir / "Energy+.idd").expand()

# Get executable using shutil.which
expand_object_exe = shutil.which("ExpandObjects", path=self.eplus_home)
self.expand_object_exe = Path(expand_object_exe).copy(self.run_dir)

# Run ExpandObjects Program
self.p = subprocess.Popen(
self.cmd,
args=ExpandObjectsExe(self.idf, self.run_dir).cmd,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
shell=False, # can use shell
Expand All @@ -72,7 +67,7 @@ def run(self):

# Read stdout line by line
loggers = [lg.getLogger("archetypal")]
with tqdm_logging_redirect(desc=f"{expand_object_exe} {self.idf.name}", loggers=loggers) as pbar:
with tqdm_logging_redirect(desc=f"{self.p.args} {self.idf.name}", loggers=loggers) as pbar:
for line in iter(self.p.stdout.readline, b""):
decoded_line = line.decode("utf-8").strip()
self.msg_callback(decoded_line)
Expand Down
Loading