From 6eff57f7eea3fda005c89c8662d7d1dd4e44c1e7 Mon Sep 17 00:00:00 2001 From: matograine <tom.ngr@zaclys.net> Date: Fri, 23 Apr 2021 14:23:08 +0200 Subject: [PATCH] [enh] #390 create show_response() --- silkaj/tui.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/silkaj/tui.py b/silkaj/tui.py index 2b09d00f..9651d9c0 100644 --- a/silkaj/tui.py +++ b/silkaj/tui.py @@ -17,6 +17,7 @@ along with Silkaj. If not, see <https://www.gnu.org/licenses/>. import sys import click +import logging from datetime import datetime from silkaj import wot, network_tools, constants @@ -69,6 +70,18 @@ async def send_doc_confirmation(document_name): sys.exit(constants.SUCCESS_EXIT_STATUS) +async def print_response(response, doc_type): + if response.status == 200: + click.echo(f"{doc_type} successfully sent") + else: + click.echo( + f"Error while publishing {lower(doc_type)}: {0}".format( + await response.text() + ) + ) + logging.debug(await response.text()) + + def convert_time(timestamp, kind): ts = int(timestamp) date = "%Y-%m-%d" -- GitLab