From c3b486b598ab3b4f69ef9c7b2605a0ac85cb7d2a Mon Sep 17 00:00:00 2001 From: Melody Horn Date: Thu, 24 Dec 2020 01:36:46 -0700 Subject: stop creating console windows all the time --- output.py | 4 ++-- sources.py | 17 +++++++++++------ vidslice.py | 3 ++- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/output.py b/output.py index 82a106e..2c765ca 100644 --- a/output.py +++ b/output.py @@ -106,7 +106,7 @@ class OutputPanel(wx.Panel): def run(): # noinspection PyArgumentList proc = subprocess.Popen(args, stdin=subprocess.DEVNULL, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, - text=True) + text=True, creationflags=subprocess.CREATE_NO_WINDOW) while proc.poll() is None: out_data = proc.stdout.readline() if out_data != '': @@ -120,7 +120,7 @@ class OutputPanel(wx.Panel): def preview(code): if code == 0: out_file = self.file_text.GetValue() - subprocess.Popen(['ffplay', '-autoexit', out_file]) + subprocess.Popen(['ffplay', '-autoexit', out_file], creationflags=subprocess.CREATE_NO_WINDOW) self.handle_run_pressed(_event, callback=preview) diff --git a/sources.py b/sources.py index a8a1611..d4fab2f 100644 --- a/sources.py +++ b/sources.py @@ -10,7 +10,8 @@ import wx def has_ytdl(): try: - subprocess.run(["youtube-dl", "--version"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) + subprocess.run(["youtube-dl", "--version"], + stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, creationflags=subprocess.CREATE_NO_WINDOW) return True except FileNotFoundError: return False @@ -18,9 +19,11 @@ def has_ytdl(): def update_ytdl(parent_win): try: - youtube_dl_found = subprocess.run(['where', 'youtube-dl'], stdout=subprocess.PIPE, text=True) + youtube_dl_found = subprocess.run(['where', 'youtube-dl'], stdout=subprocess.PIPE, text=True, + creationflags=subprocess.CREATE_NO_WINDOW) except FileNotFoundError: - youtube_dl_found = subprocess.run(['which', 'youtube-dl'], stdout=subprocess.PIPE, text=True) + youtube_dl_found = subprocess.run(['which', 'youtube-dl'], stdout=subprocess.PIPE, text=True, + creationflags=subprocess.CREATE_NO_WINDOW) if youtube_dl_found.returncode != 0: def poll(): answer = wx.MessageBox("Could not find youtube-dl. Open vidslice README?", "Error", wx.YES_NO, parent_win) @@ -32,7 +35,8 @@ def update_ytdl(parent_win): wx.CallAfter(poll) youtube_dl_path = youtube_dl_found.stdout.split("\n")[0] old_mtime = os.stat(youtube_dl_path).st_mtime - proc = subprocess.run(["youtube-dl", "-U"], stdout=subprocess.PIPE, text=True) + proc = subprocess.run(["youtube-dl", "-U"], stdout=subprocess.PIPE, text=True, + creationflags=subprocess.CREATE_NO_WINDOW) if not proc.stdout.startswith("youtube-dl is up-to-date"): while os.stat(youtube_dl_path).st_mtime == old_mtime: from time import sleep @@ -91,7 +95,8 @@ class SourcesPanel(wx.Panel): # noinspection PyArgumentList proc = subprocess.Popen([ 'youtube-dl', '-o', file.name + '.%(ext)s', self.url_text.GetValue() - ], stdin=subprocess.DEVNULL, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) + ], stdin=subprocess.DEVNULL, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True, + creationflags=subprocess.CREATE_NO_WINDOW) while proc.poll() is None: out_data = proc.stdout.readline() if out_data != '': @@ -116,7 +121,7 @@ class SourcesPanel(wx.Panel): 'ffprobe', '-v', 'error', '-of', 'json', '-show_entries', 'format=start_time,duration:stream=index,codec_type,avg_frame_rate,width,height', self.file_text.GetValue() - ], capture_output=True, text=True) + ], capture_output=True, text=True, creationflags=subprocess.CREATE_NO_WINDOW) if result.returncode == 0: ffprobe_data = json.loads(result.stdout) self.set_status("Successfully loaded media info") diff --git a/vidslice.py b/vidslice.py index 6aa343a..1f52dbc 100644 --- a/vidslice.py +++ b/vidslice.py @@ -27,7 +27,8 @@ def check_update(parent): def has_ffmpeg(): try: - subprocess.run(["ffmpeg", "-version"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) + subprocess.run(["ffmpeg", "-version"], + stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, creationflags=subprocess.CREATE_NO_WINDOW) return True except FileNotFoundError: return False -- cgit v1.2.3