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 fnmatch
|
||||||
import os
|
import os
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from subprocess import PIPE, run
|
from subprocess import run
|
||||||
|
|
||||||
from django.apps import apps as installed_apps
|
from django.apps import apps as installed_apps
|
||||||
from django.utils.crypto import get_random_string
|
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.
|
Return stdout output, stderr output, and OS status code.
|
||||||
"""
|
"""
|
||||||
try:
|
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:
|
except OSError as err:
|
||||||
raise CommandError('Error executing %s' % args[0]) from err
|
raise CommandError('Error executing %s' % args[0]) from err
|
||||||
return (
|
return (
|
||||||
|
@ -85,8 +85,7 @@ def get_git_changeset():
|
|||||||
repo_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
repo_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||||
git_log = subprocess.run(
|
git_log = subprocess.run(
|
||||||
'git log --pretty=format:%ct --quiet -1 HEAD',
|
'git log --pretty=format:%ct --quiet -1 HEAD',
|
||||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE,
|
capture_output=True, shell=True, cwd=repo_dir, text=True,
|
||||||
shell=True, cwd=repo_dir, universal_newlines=True,
|
|
||||||
)
|
)
|
||||||
timestamp = git_log.stdout
|
timestamp = git_log.stdout
|
||||||
tz = datetime.timezone.utc
|
tz = datetime.timezone.utc
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
from argparse import ArgumentParser
|
from argparse import ArgumentParser
|
||||||
from subprocess import PIPE, run
|
from subprocess import run
|
||||||
|
|
||||||
import django
|
import django
|
||||||
from django.conf import settings
|
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' % {
|
po_path = '%(path)s/en/LC_MESSAGES/django%(ext)s.po' % {
|
||||||
'path': base_path, 'ext': 'js' if cat_name.endswith('-js') else ''}
|
'path': base_path, 'ext': 'js' if cat_name.endswith('-js') else ''}
|
||||||
p = run("git diff -U0 %s | egrep '^[-+]msgid' | wc -l" % po_path,
|
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())
|
num_changes = int(p.stdout.strip())
|
||||||
print("%d changed/added messages in '%s' catalog." % (num_changes, cat_name))
|
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(
|
p = run(
|
||||||
['msgfmt', '-vc', '-o', '/dev/null', po_path],
|
['msgfmt', '-vc', '-o', '/dev/null', po_path],
|
||||||
stdout=PIPE, stderr=PIPE,
|
capture_output=True,
|
||||||
env={'LANG': 'C'},
|
env={'LANG': 'C'},
|
||||||
encoding='utf-8',
|
encoding='utf-8',
|
||||||
)
|
)
|
||||||
|
@ -120,9 +120,10 @@ class AdminScriptTestCase(SimpleTestCase):
|
|||||||
|
|
||||||
p = subprocess.run(
|
p = subprocess.run(
|
||||||
[sys.executable, *args],
|
[sys.executable, *args],
|
||||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE,
|
capture_output=True,
|
||||||
cwd=self.test_dir,
|
cwd=self.test_dir,
|
||||||
env=test_environ, universal_newlines=True,
|
env=test_environ,
|
||||||
|
text=True,
|
||||||
)
|
)
|
||||||
return p.stdout, p.stderr
|
return p.stdout, p.stderr
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user