mirror of
https://github.com/microsoft/onefuzz.git
synced 2025-06-17 04:18:07 +00:00
initial public release
This commit is contained in:
31
src/api-service/__app__/onefuzzlib/versions.py
Normal file
31
src/api-service/__app__/onefuzzlib/versions.py
Normal file
@ -0,0 +1,31 @@
|
||||
#!/usr/bin/env python
|
||||
#
|
||||
# Copyright (c) Microsoft Corporation.
|
||||
# Licensed under the MIT License.
|
||||
|
||||
import os
|
||||
from typing import Dict
|
||||
|
||||
from memoization import cached
|
||||
from onefuzztypes.responses import Version
|
||||
|
||||
from .__version__ import __version__
|
||||
|
||||
|
||||
@cached
|
||||
def read_local_file(filename: str) -> str:
|
||||
path = os.path.join(os.path.dirname(os.path.realpath(__file__)), filename)
|
||||
if os.path.exists(path):
|
||||
with open(path, "r") as handle:
|
||||
return handle.read().strip()
|
||||
else:
|
||||
return "UNKNOWN"
|
||||
|
||||
|
||||
def versions() -> Dict[str, Version]:
|
||||
entry = Version(
|
||||
git=read_local_file("git.version"),
|
||||
build=read_local_file("build.id"),
|
||||
version=__version__,
|
||||
)
|
||||
return {"onefuzz": entry}
|
Reference in New Issue
Block a user