From: Oleg Broytman Date: Wed, 31 Jul 2024 18:12:59 +0000 (+0300) Subject: Fear(robots): Try robots from a list X-Git-Tag: 5.4.0~13 X-Git-Url: https://git.phdru.name/?a=commitdiff_plain;h=edd0499990608b5f1c828edc6444c1e4834a420b;p=bookmarks_db.git Fear(robots): Try robots from a list Default list is curl,requests,forking. --- 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)