Skip to content

Commit

Permalink
Catch errors when trying to write fetch-log.txt
Browse files Browse the repository at this point in the history
  • Loading branch information
TimoWilken committed Sep 6, 2023
1 parent 8484cd9 commit fe1e48c
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions alibuild_helpers/workarea.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
except ImportError:
from ordereddict import OrderedDict

from alibuild_helpers.log import dieOnError, debug, info
from alibuild_helpers.log import dieOnError, debug, info, error
from alibuild_helpers.git import git, clone_speedup_options

FETCH_LOG_NAME = "fetch-log.txt"
Expand Down Expand Up @@ -44,11 +44,14 @@ def logged_git(package, referenceSources,
if logOutput:
debug(output)
if err:
with codecs.open(os.path.join(referenceSources, FETCH_LOG_NAME),
"a", encoding="utf-8", errors="replace") as logf:
logf.write("Git command for package %r failed.\n"
"Command: git %s\nIn directory: %s\nExit code: %d\n" %
(package, " ".join(command), directory, err))
try:
with codecs.open(os.path.join(referenceSources, FETCH_LOG_NAME),
"a", encoding="utf-8", errors="replace") as logf:
logf.write("Git command for package %r failed.\n"
"Command: git %s\nIn directory: %s\nExit code: %d\n" %
(package, " ".join(command), directory, err))
except OSError as exc:
error("Could not write error log from git command:", exc_info=exc)
dieOnError(err, "Error during git %s for reference repo for %s." %
(command[0], package))
info("Done git %s for repository for %s", command[0], package)
Expand Down

0 comments on commit fe1e48c

Please sign in to comment.