From 3d6ad59643a01debaff91c7dd9d8b67f29f41e48 Mon Sep 17 00:00:00 2001 From: DidierRLopes Date: Sun, 13 Aug 2023 19:43:10 -0500 Subject: [PATCH] few more updates (#5317) * check that routine title is valid * more updates * small fixes * override local routine * more improvements to routine logic * --debug runs .dev * few more updates --- openbb_terminal/core/session/hub_model.py | 12 ++++++++---- openbb_terminal/parent_classes.py | 5 +++-- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/openbb_terminal/core/session/hub_model.py b/openbb_terminal/core/session/hub_model.py index 5dea92f109b..4fc99c5c582 100644 --- a/openbb_terminal/core/session/hub_model.py +++ b/openbb_terminal/core/session/hub_model.py @@ -2,7 +2,7 @@ import datetime import json from typing import Any, Dict, List, Literal, Optional from uuid import UUID - +from os import environ import requests from jose import jwt @@ -479,10 +479,14 @@ def upload_routine( if response.status_code == 200: username = get_current_user().profile.username console.print("[green]Successfully uploaded your routine.[/green]") - if public: - console.print(f"\n[yellow]Share or edit it at https://my.openbb.co/u/{username}/routine/{name.replace(' ', '-')}[/yellow]") + if str(environ.get("DEBUG_MODE", "false")).lower() != "true": + run_env = "dev" else: - console.print(f"\n[yellow]Edit it at https://my.openbb.co/u/{username}/routine/{name.replace(' ', '-')}[/yellow]") + run_env = "co" + if public: + console.print(f"\n[yellow]Share or edit it at https://my.openbb.{run_env}/u/{username}/routine/{name.replace(' ', '-')}[/yellow]") + else: + console.print(f"\n[yellow]Edit it at https://my.openbb.{run_env}/u/{username}/routine/{name.replace(' ', '-')}[/yellow]") elif response.status_code != 409: # 409: routine already exists console.print( "[red]" + response.json().get("detail", "Unknown error.") + "[/red]" diff --git a/openbb_terminal/parent_classes.py b/openbb_terminal/parent_classes.py index b7427ec9f32..e5849a019f6 100644 --- a/openbb_terminal/parent_classes.py +++ b/openbb_terminal/parent_classes.py @@ -1068,7 +1068,7 @@ class BaseController(metaclass=ABCMeta): f"# Description: {SESSION_RECORDED_DESCRIPTION}", "\n\n", ] - lines += [c + "\n\n" for c in SESSION_RECORDED[:-1]] + lines += [c + "\n" for c in SESSION_RECORDED[:-1]] # Writing data to a file file1.writelines(lines) @@ -1081,7 +1081,8 @@ class BaseController(metaclass=ABCMeta): # Confirm that the user is logged in if not is_local(): # routine = read_routine(file_name=routine_file) - routine = "\n\n".join(SESSION_RECORDED[:-1]) + routine = "\n".join(SESSION_RECORDED[:-1]) + if routine is not None: kwargs = { "auth_header": current_user.profile.get_auth_header(),