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
This commit is contained in:
DidierRLopes
2023-08-13 19:43:10 -05:00
committed by GitHub
parent 01210120d8
commit 3d6ad59643
2 changed files with 11 additions and 6 deletions

View File

@@ -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]"

View File

@@ -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(),