Skip to content

Commit

Permalink
fix: blinking windows when loading models tracked by git (#960)
Browse files Browse the repository at this point in the history
* fix: prevent windows blinking when calling subprocess calls git info

* Add changelog entry
  • Loading branch information
melund authored May 7, 2024
1 parent a6e76ce commit 4b7f605
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 16 deletions.
45 changes: 32 additions & 13 deletions Body/AAUHuman/BodyModels/GenericBodyModel/git_info.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from pathlib import Path
import subprocess
from dataclasses import dataclass
from pathlib import Path
from typing import Tuple
import subprocess


@dataclass
Expand All @@ -14,9 +14,6 @@ class AMSContext:
call_location_file: str


import subprocess
from pathlib import Path
from typing import Tuple


def git_info(context: tuple, fpath: str) -> Tuple[str, str]:
Expand All @@ -42,28 +39,50 @@ def git_info(context: tuple, fpath: str) -> Tuple[str, str]:
if not gitfolder.is_dir():
return "unknown", "unknown"

options = dict(
creationflags=subprocess.CREATE_NO_WINDOW,
timeout=2,
text=True,
)

try:
subprocess.run(["git", "--version"], capture_output=True, timeout=1, check=True)
except (subprocess.CalledProcessError, subprocess.TimeoutExpired, FileNotFoundError) as e:
subprocess.run(["git", "--version"], capture_output=True, **options)
except (
subprocess.CalledProcessError,
subprocess.TimeoutExpired,
FileNotFoundError,
):
return "unknown", "unknown"

basecmd = ["git", "-C", f"{gitfolder.absolute()}"]
try:
cmd = basecmd + ["rev-parse", "HEAD"]
hashref = subprocess.check_output(cmd, text=True, timeout=2).strip()
except (subprocess.CalledProcessError, subprocess.TimeoutExpired, FileNotFoundError) as e:
hashref = subprocess.check_output(cmd, **options).strip()
except (
subprocess.CalledProcessError,
subprocess.TimeoutExpired,
FileNotFoundError,
):
hashref = "unknown"

try:
cmd = basecmd + ["symbolic-ref", "-q", "--short", "HEAD"]
branch_name = subprocess.check_output(cmd, text=True, timeout=2).strip()
except (subprocess.CalledProcessError, subprocess.TimeoutExpired, FileNotFoundError) as e:
branch_name = subprocess.check_output(cmd, **options).strip()
except (
subprocess.CalledProcessError,
subprocess.TimeoutExpired,
FileNotFoundError,
):
branch_name = None

try:
cmd = basecmd + ["describe", "--tags", "--always"]
tag_name = subprocess.check_output(cmd, text=True, timeout=2).strip()
except (subprocess.CalledProcessError, subprocess.TimeoutExpired, FileNotFoundError) as e:
tag_name = subprocess.check_output(cmd, **options).strip()
except (
subprocess.CalledProcessError,
subprocess.TimeoutExpired,
FileNotFoundError,
):
tag_name = "unknown"

ref = branch_name or tag_name
Expand Down
9 changes: 6 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@
### 🩹 Fixed:
* Fixed a penetration warning for the pectoralis muscles when the thoracic segments is scaled very non-uniformly.
The fix involves a small (5 deg) adjustments to the orientation of the pectoralis wrapping surface.

* The foot marker position in the Xsens protocol has been updated to account for the changes to the foot anatomical frame introduced with the TLEM 2.2 leg model. The R/LTOE and
R/LTOE2 markers have been moved upwards by 1.5 cm.
* Fixed an issue where blinking Windows would appear when loading models stored
in git repositories. This issue was caused by a python subprocess that queried
the git repository for branch information.
* Updated the foot marker position in the Xsens protocol to accommodate the
changes made to the foot anatomical frame in the TLEM 2.2 leg model. The
R/LTOE and R/LTOE2 markers have been moved upwards by 1.5 cm.

(ammr-3.0.1-changelog)=
## AMMR 3.0.1 (2024-02-13)
Expand Down

0 comments on commit 4b7f605

Please sign in to comment.