Skip to content

Commit

Permalink
use run_shell_cmd in custom easyblock for Stata
Browse files Browse the repository at this point in the history
  • Loading branch information
branfosj committed Apr 6, 2024
1 parent a14a292 commit a07fb1e
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions easybuild/easyblocks/s/stata.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
from easybuild.easyblocks.generic.packedbinary import PackedBinary
from easybuild.tools.build_log import EasyBuildError, print_msg
from easybuild.tools.filetools import change_dir
from easybuild.tools.run import run_cmd, run_cmd_qa
from easybuild.tools.run import run_shell_cmd


class EB_Stata(PackedBinary):
Expand All @@ -45,18 +45,18 @@ def install_step(self):
change_dir(self.installdir)

cmd = os.path.join(self.cfg['start_dir'], 'install')
std_qa = {
r"Do you wish to continue\?\s*\(y/n or q to quit\)": 'y',
r"Are you sure you want to install into .*\?\s*\(y/n or q\)": 'y',
r"Okay to proceed\s*\(y/n or q to quit\)": 'y',
}
qa = [
(r"Do you wish to continue\?\s*\(y/n or q to quit\)", 'y'),
(r"Are you sure you want to install into .*\?\s*\(y/n or q\)", 'y'),
(r"Okay to proceed\s*\(y/n or q to quit\)", 'y'),
]
no_qa = [
"About to proceed with installation:",
"uncompressing files",
"extracting files",
"setting permissions",
]
run_cmd_qa(cmd, {}, no_qa=no_qa, std_qa=std_qa, log_all=True, simple=True)
run_shell_cmd(cmd, qa_patterns=qa, qa_wait_patterns=no_qa)

print_msg("Note: you need to manually run ./stinit in %s to initialise the license for Stata!",
self.installdir)
Expand All @@ -71,9 +71,9 @@ def sanity_check_step(self):

# make sure required libpng library is there for Stata
# Stata depends on a very old version of libpng, so we need to provide it
out, _ = run_cmd("ldd %s" % os.path.join(self.installdir, 'stata'), simple=False)
res = run_shell_cmd("ldd %s" % os.path.join(self.installdir, 'stata'))
regex = re.compile('libpng.*not found', re.M)
if regex.search(out):
if regex.search(res.output):
raise EasyBuildError("Required libpng library for 'stata' is not available")

def make_module_req_guess(self):
Expand Down

0 comments on commit a07fb1e

Please sign in to comment.