def get_swarming_bot_zip(host): """Returns a zipped file of all the files a bot needs to run. Returns: A string representing the zipped file's contents. """ version, additionals, bot_config_rev = get_bot_version(host) cached_content, cached_bot_config_rev = get_cached_swarming_bot_zip( version) # TODO(crbug.com/1087981): Compare the bot config revisions. # Separate deployment to be safe. if cached_content and cached_bot_config_rev: logging.debug( 'memcached bot code %s; %d bytes with bot_config.py rev: %s', version, len(cached_content), cached_bot_config_rev) return cached_content # Get the start bot script from the database, if present. Pass an empty # file if the files isn't present. bot_config, bot_config_rev = get_bot_config() additionals = additionals or { 'config/bot_config.py': bot_config.content, } bot_dir = os.path.join(ROOT_DIR, 'swarming_bot') content, version = bot_archive.get_swarming_bot_zip( bot_dir, host, utils.get_app_version(), additionals, local_config.settings()) logging.info('generated bot code %s; %d bytes with bot_config.py rev: %s', version, len(content), bot_config_rev) cache_swarming_bot_zip(version, content, bot_config_rev) return content
def get_swarming_bot_zip(): host = read_config()['server'] bot_config_path = os.path.join( ROOT_DIR, 'swarming_bot', 'config', 'bot_config.py') with open(bot_config_path, 'rb') as f: additionals = {'config/bot_config.py': f.read()} from server import bot_archive return bot_archive.get_swarming_bot_zip( os.path.join(ROOT_DIR, 'swarming_bot'), host, '1', additionals)
def setUp(self): with open(os.path.join(BOT_DIR, 'bot_config.py'), 'rb') as f: bot_config_content = f.read() zip_content = bot_archive.get_swarming_bot_zip( BOT_DIR, 'http://localhost', {'bot_config.py': bot_config_content}) self.tmpdir = tempfile.mkdtemp(prefix='main') self.zip_file = os.path.join(self.tmpdir, 'swarming_bot.zip') with open(self.zip_file, 'wb') as f: f.write(zip_content)
def get_swarming_bot_zip(): host = read_config()['server'] bot_config_path = os.path.join(ROOT_DIR, 'swarming_bot', 'config', 'bot_config.py') with open(bot_config_path, 'rb') as f: additionals = {'config/bot_config.py': f.read()} from server import bot_archive return bot_archive.get_swarming_bot_zip( os.path.join(ROOT_DIR, 'swarming_bot'), host, '1', additionals)
def get_swarming_bot_zip(): config = read_config() bot_config_path = os.path.join(ROOT_DIR, 'swarming_bot', 'config', 'bot_config.py') with open(bot_config_path, 'rb') as f: additionals = {'config/bot_config.py': f.read()} from server import bot_archive return bot_archive.get_swarming_bot_zip( os.path.join(ROOT_DIR, 'swarming_bot'), config['server'], '1', additionals, config['enable_ts_monitoring'])
def get_swarming_bot_zip(host): """Returns a zipped file of all the files a bot needs to run. Returns: A string representing the zipped file's contents. """ bot_version = get_bot_version(host) content = memcache.get('code-%s' + bot_version, namespace='bot_code') if content: return content # Get the start bot script from the database, if present. Pass an empty # file if the files isn't present. additionals = {'config/bot_config.py': get_bot_config().content} bot_dir = os.path.join(ROOT_DIR, 'swarming_bot') content, bot_version = bot_archive.get_swarming_bot_zip( bot_dir, host, utils.get_app_version(), additionals) memcache.set('code-%s' + bot_version, content, namespace='bot_code') return content
def get_swarming_bot_zip(host): """Returns a zipped file of all the files a bot needs to run. Returns: A string representing the zipped file's contents. """ namespace = os.environ['CURRENT_VERSION_ID'] key = 'bot_version-%s' + get_bot_version(host) code = memcache.get(key, namespace=namespace) if code: return code # Get the start bot script from the database, if present. Pass an empty # file if the files isn't present. additionals = {'bot_config.py': get_bot_config().content} bot_dir = os.path.join(ROOT_DIR, 'swarming_bot') code = bot_archive.get_swarming_bot_zip(bot_dir, host, additionals) memcache.set(key, code, namespace=namespace) return code
def get_swarming_bot_zip(host): """Returns a zipped file of all the files a bot needs to run. Returns: A string representing the zipped file's contents. """ version, additionals = get_bot_version(host) content = get_cached_swarming_bot_zip(version) if content: logging.debug('memcached bot code %s; %d bytes', version, len(content)) return content # Get the start bot script from the database, if present. Pass an empty # file if the files isn't present. additionals = additionals or { 'config/bot_config.py': get_bot_config().content, } bot_dir = os.path.join(ROOT_DIR, 'swarming_bot') content, version = bot_archive.get_swarming_bot_zip( bot_dir, host, utils.get_app_version(), additionals, local_config.settings()) logging.info('generated bot code %s; %d bytes', version, len(content)) cache_swarming_bot_zip(version, content) return content