Newer
Older
def app_version():
import git
version_file = open(f"{_project}/resources/app-version.json", "w+")
try:
repo = git.Repo(".")
gitHash = repo.head.commit.hexsha
version = repo.git.describe(tags=True, first_parent=True, always=True)
url = os.environ.get("CI_PROJECT_URL", repo.remotes.origin.url)
if "gitlab-ci-token" in url:
url = re.sub(r"gitlab-ci-token\:.*@", "", url)
version_info = dict(
gitHash=gitHash,
projectName="ncm-ws",
url=url,
version=version,
)
version_file.write(json.dumps(version_info, indent=2))
except Exception as error:
print("Failed to create version file. Writing blank file.")
version_file.write(json.dumps("{}"))
# Install database
args = sys.argv
args.remove(args[0])
check_call(["python", "-m", "ncm_database"] + args)
def thermod():
# Run TherMod
args = sys.argv
args.remove(args[0])
check_call(["python", "-m", _project] + args)
def example():
# Run TherMod examples
os.system("bash thermod/resources/example.sh")
def help():
# Run Python help command
check_call(["python", "-m", _project, "-h"])
def format_check():
# Check code format
check_call(["isort", "--check", "--diff", ".", "--skip", ".venv"])
check_call(["black", "--check", "--diff", ".", "--exclude", ".venv"])