forked from alisw/alibuild
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
45 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from shlex import quote # Python 3.3+ | ||
from alibuild_helpers.cmd import getstatusoutput | ||
from alibuild_helpers.log import debug | ||
|
||
SL_COMMAND_TIMEOUT_SEC = 120 | ||
"""How many seconds to let any sl command execute before being terminated.""" | ||
|
||
def sapling(args, directory=".", check=True, prompt=True): | ||
debug("Executing sl %s (in directory %s)", " ".join(args), directory) | ||
# We can't use git --git-dir=%s/.git or git -C %s here as the former requires | ||
# that the directory we're inspecting to be the root of a git directory, not | ||
# just contained in one (and that breaks CI tests), and the latter isn't | ||
# supported by the git version we have on slc6. | ||
# Silence cd as shell configuration can cause the new directory to be echoed. | ||
err, output = getstatusoutput("""\ | ||
set -e +x | ||
cd {directory} >/dev/null 2>&1 | ||
sl {args} | ||
""".format( | ||
directory=quote(directory), | ||
args=" ".join(map(quote, args)), | ||
), timeout=SL_COMMAND_TIMEOUT_SEC) | ||
if check and err != 0: | ||
raise RuntimeError("Error {} from sl {}: {}".format(err, " ".join(args), output)) | ||
return output if check else (err, output) |