From 52ba5c9b79f68f1e1d36ccda9222f34a6b9bf619 Mon Sep 17 00:00:00 2001 From: Gavin D'souza Date: Tue, 23 Jun 2020 12:46:26 +0530 Subject: [PATCH] fix: Handle progress updates if command not executed via terminal --- frappe/utils/__init__.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/frappe/utils/__init__.py b/frappe/utils/__init__.py index 2539a6a160..f996b5109e 100644 --- a/frappe/utils/__init__.py +++ b/frappe/utils/__init__.py @@ -400,7 +400,11 @@ def call_hook_method(hook, *args, **kwargs): def update_progress_bar(txt, i, l): if not getattr(frappe.local, 'request', None): lt = len(txt) - col = 40 if os.get_terminal_size().columns > 80 else 20 + try: + col = 40 if os.get_terminal_size().columns > 80 else 20 + except OSError: + # in case function isn't being called from a terminal + col = 40 if lt < 36: txt = txt + " "*(36-lt)