Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: blinking windows when loading models tracked by git #960

Merged
merged 2 commits into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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