From 96ba3efc920469fc342ebd5a3cdb9b8459fda2f5 Mon Sep 17 00:00:00 2001 From: Akshat <33050725+aaaakshat@users.noreply.github.com> Date: Tue, 31 Dec 2019 13:29:13 +0800 Subject: [PATCH] added show stdout cmd --- evalai/show_stdout.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 evalai/show_stdout.py diff --git a/evalai/show_stdout.py b/evalai/show_stdout.py new file mode 100644 index 000000000..972dd6c06 --- /dev/null +++ b/evalai/show_stdout.py @@ -0,0 +1,31 @@ +#!/usr/bin/env python3 + +import click +import os + + +from click import echo, style +from evalai.utils.config import AUTH_TOKEN_DIR + + +@click.group(invoke_without_command=True) +def show_stdout(): + """ + Shows output data from stdout.txt file. + """ + file_path = os.path.join(AUTH_TOKEN_DIR, "stdout.txt") + if not os.path.exists(file_path): + echo( + style( + "The stdout.txt file does not exist.", + bold=True, + fg="red", + ) + ) + else: + with open(file_path, "r") as fr: + try: + stdout = fr.read() + echo(stdout) + except (OSError, IOError) as e: + echo(str(e))