diff options
author | Igor Radovanovic <74266147+IgorWounds@users.noreply.github.com> | 2024-05-12 16:11:48 +0200 |
---|---|---|
committer | Igor Radovanovic <74266147+IgorWounds@users.noreply.github.com> | 2024-05-12 16:11:48 +0200 |
commit | e163927416dceda2d626c4bb265d942094d63ce3 (patch) | |
tree | 738fde3939521dceb003e4de1e0385dc76cf4c0b | |
parent | 78b9d954d89ae0b3b5b8c1319233e600c0e1faa5 (diff) |
Fix CLI exit when FileNotFound error on routinebugfix/remove-old-code
-rw-r--r-- | cli/openbb_cli/controllers/cli_controller.py | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/cli/openbb_cli/controllers/cli_controller.py b/cli/openbb_cli/controllers/cli_controller.py index 7969f74826b..5f16f070229 100644 --- a/cli/openbb_cli/controllers/cli_controller.py +++ b/cli/openbb_cli/controllers/cli_controller.py @@ -423,8 +423,9 @@ class CLIController(BaseController): else: return - with open(routine_path) as fp: - raw_lines = list(fp) + try: + with open(routine_path) as fp: + raw_lines = list(fp) # Capture ARGV either as list if args separated by commas or as single value if ns_parser.routine_args: @@ -478,6 +479,12 @@ class CLIController(BaseController): ) self.queue = self.queue[1:] + except FileNotFoundError: + session.console.print( + f"[red]File '{routine_path}' doesn't exist.[/red]\n" + ) + return + def handle_job_cmds(jobs_cmds: Optional[List[str]]) -> Optional[List[str]]: """Handle job commands.""" |