Skip to content
Snippets Groups Projects
Commit 14316d8f authored by Florian Bruhin's avatar Florian Bruhin
Browse files

Merge branch 'safeguards' into 'master'

Add some more debugging info and safeguards

See merge request !2
parents 47cb77c1 267f3165
No related branches found
No related tags found
1 merge request!2Add some more debugging info and safeguards
from logging import error
import datetime
import time
import sys
from click.termui import style
......@@ -24,6 +25,13 @@ def upload_file(
),
url: str = typer.Argument("http://localhost:5000/testbook", envvar="TAAS_URL"),
):
if not notebook.is_relative_to(Path.home() / 'work' / 'AutPy'):
console.print(
f"[red]Refusing to submit file from unexpected location[/]: {notebook}\n"
"Make sure you're not accidentally working in the 'Originale' folder!"
)
raise typer.Exit(code=1)
modified = round(time.time() - notebook.stat().st_mtime)
sec = 'second' if modified == 1 else 'seconds'
suffix = ', [red]make sure you saved![/]' if modified >= 10 else ''
......@@ -66,12 +74,15 @@ def upload_file(
try:
print(f"[red]Error: {exc.response.json().get('error')}[/]", file=sys.stderr)
print(f"[red]Message: {exc.response.json().get('msg')}[/]", file=sys.stderr)
print(":boom: [bold]Submission failed![/]")
timestamp = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
print(f":boom: [bold]Submission failed![/] [white]({timestamp})[/]")
except:
pass
raise typer.Exit(code=1)
print(":mailbox: :heavy_check_mark: [bold]Submission successful![/]")
commit = result.get("commit", "?")
timestamp = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
print(f":mailbox: :heavy_check_mark: [bold]Submission successful![/] [white]({timestamp}, {commit})[/]")
def run():
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment