Quellcode durchsuchen

build_telemetry: Print status

It's unclear what the status is.

`build_telemetry status` or just `build_telemetry` prints the status.

Bug: 354726696
Change-Id: Id6d17a263f8ff6bea107499cee3ebe26ee422454
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5732737
Commit-Queue: Junji Watanabe <jwata@google.com>
Reviewed-by: Fumitoshi Ukai <ukai@google.com>
Commit-Queue: Fumitoshi Ukai <ukai@google.com>
Auto-Submit: Junji Watanabe <jwata@google.com>
Junji Watanabe vor 1 Jahr
Ursprung
Commit
14ce8321ec
1 geänderte Dateien mit 23 neuen und 1 gelöschten Zeilen
  1. 23 1
      build_telemetry.py

+ 23 - 1
build_telemetry.py

@@ -127,6 +127,9 @@ class Config:
         self.save()
         print("build telemetry collection is opted out")
 
+    def status(self):
+        return self._config["status"]
+
 
 def load_config(cfg_path=_DEFAULT_CONFIG_PATH, countdown=_DEFAULT_COUNTDOWN):
     """Loads the config from the default location."""
@@ -161,9 +164,22 @@ def enabled():
     return cfg.enabled()
 
 
+def print_status(cfg):
+    status = cfg.status()
+    if status == "opt-in":
+        print("build telemetry collection is enabled. You have opted in.")
+    elif status == "opt-out":
+        print("build telemetry collection is disabled. You have opted out.")
+    else:
+        print("build telemetry collection is enabled.")
+    print("")
+
+
 def main():
     parser = argparse.ArgumentParser(prog="build_telemetry")
-    parser.add_argument('status', choices=['opt-in', 'opt-out'])
+    parser.add_argument('status',
+                        nargs='?',
+                        choices=["opt-in", "opt-out", "status"])
     args = parser.parse_args()
 
     cfg = load_config()
@@ -178,6 +194,12 @@ def main():
     if args.status == "opt-out":
         cfg.opt_out()
         return
+    if args.status == "status":
+        print_status(cfg)
+        return
+
+    print_status(cfg)
+    parser.print_help()
 
 
 if __name__ == "__main__":