mirror of
https://github.com/django/django.git
synced 2024-12-22 17:16:24 +00:00
Refs #32355 -- Modernized subprocess.run() calls.
This commit is contained in:
parent
ca58378390
commit
840ad06300
@ -1,7 +1,7 @@
|
||||
import fnmatch
|
||||
import os
|
||||
from pathlib import Path
|
||||
from subprocess import PIPE, run
|
||||
from subprocess import run
|
||||
|
||||
from django.apps import apps as installed_apps
|
||||
from django.utils.crypto import get_random_string
|
||||
@ -17,7 +17,7 @@ def popen_wrapper(args, stdout_encoding='utf-8'):
|
||||
Return stdout output, stderr output, and OS status code.
|
||||
"""
|
||||
try:
|
||||
p = run(args, stdout=PIPE, stderr=PIPE, close_fds=os.name != 'nt')
|
||||
p = run(args, capture_output=True, close_fds=os.name != 'nt')
|
||||
except OSError as err:
|
||||
raise CommandError('Error executing %s' % args[0]) from err
|
||||
return (
|
||||
|
@ -85,8 +85,7 @@ def get_git_changeset():
|
||||
repo_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
git_log = subprocess.run(
|
||||
'git log --pretty=format:%ct --quiet -1 HEAD',
|
||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE,
|
||||
shell=True, cwd=repo_dir, universal_newlines=True,
|
||||
capture_output=True, shell=True, cwd=repo_dir, text=True,
|
||||
)
|
||||
timestamp = git_log.stdout
|
||||
tz = datetime.timezone.utc
|
||||
|
@ -20,7 +20,7 @@
|
||||
|
||||
import os
|
||||
from argparse import ArgumentParser
|
||||
from subprocess import PIPE, run
|
||||
from subprocess import run
|
||||
|
||||
import django
|
||||
from django.conf import settings
|
||||
@ -74,7 +74,7 @@ def _check_diff(cat_name, base_path):
|
||||
po_path = '%(path)s/en/LC_MESSAGES/django%(ext)s.po' % {
|
||||
'path': base_path, 'ext': 'js' if cat_name.endswith('-js') else ''}
|
||||
p = run("git diff -U0 %s | egrep '^[-+]msgid' | wc -l" % po_path,
|
||||
stdout=PIPE, stderr=PIPE, shell=True)
|
||||
capture_output=True, shell=True)
|
||||
num_changes = int(p.stdout.strip())
|
||||
print("%d changed/added messages in '%s' catalog." % (num_changes, cat_name))
|
||||
|
||||
@ -123,7 +123,7 @@ def lang_stats(resources=None, languages=None):
|
||||
)
|
||||
p = run(
|
||||
['msgfmt', '-vc', '-o', '/dev/null', po_path],
|
||||
stdout=PIPE, stderr=PIPE,
|
||||
capture_output=True,
|
||||
env={'LANG': 'C'},
|
||||
encoding='utf-8',
|
||||
)
|
||||
|
@ -120,9 +120,10 @@ class AdminScriptTestCase(SimpleTestCase):
|
||||
|
||||
p = subprocess.run(
|
||||
[sys.executable, *args],
|
||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE,
|
||||
capture_output=True,
|
||||
cwd=self.test_dir,
|
||||
env=test_environ, universal_newlines=True,
|
||||
env=test_environ,
|
||||
text=True,
|
||||
)
|
||||
return p.stdout, p.stderr
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user