-
-
Notifications
You must be signed in to change notification settings - Fork 394
fix: Do not create command prompt window on subprocess #436
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
a5190e1
fix: Do not create command prompt window on subcmd
seakrueger b0d276d
fix: Replace Popen in mediainfo_json decoder
seakrueger ede79de
fixup: Pipe stdin to stdin
seakrueger b5b2ccf
chore: Exclude vendored dir from tooling checks
seakrueger 938f258
suppress mypy warnings
CyanVoxel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
[tool.ruff] | ||
exclude = ["main_window.py", "home_ui.py", "resources.py", "resources_rc.py"] | ||
exclude = ["main_window.py", "home_ui.py", "resources.py", "resources_rc.py", "**/vendored/"] | ||
|
||
[tool.mypy] | ||
strict_optional = false | ||
disable_error_code = ["union-attr", "annotation-unchecked", "import-untyped"] | ||
explicit_package_bases = true | ||
warn_unused_ignores = true | ||
exclude = ['tests'] | ||
exclude = ['tests', 'src/qt/helpers/vendored'] | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import subprocess | ||
import sys | ||
|
||
|
||
def promptless_Popen( | ||
args, | ||
bufsize=-1, | ||
executable=None, | ||
stdin=None, | ||
stdout=None, | ||
stderr=None, | ||
preexec_fn=None, | ||
close_fds=True, | ||
shell=False, | ||
cwd=None, | ||
env=None, | ||
universal_newlines=None, | ||
startupinfo=None, | ||
restore_signals=True, | ||
start_new_session=False, | ||
pass_fds=(), | ||
*, | ||
group=None, | ||
extra_groups=None, | ||
user=None, | ||
umask=-1, | ||
encoding=None, | ||
errors=None, | ||
text=None, | ||
pipesize=-1, | ||
process_group=None, | ||
): | ||
creation_flags = 0 | ||
if sys.platform == "win32": | ||
creation_flags = subprocess.CREATE_NO_WINDOW | ||
|
||
return subprocess.Popen( | ||
args=args, | ||
bufsize=bufsize, | ||
executable=executable, | ||
stdin=stdin, | ||
stdout=stdout, | ||
stderr=stderr, | ||
preexec_fn=preexec_fn, | ||
close_fds=close_fds, | ||
shell=shell, | ||
cwd=cwd, | ||
env=env, | ||
universal_newlines=universal_newlines, | ||
startupinfo=startupinfo, | ||
creationflags=creation_flags, | ||
restore_signals=restore_signals, | ||
start_new_session=start_new_session, | ||
pass_fds=pass_fds, | ||
group=group, | ||
extra_groups=extra_groups, | ||
user=user, | ||
umask=umask, | ||
encoding=encoding, | ||
errors=errors, | ||
text=text, | ||
pipesize=pipesize, | ||
process_group=process_group, | ||
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Copyright (C) 2022 Karl Kroening (kkroening). | ||
# Licensed under the GPL-3.0 License. | ||
# Vendored from ffmpeg-python and ffmpeg-python PR#790 by amamic1803 | ||
|
||
import subprocess | ||
import json | ||
import sys | ||
|
||
import ffmpeg | ||
|
||
from src.qt.helpers.silent_popen import promptless_Popen | ||
|
||
def _probe(filename, cmd='ffprobe', timeout=None, **kwargs): | ||
"""Run ffprobe on the specified file and return a JSON representation of the output. | ||
|
||
Raises: | ||
:class:`ffmpeg.Error`: if ffprobe returns a non-zero exit code, | ||
an :class:`Error` is returned with a generic error message. | ||
The stderr output can be retrieved by accessing the | ||
``stderr`` property of the exception. | ||
""" | ||
args = [cmd, '-show_format', '-show_streams', '-of', 'json'] | ||
args += ffmpeg._utils.convert_kwargs_to_cmd_line_args(kwargs) | ||
args += [filename] | ||
|
||
# PATCHED | ||
p = promptless_Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE) | ||
communicate_kwargs = {} | ||
if timeout is not None: | ||
communicate_kwargs['timeout'] = timeout | ||
out, err = p.communicate(**communicate_kwargs) | ||
if p.returncode != 0: | ||
raise ffmpeg.Error('ffprobe', out, err) | ||
return json.loads(out.decode('utf-8')) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason why the ruff exclusion pattern for vendored is different than mypy's?