subprocess: Change all imports from subprocess -> subprocess32

This commit is contained in:
Martin Bornhold 2016-10-14 09:37:44 +02:00
parent f5a84e0461
commit a9a4e32eed
15 changed files with 42 additions and 44 deletions

View file

@ -35,7 +35,7 @@ __all__ = [
import atexit
import logging
import subprocess
import subprocess32
import time
import urlparse
from cStringIO import StringIO
@ -165,7 +165,7 @@ def _start_pyro4_vcs_server(server_and_port, log_level=None):
'--threadpool', '32']
if log_level:
args += ['--log-level', log_level]
proc = subprocess.Popen(args)
proc = subprocess32.Popen(args)
def cleanup_server_process():
proc.kill()
@ -182,7 +182,7 @@ def _start_http_vcs_server(server_and_port, log_level=None):
args = [
'pserve', 'rhodecode/tests/vcsserver_http.ini',
'http_port=%s' % (port, ), 'http_host=%s' % (host, )]
proc = subprocess.Popen(args)
proc = subprocess32.Popen(args)
def cleanup_server_process():
proc.kill()

View file

@ -15,7 +15,7 @@ import logging
import optparse
import os
import re
import subprocess
import subprocess32
import sys
import textwrap
import threading
@ -32,9 +32,9 @@ from rhodecode.lib.compat import kill
def make_web_build_callback(filename):
p = subprocess.Popen('make web-build', shell=True,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
p = subprocess32.Popen('make web-build', shell=True,
stdout=subprocess32.PIPE,
stderr=subprocess32.PIPE,
cwd=os.path.dirname(os.path.dirname(__file__)))
stdout, stderr = p.communicate()
stdout = ''.join(stdout)
@ -658,7 +658,7 @@ class RcServerCommand(object):
try:
try:
_turn_sigterm_into_systemexit()
proc = subprocess.Popen(args, env=new_environ)
proc = subprocess32.Popen(args, env=new_environ)
exit_code = proc.wait()
proc = None
except KeyboardInterrupt:

View file

@ -18,7 +18,7 @@
# RhodeCode Enterprise Edition, including its added features, Support services,
# and proprietary license terms, please see https://rhodecode.com/licenses/
from subprocess import Popen, PIPE
from subprocess32 import Popen, PIPE
import os
import shutil
import sys

View file

@ -24,7 +24,7 @@ Checking the chunked data transfer via HTTP
import os
import time
import subprocess
import subprocess32
import pytest
import requests
@ -53,7 +53,7 @@ def echo_app_chunking(request, available_port_factory):
'rhodecode.tests.lib.middleware.utils.test_scm_app_http_chunking'
':create_echo_app')
command = command.format(port=port)
proc = subprocess.Popen(command.split(' '), bufsize=0)
proc = subprocess32.Popen(command.split(' '), bufsize=0)
echo_app_url = 'http://localhost:' + str(port)
@request.addfinalizer
@ -78,7 +78,7 @@ def scm_app(request, available_port_factory, echo_app_chunking):
command = command.format(port=port)
env = os.environ.copy()
env["RC_ECHO_URL"] = echo_app_chunking
proc = subprocess.Popen(command.split(' '), bufsize=0, env=env)
proc = subprocess32.Popen(command.split(' '), bufsize=0, env=env)
scm_app_url = 'http://localhost:' + str(port)
wait_for_url(scm_app_url)

View file

@ -32,7 +32,7 @@ import itertools
import os
import pprint
import shutil
import subprocess
import subprocess32
import sys
import time
@ -77,12 +77,12 @@ def execute(*popenargs, **kwargs):
input = kwargs.pop('stdin', None)
stdin = None
if input:
stdin = subprocess.PIPE
stdin = subprocess32.PIPE
#if 'stderr' not in kwargs:
# kwargs['stderr'] = subprocess.PIPE
# kwargs['stderr'] = subprocess32.PIPE
if 'stdout' in kwargs:
raise ValueError('stdout argument not allowed, it will be overridden.')
process = subprocess.Popen(stdin=stdin, stdout=subprocess.PIPE,
process = subprocess32.Popen(stdin=stdin, stdout=subprocess32.PIPE,
*popenargs, **kwargs)
output, error = process.communicate(input=input)
retcode = process.poll()
@ -91,7 +91,7 @@ def execute(*popenargs, **kwargs):
if cmd is None:
cmd = popenargs[0]
print cmd, output, error
raise subprocess.CalledProcessError(retcode, cmd, output=output)
raise subprocess32.CalledProcessError(retcode, cmd, output=output)
return output

View file

@ -31,7 +31,7 @@ To stop the script by press Ctrl-C
import datetime
import os
import psutil
import subprocess
import subprocess32
import sys
import time
import traceback
@ -66,7 +66,7 @@ def dump_system():
def count_dulwich_fds(proc):
p = subprocess.Popen(["lsof", "-p", proc.pid], stdout=subprocess.PIPE)
p = subprocess32.Popen(["lsof", "-p", proc.pid], stdout=subprocess32.PIPE)
out, err = p.communicate()
count = 0
@ -117,7 +117,7 @@ print "VCS - Ok"
print "\nStarting RhodeCode..."
rc = psutil.Popen("RC_VCSSERVER_TEST_DISABLE=1 paster serve test.ini",
shell=True, stdin=subprocess.PIPE)
shell=True, stdin=subprocess32.PIPE)
time.sleep(1)
if not rc.is_running():
print "RC - Failed to start"

View file

@ -40,7 +40,7 @@ import functools
import logging
import os
import shutil
import subprocess
import subprocess32
import tempfile
import time
from itertools import chain
@ -145,8 +145,8 @@ class Repository(object):
def _run(self, *args):
command = [self.BASE_COMMAND] + list(args)
process = subprocess.Popen(
command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
process = subprocess32.Popen(
command, stdout=subprocess32.PIPE, stderr=subprocess32.PIPE)
return process.communicate()
def _create_file(self, name, size):

View file

@ -28,7 +28,7 @@ Base for test suite for making push/pull operations.
"""
from os.path import join as jn
from subprocess import Popen, PIPE
from subprocess32 import Popen, PIPE
import logging
import os
import tempfile

View file

@ -29,7 +29,7 @@ py.test config for test suite for making push/pull operations.
import ConfigParser
import os
import subprocess
import subprocess32
import tempfile
import textwrap
import pytest
@ -164,7 +164,7 @@ def rc_web_server(
print('Command: {}'.format(command))
print('Logfile: {}'.format(RC_LOG))
proc = subprocess.Popen(
proc = subprocess32.Popen(
command, bufsize=0, env=env, stdout=server_out, stderr=server_out)
wait_for_url(host_url, timeout=30)

View file

@ -26,7 +26,7 @@ import re
import pprint
import shutil
import socket
import subprocess
import subprocess32
import time
import uuid
@ -42,7 +42,7 @@ from rhodecode.model.changeset_status import ChangesetStatusModel
from rhodecode.model.comment import ChangesetCommentsModel
from rhodecode.model.db import (
PullRequest, Repository, RhodeCodeSetting, ChangesetStatus, RepoGroup,
UserGroup, RepoRhodeCodeUi, RepoRhodeCodeSetting, RhodeCodeUi, Integration)
UserGroup, RepoRhodeCodeUi, RepoRhodeCodeSetting, RhodeCodeUi)
from rhodecode.model.meta import Session
from rhodecode.model.pull_request import PullRequestModel
from rhodecode.model.repo import RepoModel
@ -884,7 +884,7 @@ class RepoServer(object):
if vcsrepo.alias != 'svn':
raise TypeError("Backend %s not supported" % vcsrepo.alias)
proc = subprocess.Popen(
proc = subprocess32.Popen(
['svnserve', '-d', '--foreground', '--listen-host', 'localhost',
'--root', vcsrepo.path])
self._cleanup_servers.append(proc)

View file

@ -23,7 +23,7 @@ import logging.config
import os
import platform
import socket
import subprocess
import subprocess32
import time
from urllib2 import urlopen, URLError
@ -196,7 +196,7 @@ class VCSServer(object):
def start(self):
print("Starting the VCSServer: {}".format(self._args))
self.process = subprocess.Popen(self._args)
self.process = subprocess32.Popen(self._args)
def wait_until_ready(self, timeout=30):
raise NotImplementedError()
@ -255,7 +255,7 @@ class HttpVCSServer(VCSServer):
return template.format(**self._config)
def start(self):
self.process = subprocess.Popen(self._args)
self.process = subprocess32.Popen(self._args)
def wait_until_ready(self, timeout=30):
host = self._config['host']

View file

@ -30,10 +30,8 @@ from os.path import join as jn
from os.path import dirname as dn
from tempfile import _RandomNameSequence
from subprocess import Popen, PIPE
from subprocess32 import Popen, PIPE
from paste.deploy import appconfig
from pylons import config
from rhodecode.lib.utils import add_cache
from rhodecode.lib.utils2 import engine_from_config
@ -42,7 +40,7 @@ from rhodecode.model import init_model
from rhodecode.model import meta
from rhodecode.model.db import User, Repository
from rhodecode.tests import TESTS_TMP_PATH, NEW_HG_REPO, HG_REPO
from rhodecode.tests import TESTS_TMP_PATH, HG_REPO
from rhodecode.config.environment import load_environment
rel_path = dn(dn(dn(dn(os.path.abspath(__file__)))))

View file

@ -22,7 +22,7 @@ import threading
import time
import logging
import os.path
import subprocess
import subprocess32
import urllib2
from urlparse import urlparse, parse_qsl
from urllib import unquote_plus
@ -113,10 +113,10 @@ def _load_svn_dump_into_repo(dump_name, repo_path):
integrated with the main repository once they stabilize more.
"""
dump = rc_testdata.load_svn_dump(dump_name)
load_dump = subprocess.Popen(
load_dump = subprocess32.Popen(
['svnadmin', 'load', repo_path],
stdin=subprocess.PIPE, stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
stdin=subprocess32.PIPE, stdout=subprocess32.PIPE,
stderr=subprocess32.PIPE)
out, err = load_dump.communicate(dump)
if load_dump.returncode != 0:
log.error("Output of load_dump command: %s", out)

View file

@ -20,7 +20,7 @@
import datetime
import os
import subprocess
import subprocess32
import pytest
@ -86,8 +86,8 @@ class TestGetScm:
def test_get_two_scms_for_path(self, tmpdir):
multialias_repo_path = str(tmpdir)
subprocess.check_call(['hg', 'init', multialias_repo_path])
subprocess.check_call(['git', 'init', multialias_repo_path])
subprocess32.check_call(['hg', 'init', multialias_repo_path])
subprocess32.check_call(['git', 'init', multialias_repo_path])
with pytest.raises(VCSError):
get_scm(multialias_repo_path)

View file

@ -27,7 +27,7 @@ import os
import re
import sys
from subprocess import Popen
from subprocess32 import Popen
class VCSTestError(Exception):