Skip to content

Commit

Permalink
fix: let callback call itself
Browse files Browse the repository at this point in the history
  • Loading branch information
johnson2427 committed Oct 3, 2024
1 parent f887a6f commit d8e7d8d
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions silverback/_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,16 +106,19 @@ def _network_callback(ctx, param, val):
def run(cli_ctx, account, runner_class, recorder_class, max_exceptions, path):
"""Run Silverback application"""

def path_callback(path):
def path_callback(path, calls=0):
if not path:
path = "bot:bot"
elif ":" not in path:
path += ":bot"

try:
return import_from_string(path)
except ImportFromStringError:
return import_from_string(f"bots.{path}")
except ImportFromStringError as e:
if calls > 0:
raise ImportFromStringError(e)
calls += 1
return path_callback(f"bots.{path}", calls)

if not runner_class:
# NOTE: Automatically select runner class
Expand Down

0 comments on commit d8e7d8d

Please sign in to comment.