[autotest] test failure send email via a different gmail account
Test failures notification emails sometimes causing quota issues
when a huge amount of notifications are sent out around the same time.
Move it to a different gmail account to gurantee that more
critical emails like inventory emails can be sent out on time.
Also, add support for a "creds" dir.
TEST=send email using the new gmail account:
- with gmail_api_credentials_test_failure and creds dir set.
confirm using new credentials.
- without gmail_api_credentials_test_failure and creds dir set.
confirm using the default credentials.
BUG=chromium:541824;chromium:567882
Change-Id: I191e14303cdead164147d188ac495da6f7c18ba6
Reviewed-on: https://chromium-review.googlesource.com/316680
Commit-Ready: Fang Deng <fdeng@chromium.org>
Tested-by: Fang Deng <fdeng@chromium.org>
Reviewed-by: Fang Deng <fdeng@chromium.org>
diff --git a/server/site_utils.py b/server/site_utils.py
index 1ebff49..6d44467 100644
--- a/server/site_utils.py
+++ b/server/site_utils.py
@@ -691,3 +691,24 @@
return (machine['hostname'], machine['host_attributes'])
else:
return (machine, {})
+
+
+def get_creds_abspath(creds_file):
+ """Returns the abspath of the credentials file.
+
+ If creds_file is already an absolute path, just return it.
+ Otherwise, assume it is located in the creds directory
+ specified in global_config and return the absolute path.
+
+ @param: creds_path, a path to the credentials.
+ @return: An absolute path to the credentials file.
+ """
+ if not creds_file:
+ return None
+ if os.path.isabs(creds_file):
+ return creds_file
+ creds_dir = global_config.global_config.get_config_value(
+ 'SERVER', 'creds_dir', default='')
+ if not creds_dir or not os.path.exists(creds_dir):
+ creds_dir = common.autotest_dir
+ return os.path.join(creds_dir, creds_file)