# HG changeset patch # User Martin Bornhold # Date 2016-10-14 07:37:44 # Node ID e9c224885d413b2cc98ed8413ca5a08227ee8547 # Parent 4d64868fa22de27c965b553847d6efe2b4236696 subprocess: Change all imports from `subprocess` -> `subprocess32` diff --git a/rhodecode/lib/vcs/__init__.py b/rhodecode/lib/vcs/__init__.py --- a/rhodecode/lib/vcs/__init__.py +++ b/rhodecode/lib/vcs/__init__.py @@ -35,7 +35,7 @@ VERSION = (0, 5, 0, 'dev') 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_p '--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_po 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() diff --git a/rhodecode/rcserver.py b/rhodecode/rcserver.py --- a/rhodecode/rcserver.py +++ b/rhodecode/rcserver.py @@ -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: diff --git a/rhodecode/tests/database/conftest.py b/rhodecode/tests/database/conftest.py --- a/rhodecode/tests/database/conftest.py +++ b/rhodecode/tests/database/conftest.py @@ -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 diff --git a/rhodecode/tests/lib/middleware/utils/test_scm_app_http_chunking.py b/rhodecode/tests/lib/middleware/utils/test_scm_app_http_chunking.py --- a/rhodecode/tests/lib/middleware/utils/test_scm_app_http_chunking.py +++ b/rhodecode/tests/lib/middleware/utils/test_scm_app_http_chunking.py @@ -24,7 +24,7 @@ Checking the chunked data transfer via H import os import time -import subprocess +import subprocess32 import pytest import requests @@ -53,7 +53,7 @@ def echo_app_chunking(request, available '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_fact 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) diff --git a/rhodecode/tests/load/http_performance.py b/rhodecode/tests/load/http_performance.py --- a/rhodecode/tests/load/http_performance.py +++ b/rhodecode/tests/load/http_performance.py @@ -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 diff --git a/rhodecode/tests/load/profile.py b/rhodecode/tests/load/profile.py --- a/rhodecode/tests/load/profile.py +++ b/rhodecode/tests/load/profile.py @@ -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" diff --git a/rhodecode/tests/load/vcs_performance.py b/rhodecode/tests/load/vcs_performance.py --- a/rhodecode/tests/load/vcs_performance.py +++ b/rhodecode/tests/load/vcs_performance.py @@ -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): diff --git a/rhodecode/tests/other/vcs_operations/__init__.py b/rhodecode/tests/other/vcs_operations/__init__.py --- a/rhodecode/tests/other/vcs_operations/__init__.py +++ b/rhodecode/tests/other/vcs_operations/__init__.py @@ -28,7 +28,7 @@ Base for test suite for making push/pull """ from os.path import join as jn -from subprocess import Popen, PIPE +from subprocess32 import Popen, PIPE import logging import os import tempfile diff --git a/rhodecode/tests/other/vcs_operations/conftest.py b/rhodecode/tests/other/vcs_operations/conftest.py --- a/rhodecode/tests/other/vcs_operations/conftest.py +++ b/rhodecode/tests/other/vcs_operations/conftest.py @@ -29,7 +29,7 @@ py.test config for test suite for making 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) diff --git a/rhodecode/tests/plugin.py b/rhodecode/tests/plugin.py --- a/rhodecode/tests/plugin.py +++ b/rhodecode/tests/plugin.py @@ -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 im 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) diff --git a/rhodecode/tests/pylons_plugin.py b/rhodecode/tests/pylons_plugin.py --- a/rhodecode/tests/pylons_plugin.py +++ b/rhodecode/tests/pylons_plugin.py @@ -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'] diff --git a/rhodecode/tests/scripts/test_concurency.py b/rhodecode/tests/scripts/test_concurency.py --- a/rhodecode/tests/scripts/test_concurency.py +++ b/rhodecode/tests/scripts/test_concurency.py @@ -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__))))) diff --git a/rhodecode/tests/utils.py b/rhodecode/tests/utils.py --- a/rhodecode/tests/utils.py +++ b/rhodecode/tests/utils.py @@ -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, 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) diff --git a/rhodecode/tests/vcs/test_utils.py b/rhodecode/tests/vcs/test_utils.py --- a/rhodecode/tests/vcs/test_utils.py +++ b/rhodecode/tests/vcs/test_utils.py @@ -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) diff --git a/rhodecode/tests/vcs/utils.py b/rhodecode/tests/vcs/utils.py --- a/rhodecode/tests/vcs/utils.py +++ b/rhodecode/tests/vcs/utils.py @@ -27,7 +27,7 @@ import os import re import sys -from subprocess import Popen +from subprocess32 import Popen class VCSTestError(Exception):