Make stats upload more robust.

Print exceptions resulting from creation of the Stats object, but don't
quit the script.

BUG=chromium:236714
TEST=Unit tests, ran locally.

Change-Id: Ica6ec7fd9bcc5b7b54de69af391e4e2e8258e37b
Reviewed-on: https://gerrit.chromium.org/gerrit/49611
Commit-Queue: Ryan Cui <rcui@chromium.org>
Reviewed-by: Ryan Cui <rcui@chromium.org>
Tested-by: Ryan Cui <rcui@chromium.org>
diff --git a/scripts/deploy_chrome.py b/scripts/deploy_chrome.py
index 92d950c..464515d 100644
--- a/scripts/deploy_chrome.py
+++ b/scripts/deploy_chrome.py
@@ -501,8 +501,9 @@
     logging.getLogger().setLevel(logging.INFO)
 
   with stats.UploadContext() as queue:
-    cmd_stats = stats.Stats(cmd_line=argv, cmd_base='deploy_chrome')
-    queue.put([cmd_stats, stats.StatsUploader.URL, 1])
+    cmd_stats = stats.Stats.SafeInit(cmd_line=argv, cmd_base='deploy_chrome')
+    if cmd_stats:
+      queue.put([cmd_stats, stats.StatsUploader.URL, 1])
 
     with osutils.TempDir(set_global=True) as tempdir:
       staging_dir = options.staging_dir