aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAri Hausman-Cohen <arihc@google.com>2015-10-08 14:55:05 -0700
committerAri Hausman-Cohen <arihc@google.com>2015-10-27 14:19:41 -0700
commita01bbe8d34243603630d6c47d1d54b416c4e63d6 (patch)
treea6e0b4f3d2eccc86a897ea3349d5479b9ae0fb4d
parentf099f71bde81d4b428dd6e3210c37a012e060557 (diff)
downloadbdk-a01bbe8d34243603630d6c47d1d54b416c4e63d6.tar.gz
Adds a script to complete installation of BDK.
I.e. setup brunch/user options. BUG: 24381926, 23999994, 24382105, 24381726 Change-Id: I9ea25aee4bd97e98b8261f6ba050157b85fbbf88
-rw-r--r--brunch/lib/commands/product/build.py2
-rw-r--r--brunch/lib/complete_install.py49
2 files changed, 50 insertions, 1 deletions
diff --git a/brunch/lib/commands/product/build.py b/brunch/lib/commands/product/build.py
index cfbba79..1babf84 100644
--- a/brunch/lib/commands/product/build.py
+++ b/brunch/lib/commands/product/build.py
@@ -95,7 +95,7 @@ class Build(clicommand.Command):
# TODO(arihc): also check for not --help, since this is what build_time > 0
# is primarily checking for, and the wrapper runs lunch first,
# making basically all builds > 0 time.
- if user_store.metrics_opt_in != '0' and ret == 0 and build_time > 0:
+ if user_store.metrics_opt_in == '1' and ret == 0 and build_time > 0:
send_hits.SendHitAndRetries(brillo_ga_hits.BuildTiming(envcmd,
build_time))
diff --git a/brunch/lib/complete_install.py b/brunch/lib/complete_install.py
new file mode 100644
index 0000000..73e6578
--- /dev/null
+++ b/brunch/lib/complete_install.py
@@ -0,0 +1,49 @@
+#
+# Copyright (C) 2015 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+"""Completes the installation of brunch.
+
+Sets up user options, and reports BDK download time
+if the user opts in to metrics.
+"""
+
+import argparse
+import sys
+
+from core import config
+from metrics.data_types import brillo_ga_hits
+from metrics import send_hits
+
+def main():
+ parser = argparse.ArgumentParser(description='Install brunch.')
+ parser.add_argument('-t', '--time', type=int, default=None,
+ help='the amount of time it took to download the BDK.')
+ args = parser.parse_args()
+
+ # Set up user options
+ user_options = config.UserStore()
+ if not user_options.complete():
+ user_options.initialize()
+
+ # Offer to add brunch to $PATH
+ # TODO(arihc): Whether or not we're doing this is up in the air right now.
+
+ # Send install metrics if opted in
+ if args.time and user_options.metrics_opt_in == '1':
+ send_hits.SendHitAndRetries(brillo_ga_hits.InstallTiming(args.time))
+
+
+if __name__ == '__main__':
+ main()