Пример #1
0
def init(project: SentryProject) -> None:
  # forks like to mess with this, so double check
  comma_remote = is_comma_remote() and "commaai" in get_origin(default="")
  if not comma_remote or not is_registered_device() or PC:
    return

  env = "release" if is_tested_branch() else "master"
  dongle_id = Params().get("DongleId", encoding='utf-8')

  integrations = []
  if project == SentryProject.SELFDRIVE:
    integrations.append(ThreadingIntegration(propagate_hub=True))
  else:
    sentry_sdk.utils.MAX_STRING_LENGTH = 8192

  sentry_sdk.init(project.value,
                  default_integrations=False,
                  release=get_version(),
                  integrations=integrations,
                  traces_sample_rate=1.0,
                  environment=env)

  sentry_sdk.set_user({"id": dongle_id})
  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())
  sentry_sdk.set_tag("device", HARDWARE.get_device_type())

  if project == SentryProject.SELFDRIVE:
    sentry_sdk.Hub.current.start_session()
Пример #2
0
def getVersion() -> Dict[str, str]:
    return {
        "version": get_version(),
        "remote": get_origin(''),
        "branch": get_short_branch(''),
        "commit": get_commit(default=''),
    }
Пример #3
0
        print(diff)
        with open("debayer_diff.txt", "w") as f:
          f.write(diff)
    except Exception as e:
      print(str(e))
      failed = True

  # upload new refs
  if update or (failed and TICI):
    from selfdrive.test.openpilotci import upload_file

    print("Uploading new refs")

    frames_bzip = bzip_frames(frames)

    new_commit = get_commit()
    frame_fn = os.path.join(replay_dir, get_frame_fn(new_commit, TEST_ROUTE, tici=TICI))
    with open(frame_fn, "wb") as f2:
      f2.write(frames_bzip)

    try:
      upload_file(frame_fn, os.path.basename(frame_fn))
    except Exception as e:
      print("failed to upload", e)

  if update:
    with open(ref_commit_fn, 'w') as f:
      f.write(str(new_commit))

    print("\nNew ref commit: ", new_commit)
Пример #4
0
                 == all_procs) and (tested_cars == all_cars) and all(
                     len(x) == 0
                     for x in (args.ignore_fields, args.ignore_msgs))
    upload = args.update_refs or args.upload_only
    os.makedirs(os.path.dirname(FAKEDATA), exist_ok=True)

    if upload:
        assert full_test, "Need to run full test when updating refs"

    try:
        ref_commit = open(REF_COMMIT_FN).read().strip()
    except FileNotFoundError:
        print("Couldn't find reference commit")
        sys.exit(1)

    cur_commit = get_commit()
    if cur_commit is None:
        raise Exception("Couldn't get current commit")

    print(f"***** testing against commit {ref_commit} *****")

    # check to make sure all car brands are tested
    if full_test:
        untested = (set(interface_names) - set(excluded_interfaces)) - {
            c.lower()
            for c in tested_cars
        }
        assert len(untested) == 0, f"Cars missing routes: {str(untested)}"

    with concurrent.futures.ProcessPoolExecutor(max_workers=args.jobs) as pool:
        if not args.upload_only:
Пример #5
0
def manager_init() -> None:
    # update system time from panda
    set_time(cloudlog)

    # save boot log
    subprocess.call("./bootlog",
                    cwd=os.path.join(BASEDIR, "selfdrive/loggerd"))

    params = Params()
    params.clear_all(ParamKeyType.CLEAR_ON_MANAGER_START)

    default_params: List[Tuple[str, Union[str, bytes]]] = [
        ("CompletedTrainingVersion", "0"),
        ("DisengageOnAccelerator", "1"),
        ("HasAcceptedTerms", "0"),
        ("OpenpilotEnabledToggle", "1"),
    ]
    if not PC:
        default_params.append(
            ("LastUpdateTime",
             datetime.datetime.utcnow().isoformat().encode('utf8')))

    if params.get_bool("RecordFrontLock"):
        params.put_bool("RecordFront", True)

    if not params.get_bool("DisableRadar_Allow"):
        params.delete("DisableRadar")

    # set unset params
    for k, v in default_params:
        if params.get(k) is None:
            params.put(k, v)

    # is this dashcam?
    if os.getenv("PASSIVE") is not None:
        params.put_bool("Passive", bool(int(os.getenv("PASSIVE", "0"))))

    if params.get("Passive") is None:
        raise Exception("Passive must be set to continue")

    # Create folders needed for msgq
    try:
        os.mkdir("/dev/shm")
    except FileExistsError:
        pass
    except PermissionError:
        print("WARNING: failed to make /dev/shm")

    # set version params
    params.put("Version", get_version())
    params.put("TermsVersion", terms_version)
    params.put("TrainingVersion", training_version)
    params.put("GitCommit", get_commit(default=""))
    params.put("GitBranch", get_short_branch(default=""))
    params.put("GitRemote", get_origin(default=""))
    params.put_bool("IsTestedBranch", is_tested_branch())

    # set dongle id
    reg_res = register(show_spinner=True)
    if reg_res:
        dongle_id = reg_res
    else:
        serial = params.get("HardwareSerial")
        raise Exception(f"Registration failed for device {serial}")
    os.environ['DONGLE_ID'] = dongle_id  # Needed for swaglog

    if not is_dirty():
        os.environ['CLEAN'] = '1'

    # init logging
    sentry.init(sentry.SentryProject.SELFDRIVE)
    cloudlog.bind_global(dongle_id=dongle_id,
                         version=get_version(),
                         dirty=is_dirty(),
                         device=HARDWARE.get_device_type())