def get_bootstrap(self, _request): """Retrieves the current version of bootstrap.py.""" obj = bot_code.get_bootstrap('', '') return swarming_rpcs.FileContent(content=obj.content.decode('utf-8'), who=obj.who, when=obj.when, version=obj.version)
def get(self): bootstrap = bot_code.get_bootstrap(self.request.host_url) params = { "content": bootstrap.content.decode("utf-8"), "path": self.request.path, "when": bootstrap.when, "who": bootstrap.who, "xsrf_token": self.generate_xsrf_token(), } self.response.write(template.render("swarming/restricted_upload_bootstrap.html", params))
def get_bootstrap(self, request): """Retrieves the current or a previous version of bootstrap.py.""" obj = bot_code.get_bootstrap('', request.version) if not obj: return swarming_rpcs.FileContent() return swarming_rpcs.FileContent( content=obj.content.decode('utf-8'), who=obj.who.to_bytes() if obj.who else None, when=obj.when, version=obj.version)
def get(self): bootstrap = bot_code.get_bootstrap(self.request.host_url) params = { 'content': bootstrap.content.decode('utf-8'), 'path': self.request.path, 'when': bootstrap.when, 'who': bootstrap.who, 'xsrf_token': self.generate_xsrf_token(), } self.response.write( template.render('swarming/restricted_upload_bootstrap.html', params))
def get(self): # We must pass a bootstrap token (generating it, if necessary) to # get_bootstrap(...), since bootstrap.py uses tokens exclusively (it can't # transparently pass OAuth headers to /bot_code). bootstrap_token = self.check_bot_code_access(bot_id=None, generate_token=True) self.response.headers['Content-Type'] = 'text/x-python' self.response.headers['Content-Disposition'] = ( 'attachment; filename="swarming_bot_bootstrap.py"') self.response.out.write( bot_code.get_bootstrap(self.request.host_url, bootstrap_token).content)
def test_get_bootstrap(self): def get_self_config_mock(path, revision=None, store_last_good=False): self.assertEqual('scripts/bootstrap.py', path) self.assertEqual(None, revision) self.assertEqual(True, store_last_good) return None, 'foo bar' self.mock(config, 'get_self_config', get_self_config_mock) f = bot_code.get_bootstrap('localhost', 'token') expected = ('#!/usr/bin/env python\n' '# coding: utf-8\n' 'host_url = \'localhost\'\n' 'bootstrap_token = \'token\'\n' 'foo bar') self.assertEqual(expected, f.content)
def get(self): self.response.headers['Content-Type'] = 'text/x-python' self.response.headers['Content-Disposition'] = ( 'attachment; filename="swarming_bot_bootstrap.py"') self.response.out.write( bot_code.get_bootstrap(self.request.host_url).content)
def get(self): self.response.headers["Content-Type"] = "text/x-python" self.response.headers["Content-Disposition"] = 'attachment; filename="swarming_bot_bootstrap.py"' self.response.out.write(bot_code.get_bootstrap(self.request.host_url).content)