Skip to content
Snippets Groups Projects

Add some more debugging info and safeguards

Merged Florian Bruhin requested to merge safeguards into master
1 file
+ 13
2
Compare changes
  • Side-by-side
  • Inline
+ 13
2
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![/] [bright_black]({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![/] [bright_black]({timestamp}, {commit})[/]")
def run():
Loading