Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(302)

Unified Diff: appengine/swarming/swarming_bot/api/bot.py

Issue 2024313003: Send authorization headers when calling Swarming backend. (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/luci-py@master
Patch Set: rebase Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « appengine/swarming/server/bot_archive.py ('k') | appengine/swarming/swarming_bot/api/bot_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: appengine/swarming/swarming_bot/api/bot.py
diff --git a/appengine/swarming/swarming_bot/api/bot.py b/appengine/swarming/swarming_bot/api/bot.py
index 0c67b6f865b5c2fc9d696b44460705540f08ef62..e9bb5288a77a9081ce9b2c1df02e3d4459e4bd49 100644
--- a/appengine/swarming/swarming_bot/api/bot.py
+++ b/appengine/swarming/swarming_bot/api/bot.py
@@ -10,7 +10,6 @@ import threading
import time
import os_utilities
-from utils import net
from utils import zip_package
THIS_FILE = os.path.abspath(zip_package.get_main_script_path())
@@ -20,11 +19,13 @@ THIS_FILE = os.path.abspath(zip_package.get_main_script_path())
class Bot(object):
def __init__(
- self, attributes, server, server_version, base_dir, shutdown_hook):
+ self, remote, attributes, server, server_version, base_dir,
+ shutdown_hook):
# Do not expose attributes for now, as attributes may be refactored.
assert server is None or not server.endswith('/'), server
self._attributes = attributes
self._base_dir = base_dir
+ self._remote = remote
self._server = server
self._server_version = server_version
self._shutdown_hook = shutdown_hook
@@ -57,6 +58,14 @@ class Bot(object):
return self.dimensions.get('id', ['unknown'])[0]
@property
+ def remote(self):
+ """RemoteClient to talk to the server.
+
+ Should not be normally used by bot_config.py for now.
+ """
+ return self._remote
+
+ @property
def server(self):
"""URL of the swarming server this bot is connected to.
@@ -96,7 +105,7 @@ class Bot(object):
data = self._attributes.copy()
data['event'] = event_type
data['message'] = message
- net.url_read_json(self.server + '/swarming/api/v1/bot/event', data=data)
+ self._remote.url_read_json('/swarming/api/v1/bot/event', data=data)
def post_error(self, message):
"""Posts given string as a failure.
« no previous file with comments | « appengine/swarming/server/bot_archive.py ('k') | appengine/swarming/swarming_bot/api/bot_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698