Skip to content

Commit

Permalink
handle Git is not installed
Browse files Browse the repository at this point in the history
  • Loading branch information
dizcza committed Jun 10, 2021
1 parent 8576350 commit 27d37e0
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions mighty/trainer/trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,11 +183,16 @@ def log_trainer(self):
self.monitor.log(repr(self.mutual_info))
git_dir = Path(sys.argv[0]).parent
while str(git_dir) != git_dir.root:
commit = subprocess.run(['git', '--git-dir', str(git_dir / '.git'),
'rev-parse', 'HEAD'],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
universal_newlines=True)
try:
commit = subprocess.run(['git', '--git-dir',
str(git_dir / '.git'),
'rev-parse', 'HEAD'],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
universal_newlines=True)
except FileNotFoundError:
# Git is not installed
break
if commit.returncode == 0:
self.monitor.log(f"Git location '{str(git_dir)}' "
f"commit: {commit.stdout}")
Expand Down

0 comments on commit 27d37e0

Please sign in to comment.