autotest: Delete gmail credentials config
BUG=b:191304437
TEST=None
Change-Id: I97321b90ecad2f8397a3e738bd1084968242c190
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/autotest/+/2971194
Commit-Queue: Allen Li <ayatane@chromium.org>
Tested-by: Allen Li <ayatane@chromium.org>
Auto-Submit: Allen Li <ayatane@chromium.org>
Reviewed-by: Derek Beckett <dbeckett@chromium.org>
Reviewed-by: Congbin Guo <guocb@chromium.org>
diff --git a/global_config.ini b/global_config.ini
index a2b8ba0..9bd02f4 100644
--- a/global_config.ini
+++ b/global_config.ini
@@ -390,7 +390,6 @@
chromium_build_url: http://build.chromium.org/p/chromiumos/
sheriffs: USE SHADOW SHERIFFS
lab_sheriffs: USE SHADOW SHERIFFS
-gmail_api_credentials:
gmail_api_credentials_test_failure:
[SSP]
diff --git a/site_utils/gmail_lib.py b/site_utils/gmail_lib.py
index 6b8c0a7..69410bc 100755
--- a/site_utils/gmail_lib.py
+++ b/site_utils/gmail_lib.py
@@ -25,36 +25,21 @@
import httplib2
import logging
import sys
-import os
import random
from email.mime.text import MIMEText
import common
-from autotest_lib.client.bin import utils
-from autotest_lib.client.common_lib import global_config
from autotest_lib.server import site_utils
try:
- from apiclient.discovery import build as apiclient_build
- from apiclient import errors as apiclient_errors
- from oauth2client import file as oauth_client_fileio
+ from apiclient.discovery import build as apiclient_build
+ from apiclient import errors as apiclient_errors
+ from oauth2client import file as oauth_client_fileio
except ImportError as e:
- apiclient_build = None
- logging.debug("API client for gmail disabled. %s", e)
-
-# Note: These imports needs to come after the apiclient imports, because
-# of a sys.path war between chromite and autotest crbug.com/622988
-from autotest_lib.server import utils as server_utils
-from autotest_lib.utils.frozen_chromite.lib import retry_util
-
-try:
- from autotest_lib.utils.frozen_chromite.lib import metrics
-except ImportError:
- metrics = utils.metrics_mock
+ apiclient_build = None
+ logging.debug("API client for gmail disabled. %s", e)
-DEFAULT_CREDS_FILE = global_config.global_config.get_config_value(
- 'NOTIFICATIONS', 'gmail_api_credentials', default=None)
RETRY_DELAY = 5
RETRY_BACKOFF_FACTOR = 1.5
MAX_RETRY = 10
@@ -141,48 +126,8 @@
@param creds_path: The credential path for gmail account, if None,
will use DEFAULT_CREDS_FILE.
"""
- auth_creds = server_utils.get_creds_abspath(
- creds_path or DEFAULT_CREDS_FILE)
- if not auth_creds or not os.path.isfile(auth_creds):
- logging.error('Failed to send email to %s: Credential file does not '
- 'exist: %s. If this is a prod server, puppet should '
- 'install it. If you need to be able to send email, '
- 'find the credential file from chromeos-admin repo and '
- 'copy it to %s', to, auth_creds, auth_creds)
- return
- client = GmailApiClient(oauth_credentials=auth_creds)
- m = Message(to, subject, message_text)
- retry_count = MAX_RETRY if retry else 0
-
- def _run():
- """Send the message."""
- client.send_message(m, ignore_error=False)
-
- def handler(exc):
- """Check if exc is an HttpError and is retriable.
-
- @param exc: An exception.
-
- @return: True if is an retriable HttpError.
- """
- if not isinstance(exc, apiclient_errors.HttpError):
- return False
-
- error_msg = str(exc)
- should_retry = any([msg in error_msg for msg in RETRIABLE_MSGS])
- if should_retry:
- logging.warning('Will retry error %s', exc)
- return should_retry
-
- success = False
- try:
- retry_util.GenericRetry(
- handler, retry_count, _run, sleep=RETRY_DELAY,
- backoff_factor=RETRY_BACKOFF_FACTOR)
- success = True
- finally:
- metrics.Counter('chromeos/autotest/send_email/count').increment(
- fields={'success': success})
+ # TODO(ayatane): Deprecated, not untangling imports now
+ pass
if __name__ == '__main__':