Skip to content

Commit

Permalink
Store build exit code in conf
Browse files Browse the repository at this point in the history
  • Loading branch information
17451k committed Jul 20, 2021
1 parent c1919ae commit 0a89a46
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
4 changes: 3 additions & 1 deletion clade/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def intercept(self, command, cwd=os.getcwd(), append=False, use_wrappers=False,

self.__prepare_to_intercept()

return intercept(
self.conf["build_exit_code"] = intercept(
command=command,
cwd=cwd,
output=self.cmds_file,
Expand All @@ -154,6 +154,8 @@ def intercept(self, command, cwd=os.getcwd(), append=False, use_wrappers=False,
conf=self.conf
)

return self.conf["build_exit_code"]

def __get_ext_obj(self, ext_name):
"""Return object of specified extension."""

Expand Down
15 changes: 12 additions & 3 deletions clade/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ def prepare_conf(args):
def main(sys_args=sys.argv[1:]):
args = parse_args(sys_args)
conf = prepare_conf(args)
build_exit_code = 0

# Create Clade interface object
try:
Expand All @@ -184,17 +185,22 @@ def main(sys_args=sys.argv[1:]):

c.logger.info("Starting build")
build_time_start = time.time()
r = c.intercept(conf["build_command"], use_wrappers=conf["use_wrappers"], append=args.append, intercept_open=args.intercept_open)
build_exit_code = c.intercept(
conf["build_command"],
use_wrappers=conf["use_wrappers"],
append=args.append,
intercept_open=args.intercept_open
)

build_delta = datetime.timedelta(seconds=(time.time() - build_time_start))
build_delta_str = str(build_delta).split(".")[0]

# Clade can still proceed further if exit code != 0
c.logger.error("Build finished in {} with exit code {}".format(build_delta_str, r))
c.logger.error("Build finished in {} with exit code {}".format(build_delta_str, build_exit_code))

if args.intercept and os.path.exists(conf["cmds_file"]):
c.logger.info("Path to the file with intercepted commands: {!r}".format(conf["cmds_file"]))
sys.exit(r)
sys.exit(build_exit_code)

if not os.path.exists(conf["cmds_file"]):
c.logger.error("Something is wrong: file with intercepted commands is empty")
Expand All @@ -210,6 +216,9 @@ def main(sys_args=sys.argv[1:]):
ext_delta = datetime.timedelta(seconds=(time.time() - ext_time_start))
ext_delta_str = str(ext_delta).split(".")[0]
c.logger.info("Extensions finished in {}".format(ext_delta_str))

if build_exit_code != 0:
c.logger.error("Reminder that build finished with exit code {}".format(build_exit_code))
except RuntimeError as e:
if e.args:
raise SystemExit(e)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ def finalize_options(self):

setuptools.setup(
name="clade",
version="3.4.2",
version="3.4.3",
author="Ilya Shchepetkov",
author_email="[email protected]",
url="https://github.com/17451k/clade",
Expand Down

0 comments on commit 0a89a46

Please sign in to comment.