version.py: make function names more clear (#23216)

* rename a few version functions

* and is_prebuilt

* and some formatting 😊
pull/23113/head
Shane Smiskol 3 years ago committed by GitHub
parent 084ef39489
commit b745a14ff7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      selfdrive/athena/manage_athenad.py
  2. 4
      selfdrive/car/car_helpers.py
  3. 4
      selfdrive/manager/build.py
  4. 12
      selfdrive/manager/manager.py
  5. 4
      selfdrive/tombstoned.py
  6. 4
      selfdrive/updated.py
  7. 21
      selfdrive/version.py

@ -6,7 +6,7 @@ from multiprocessing import Process
from common.params import Params
from selfdrive.manager.process import launcher
from selfdrive.swaglog import cloudlog
from selfdrive.version import get_version, get_dirty
from selfdrive.version import get_version, is_dirty
ATHENA_MGR_PID_PARAM = "AthenadPid"
@ -14,7 +14,7 @@ ATHENA_MGR_PID_PARAM = "AthenadPid"
def main():
params = Params()
dongle_id = params.get("DongleId").decode('utf-8')
cloudlog.bind_global(dongle_id=dongle_id, version=get_version(), dirty=get_dirty())
cloudlog.bind_global(dongle_id=dongle_id, version=get_version(), dirty=is_dirty())
try:
while 1:

@ -1,7 +1,7 @@
import os
from common.params import Params
from common.basedir import BASEDIR
from selfdrive.version import get_comma_remote, get_tested_branch
from selfdrive.version import is_comma_remote, is_tested_branch
from selfdrive.car.fingerprints import eliminate_incompatible_cars, all_legacy_fingerprint_cars
from selfdrive.car.vin import get_vin, VIN_UNKNOWN
from selfdrive.car.fw_versions import get_fw_versions, match_fw_to_car
@ -14,7 +14,7 @@ EventName = car.CarEvent.EventName
def get_startup_event(car_recognized, controller_available, fw_seen):
if get_comma_remote() and get_tested_branch():
if is_comma_remote() and is_tested_branch():
event = EventName.startup
else:
event = EventName.startupMaster

@ -12,7 +12,7 @@ from common.spinner import Spinner
from common.text_window import TextWindow
from selfdrive.hardware import TICI
from selfdrive.swaglog import cloudlog, add_file_handler
from selfdrive.version import get_dirty
from selfdrive.version import is_dirty
MAX_CACHE_SIZE = 4e9 if "CI" in os.environ else 2e9
CACHE_DIR = Path("/data/scons_cache" if TICI else "/tmp/scons_cache")
@ -98,4 +98,4 @@ def build(spinner, dirty=False):
if __name__ == "__main__" and not PREBUILT:
spinner = Spinner()
spinner.update_progress(0, 100)
build(spinner, get_dirty())
build(spinner, is_dirty())

@ -18,8 +18,8 @@ from selfdrive.manager.process import ensure_running
from selfdrive.manager.process_config import managed_processes
from selfdrive.athena.registration import register, UNREGISTERED_DONGLE_ID
from selfdrive.swaglog import cloudlog, add_file_handler
from selfdrive.version import get_dirty, get_commit, get_version, get_origin, get_short_branch, \
terms_version, training_version, get_comma_remote
from selfdrive.version import is_dirty, get_commit, get_version, get_origin, get_short_branch, \
terms_version, training_version, is_comma_remote
sys.path.append(os.path.join(BASEDIR, "pyextra"))
@ -86,16 +86,16 @@ def manager_init():
raise Exception(f"Registration failed for device {serial}")
os.environ['DONGLE_ID'] = dongle_id # Needed for swaglog
if not get_dirty():
if not is_dirty():
os.environ['CLEAN'] = '1'
cloudlog.bind_global(dongle_id=dongle_id, version=get_version(), dirty=get_dirty(),
cloudlog.bind_global(dongle_id=dongle_id, version=get_version(), dirty=is_dirty(),
device=HARDWARE.get_device_type())
if get_comma_remote() and not (os.getenv("NOLOG") or os.getenv("NOCRASH") or PC):
if is_comma_remote() and not (os.getenv("NOLOG") or os.getenv("NOCRASH") or PC):
crash.init()
crash.bind_user(id=dongle_id)
crash.bind_extra(dirty=get_dirty(), origin=get_origin(), branch=get_short_branch(), commit=get_commit(),
crash.bind_extra(dirty=is_dirty(), origin=get_origin(), branch=get_short_branch(), commit=get_commit(),
device=HARDWARE.get_device_type())

@ -15,7 +15,7 @@ from common.file_helpers import mkdirs_exists_ok
from selfdrive.hardware import TICI, HARDWARE
from selfdrive.loggerd.config import ROOT
from selfdrive.swaglog import cloudlog
from selfdrive.version import get_branch, get_commit, get_dirty, get_origin, get_version
from selfdrive.version import get_branch, get_commit, is_dirty, get_origin, get_version
MAX_SIZE = 100000 * 10 # mal size is 40-100k, allow up to 1M
if TICI:
@ -207,7 +207,7 @@ def main():
dongle_id = Params().get("DongleId", encoding='utf-8')
sentry_sdk.set_user({"id": dongle_id})
sentry_sdk.set_tag("dirty", get_dirty())
sentry_sdk.set_tag("dirty", is_dirty())
sentry_sdk.set_tag("origin", get_origin())
sentry_sdk.set_tag("branch", get_branch())
sentry_sdk.set_tag("commit", get_commit())

@ -40,7 +40,7 @@ from common.params import Params
from selfdrive.hardware import EON, TICI, HARDWARE
from selfdrive.swaglog import cloudlog
from selfdrive.controls.lib.alertmanager import set_offroad_alert
from selfdrive.version import get_tested_branch
from selfdrive.version import is_tested_branch
LOCK_FILE = os.getenv("UPDATER_LOCK_FILE", "/tmp/safe_staging_overlay.lock")
STAGING_ROOT = os.getenv("UPDATER_STAGING_ROOT", "/data/safe_staging")
@ -142,7 +142,7 @@ def set_params(new_version: bool, failed_count: int, exception: Optional[str]) -
now = datetime.datetime.utcnow()
dt = now - last_update
if failed_count > 15 and exception is not None:
if get_tested_branch():
if is_tested_branch():
extra_text = "Ensure the software is correctly installed"
else:
extra_text = exception

@ -7,7 +7,6 @@ from functools import lru_cache
from common.basedir import BASEDIR
from selfdrive.swaglog import cloudlog
TESTED_BRANCHES = ['devel', 'release2-staging', 'release3-staging', 'dashcam-staging', 'release2', 'release3', 'dashcam']
training_version: bytes = b"0.2.0"
@ -62,12 +61,12 @@ def get_version() -> str:
@cache
def get_prebuilt() -> bool:
def is_prebuilt() -> bool:
return os.path.exists(os.path.join(BASEDIR, 'prebuilt'))
@cache
def get_comma_remote() -> bool:
def is_comma_remote() -> bool:
origin = get_origin()
if origin is None:
return False
@ -76,12 +75,12 @@ def get_comma_remote() -> bool:
@cache
def get_tested_branch() -> bool:
def is_tested_branch() -> bool:
return get_short_branch() in TESTED_BRANCHES
@cache
def get_dirty() -> bool:
def is_dirty() -> bool:
origin = get_origin()
branch = get_branch()
if (origin is None) or (branch is None):
@ -90,7 +89,7 @@ def get_dirty() -> bool:
dirty = False
try:
# Actually check dirty files
if not get_prebuilt():
if not is_prebuilt():
# This is needed otherwise touched files might show up as modified
try:
subprocess.check_call(["git", "update-index", "--refresh"])
@ -100,15 +99,15 @@ def get_dirty() -> bool:
dirty = (subprocess.call(["git", "diff-index", "--quiet", branch, "--"]) != 0)
# Log dirty files
if dirty and get_comma_remote():
if dirty and is_comma_remote():
try:
dirty_files = run_cmd(["git", "diff-index", branch, "--"])
cloudlog.event("dirty comma branch", version=get_version(), dirty=dirty, origin=origin, branch=branch,
dirty_files=dirty_files, commit=get_commit(), origin_commit=get_commit(branch))
dirty_files=dirty_files, commit=get_commit(), origin_commit=get_commit(branch))
except subprocess.CalledProcessError:
pass
dirty = dirty or (not get_comma_remote())
dirty = dirty or (not is_comma_remote())
dirty = dirty or ('master' in branch)
except subprocess.CalledProcessError:
@ -125,9 +124,9 @@ if __name__ == "__main__":
params.put("TermsVersion", terms_version)
params.put("TrainingVersion", training_version)
print("Dirty: %s" % get_dirty())
print("Dirty: %s" % is_dirty())
print("Version: %s" % get_version())
print("Origin: %s" % get_origin())
print("Branch: %s" % get_branch())
print("Short branch: %s" % get_short_branch())
print("Prebuilt: %s" % get_prebuilt())
print("Prebuilt: %s" % is_prebuilt())

Loading…
Cancel
Save