From edd0499990608b5f1c828edc6444c1e4834a420b Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Wed, 31 Jul 2024 21:12:59 +0300 Subject: [PATCH] Fear(robots): Try robots from a list Default list is curl,requests,forking. --- robots.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/robots.py b/robots.py index 70513f2..575f9bd 100644 --- a/robots.py +++ b/robots.py @@ -15,7 +15,8 @@ import sys from os import environ from bkmk_objects import parse_params, set_params -robot_name, robot_params = parse_params(environ.get("BKMK_ROBOT", "requests")) +robot_names, robot_params = parse_params( + environ.get("BKMK_ROBOT", "curl,requests,forking")) def import_robot(robot_name): @@ -27,5 +28,13 @@ def import_robot(robot_name): return ns['robot'] -robot = import_robot(robot_name) -set_params(robot, robot_params) +for robot_name in robot_names.split(','): + try: + robot = import_robot(robot_name) + except ImportError: + pass + else: + set_params(robot, robot_params) + break +else: + raise ValueError("No robot found, tried " + robot_names) -- 2.39.5