changeset 2998:a1b98772af6b

Backed out changeset cf0dda0d4cda check_output can't be used as it's waiting for command to return, blocking the edition.
author Goffi <goffi@goffi.org>
date Fri, 12 Jul 2019 09:04:45 +0200
parents cf0dda0d4cda
children 85d8e9a7284b
files sat_frontends/jp/cmd_blog.py
diffstat 1 files changed, 17 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/sat_frontends/jp/cmd_blog.py	Fri Jul 12 08:55:41 2019 +0200
+++ b/sat_frontends/jp/cmd_blog.py	Fri Jul 12 09:04:45 2019 +0200
@@ -514,27 +514,23 @@
         # do we need a preview ?
         if self.args.preview:
             self.disp(u"Preview requested, launching it", 1)
-            # we redirect stderr to stdout and capture output to avoid console pollution
-            # in editor.
-            # If user wants to see messages, (s)he can call "blog preview" directly
-            try:
-                subprocess.check_output(
-                    [
-                        sys.argv[0],
-                        "blog",
-                        "preview",
-                        "--inotify",
-                        "true",
-                        "-p",
-                        self.profile,
-                        content_file_path,
-                    ],
-                    stderr=subprocess.STDOUT,
-                )
-            except Exception as e:
-                self.disp(u"Can't show preview: {msg}".format(
-                    msg=e.output.decode('utf-8'), err=True))
-                sys.exit(e.returncode)
+            # we redirect outputs to /dev/null to avoid console pollution in editor
+            # if user wants to see messages, (s)he can call "blog preview" directly
+            DEVNULL = open(os.devnull, "wb")
+            subprocess.Popen(
+                [
+                    sys.argv[0],
+                    "blog",
+                    "preview",
+                    "--inotify",
+                    "true",
+                    "-p",
+                    self.profile,
+                    content_file_path,
+                ],
+                stdout=DEVNULL,
+                stderr=subprocess.STDOUT,
+            )
 
         # we launch editor
         self.runEditor(