INNER CODE UNIT · Python
close
terraform-aws-modules/terraform-aws-lambda · package.py:341
def close(self, failed=False):
self._zip.close()
self._zip = None
if not os.path.exists(self._tmp_filename):
return
if failed:
os.unlink(self._tmp_filename)
else:
os.replace(self._tmp_filename, self.filename)
def __enter__(self):
return self.open()
def __exit__(self, exc_type, exc_val, exc_tb):
if exc_type is not None:
# If the failure is a CalledProcessError that captured stderr,
# surface that stderr in the log so the operator can see what
# the underlying subprocess (typically pip) actually said.