From 546161ab1a30e37d5adf182aa23c8e6e0476e199 Mon Sep 17 00:00:00 2001 From: Khushboo Vashi Date: Tue, 19 Mar 2019 15:55:34 +0000 Subject: [PATCH] Fix an issue with stdout redirection on Windows, and remove code added in a failed attempt to resolve a Windows regression test issue. --- web/pgAdmin4.py | 6 ++++++ web/pgadmin/__init__.py | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/web/pgAdmin4.py b/web/pgAdmin4.py index dd5d67fb1..fe22f51d8 100644 --- a/web/pgAdmin4.py +++ b/web/pgAdmin4.py @@ -31,6 +31,12 @@ if 'SERVER_MODE' in globals(): else: builtins.SERVER_MODE = None +# Set null device file path to stdout, stdin, stderr if they are None +for _name in ('stdin', 'stdout', 'stderr'): + if getattr(sys, _name) is None: + setattr(sys, _name, open(os.devnull, + 'r' if _name == 'stdin' else 'w')) + import config from pgadmin import create_app from pgadmin.utils import u, fs_encoding, file_quote diff --git a/web/pgadmin/__init__.py b/web/pgadmin/__init__.py index 08da8a0e8..eea268aa8 100644 --- a/web/pgadmin/__init__.py +++ b/web/pgadmin/__init__.py @@ -248,7 +248,7 @@ def create_app(app_name=None): logger.addHandler(fh) # Console logging - ch = logging.StreamHandler(sys.stdout.reconfigure(encoding='utf-8')) + ch = logging.StreamHandler() ch.setLevel(config.CONSOLE_LOG_LEVEL) ch.setFormatter(logging.Formatter(config.CONSOLE_LOG_FORMAT)) app.logger.addHandler(ch)