##// END OF EJS Templates
python3: remove usage of subprocess32
super-admin -
r4926:cf2cc324 default
parent child Browse files
Show More
@@ -26,7 +26,7 b' import os'
26 import datetime
26 import datetime
27 import logging
27 import logging
28 import Queue
28 import Queue
29 import subprocess32
29 import subprocess
30
30
31
31
32 from dateutil.parser import parse
32 from dateutil.parser import parse
@@ -359,7 +359,7 b' class AsyncSubscriber(Subscriber):'
359
359
360 class AsyncSubprocessSubscriber(AsyncSubscriber):
360 class AsyncSubprocessSubscriber(AsyncSubscriber):
361 """
361 """
362 Subscriber that uses the subprocess32 module to execute a command if an
362 Subscriber that uses the subprocess module to execute a command if an
363 event is received. Events are handled asynchronously::
363 event is received. Events are handled asynchronously::
364
364
365 subscriber = AsyncSubprocessSubscriber('ls -la', timeout=10)
365 subscriber = AsyncSubprocessSubscriber('ls -la', timeout=10)
@@ -380,16 +380,16 b' class AsyncSubprocessSubscriber(AsyncSub'
380 log.debug('Executing command %s.', cmd)
380 log.debug('Executing command %s.', cmd)
381
381
382 try:
382 try:
383 output = subprocess32.check_output(
383 output = subprocess.check_output(
384 cmd, timeout=timeout, stderr=subprocess32.STDOUT)
384 cmd, timeout=timeout, stderr=subprocess.STDOUT)
385 log.debug('Command finished %s', cmd)
385 log.debug('Command finished %s', cmd)
386 if output:
386 if output:
387 log.debug('Command output: %s', output)
387 log.debug('Command output: %s', output)
388 except subprocess32.TimeoutExpired as e:
388 except subprocess.TimeoutExpired as e:
389 log.exception('Timeout while executing command.')
389 log.exception('Timeout while executing command.')
390 if e.output:
390 if e.output:
391 log.error('Command output: %s', e.output)
391 log.error('Command output: %s', e.output)
392 except subprocess32.CalledProcessError as e:
392 except subprocess.CalledProcessError as e:
393 log.exception('Error while executing command.')
393 log.exception('Error while executing command.')
394 if e.output:
394 if e.output:
395 log.error('Command output: %s', e.output)
395 log.error('Command output: %s', e.output)
@@ -18,7 +18,7 b''
18 # RhodeCode Enterprise Edition, including its added features, Support services,
18 # RhodeCode Enterprise Edition, including its added features, Support services,
19 # and proprietary license terms, please see https://rhodecode.com/licenses/
19 # and proprietary license terms, please see https://rhodecode.com/licenses/
20
20
21 from subprocess32 import Popen, PIPE
21 from subprocess import Popen, PIPE
22 import os
22 import os
23 import shutil
23 import shutil
24 import sys
24 import sys
@@ -24,7 +24,7 b' Checking the chunked data transfer via H'
24
24
25 import os
25 import os
26 import time
26 import time
27 import subprocess32
27 import subprocess
28
28
29 import pytest
29 import pytest
30 import requests
30 import requests
@@ -53,7 +53,7 b' def echo_app_chunking(request, available'
53 'rhodecode.tests.lib.middleware.utils.test_scm_app_http_chunking'
53 'rhodecode.tests.lib.middleware.utils.test_scm_app_http_chunking'
54 ':create_echo_app')
54 ':create_echo_app')
55 command = command.format(port=port)
55 command = command.format(port=port)
56 proc = subprocess32.Popen(command.split(' '), bufsize=0)
56 proc = subprocess.Popen(command.split(' '), bufsize=0)
57 echo_app_url = 'http://localhost:' + str(port)
57 echo_app_url = 'http://localhost:' + str(port)
58
58
59 @request.addfinalizer
59 @request.addfinalizer
@@ -78,7 +78,7 b' def scm_app(request, available_port_fact'
78 command = command.format(port=port)
78 command = command.format(port=port)
79 env = os.environ.copy()
79 env = os.environ.copy()
80 env["RC_ECHO_URL"] = echo_app_chunking
80 env["RC_ECHO_URL"] = echo_app_chunking
81 proc = subprocess32.Popen(command.split(' '), bufsize=0, env=env)
81 proc = subprocess.Popen(command.split(' '), bufsize=0, env=env)
82 scm_app_url = 'http://localhost:' + str(port)
82 scm_app_url = 'http://localhost:' + str(port)
83 wait_for_url(scm_app_url)
83 wait_for_url(scm_app_url)
84
84
@@ -32,7 +32,7 b' import itertools'
32 import os
32 import os
33 import pprint
33 import pprint
34 import shutil
34 import shutil
35 import subprocess32
35 import subprocess
36 import sys
36 import sys
37 import time
37 import time
38
38
@@ -77,12 +77,12 b' def execute(*popenargs, **kwargs):'
77 input = kwargs.pop('stdin', None)
77 input = kwargs.pop('stdin', None)
78 stdin = None
78 stdin = None
79 if input:
79 if input:
80 stdin = subprocess32.PIPE
80 stdin = subprocess.PIPE
81 #if 'stderr' not in kwargs:
81 #if 'stderr' not in kwargs:
82 # kwargs['stderr'] = subprocess32.PIPE
82 # kwargs['stderr'] = subprocess.PIPE
83 if 'stdout' in kwargs:
83 if 'stdout' in kwargs:
84 raise ValueError('stdout argument not allowed, it will be overridden.')
84 raise ValueError('stdout argument not allowed, it will be overridden.')
85 process = subprocess32.Popen(stdin=stdin, stdout=subprocess32.PIPE,
85 process = subprocess.Popen(stdin=stdin, stdout=subprocess.PIPE,
86 *popenargs, **kwargs)
86 *popenargs, **kwargs)
87 output, error = process.communicate(input=input)
87 output, error = process.communicate(input=input)
88 retcode = process.poll()
88 retcode = process.poll()
@@ -91,7 +91,7 b' def execute(*popenargs, **kwargs):'
91 if cmd is None:
91 if cmd is None:
92 cmd = popenargs[0]
92 cmd = popenargs[0]
93 print('{} {} {} '.format(cmd, output, error))
93 print('{} {} {} '.format(cmd, output, error))
94 raise subprocess32.CalledProcessError(retcode, cmd, output=output)
94 raise subprocess.CalledProcessError(retcode, cmd, output=output)
95 return output
95 return output
96
96
97
97
@@ -31,7 +31,7 b' To stop the script by press Ctrl-C'
31 import datetime
31 import datetime
32 import os
32 import os
33 import psutil
33 import psutil
34 import subprocess32
34 import subprocess
35 import sys
35 import sys
36 import time
36 import time
37 import traceback
37 import traceback
@@ -66,7 +66,7 b' def dump_system():'
66
66
67
67
68 def count_dulwich_fds(proc):
68 def count_dulwich_fds(proc):
69 p = subprocess32.Popen(["lsof", "-p", proc.pid], stdout=subprocess32.PIPE)
69 p = subprocess.Popen(["lsof", "-p", proc.pid], stdout=subprocess.PIPE)
70 out, err = p.communicate()
70 out, err = p.communicate()
71
71
72 count = 0
72 count = 0
@@ -117,7 +117,7 b' print("VCS - Ok")'
117
117
118 print("\nStarting RhodeCode...")
118 print("\nStarting RhodeCode...")
119 rc = psutil.Popen("RC_VCSSERVER_TEST_DISABLE=1 paster serve test.ini",
119 rc = psutil.Popen("RC_VCSSERVER_TEST_DISABLE=1 paster serve test.ini",
120 shell=True, stdin=subprocess32.PIPE)
120 shell=True, stdin=subprocess.PIPE)
121 time.sleep(1)
121 time.sleep(1)
122 if not rc.is_running():
122 if not rc.is_running():
123 print("RC - Failed to start")
123 print("RC - Failed to start")
@@ -40,7 +40,7 b' import functools'
40 import logging
40 import logging
41 import os
41 import os
42 import shutil
42 import shutil
43 import subprocess32
43 import subprocess
44 import tempfile
44 import tempfile
45 import time
45 import time
46 from itertools import chain
46 from itertools import chain
@@ -145,8 +145,8 b' class Repository(object):'
145
145
146 def _run(self, *args):
146 def _run(self, *args):
147 command = [self.BASE_COMMAND] + list(args)
147 command = [self.BASE_COMMAND] + list(args)
148 process = subprocess32.Popen(
148 process = subprocess.Popen(
149 command, stdout=subprocess32.PIPE, stderr=subprocess32.PIPE)
149 command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
150 return process.communicate()
150 return process.communicate()
151
151
152 def _create_file(self, name, size):
152 def _create_file(self, name, size):
@@ -26,7 +26,7 b' import re'
26 import pprint
26 import pprint
27 import shutil
27 import shutil
28 import socket
28 import socket
29 import subprocess32
29 import subprocess
30 import time
30 import time
31 import uuid
31 import uuid
32 import dateutil.tz
32 import dateutil.tz
@@ -928,7 +928,7 b' class RepoServer(object):'
928 if vcsrepo.alias != 'svn':
928 if vcsrepo.alias != 'svn':
929 raise TypeError("Backend %s not supported" % vcsrepo.alias)
929 raise TypeError("Backend %s not supported" % vcsrepo.alias)
930
930
931 proc = subprocess32.Popen(
931 proc = subprocess.Popen(
932 ['svnserve', '-d', '--foreground', '--listen-host', 'localhost',
932 ['svnserve', '-d', '--foreground', '--listen-host', 'localhost',
933 '--root', vcsrepo.path])
933 '--root', vcsrepo.path])
934 self._cleanup_servers.append(proc)
934 self._cleanup_servers.append(proc)
@@ -30,7 +30,7 b' from os.path import join as jn'
30 from os.path import dirname as dn
30 from os.path import dirname as dn
31
31
32 from tempfile import _RandomNameSequence
32 from tempfile import _RandomNameSequence
33 from subprocess32 import Popen, PIPE
33 from subprocess import Popen, PIPE
34
34
35 from rhodecode.lib.utils2 import engine_from_config
35 from rhodecode.lib.utils2 import engine_from_config
36 from rhodecode.lib.auth import get_crypt_password
36 from rhodecode.lib.auth import get_crypt_password
@@ -23,7 +23,7 b' import os'
23 import time
23 import time
24 import tempfile
24 import tempfile
25 import pytest
25 import pytest
26 import subprocess32
26 import subprocess
27 import configobj
27 import configobj
28 import logging
28 import logging
29 from urllib.request import urlopen
29 from urllib.request import urlopen
@@ -152,7 +152,7 b' class RcVCSServer(ServerBase):'
152 log.info('rhodecode-vcsserver command: {}'.format(self.command))
152 log.info('rhodecode-vcsserver command: {}'.format(self.command))
153 log.info('rhodecode-vcsserver logfile: {}'.format(self.log_file))
153 log.info('rhodecode-vcsserver logfile: {}'.format(self.log_file))
154
154
155 self.process = subprocess32.Popen(
155 self.process = subprocess.Popen(
156 self._args, bufsize=0, env=env,
156 self._args, bufsize=0, env=env,
157 stdout=self.server_out, stderr=self.server_out)
157 stdout=self.server_out, stderr=self.server_out)
158
158
@@ -184,7 +184,7 b' class RcWebServer(ServerBase):'
184 log.info('rhodecode-web command: {}'.format(self.command))
184 log.info('rhodecode-web command: {}'.format(self.command))
185 log.info('rhodecode-web logfile: {}'.format(self.log_file))
185 log.info('rhodecode-web logfile: {}'.format(self.log_file))
186
186
187 self.process = subprocess32.Popen(
187 self.process = subprocess.Popen(
188 self._args, bufsize=0, env=env,
188 self._args, bufsize=0, env=env,
189 stdout=self.server_out, stderr=self.server_out)
189 stdout=self.server_out, stderr=self.server_out)
190
190
@@ -22,7 +22,7 b' import threading'
22 import time
22 import time
23 import logging
23 import logging
24 import os.path
24 import os.path
25 import subprocess32
25 import subprocess
26 import tempfile
26 import tempfile
27 import urllib.request, urllib.error, urllib.parse
27 import urllib.request, urllib.error, urllib.parse
28 from lxml.html import fromstring, tostring
28 from lxml.html import fromstring, tostring
@@ -223,10 +223,10 b' def _load_svn_dump_into_repo(dump_name, '
223 integrated with the main repository once they stabilize more.
223 integrated with the main repository once they stabilize more.
224 """
224 """
225 dump = rc_testdata.load_svn_dump(dump_name)
225 dump = rc_testdata.load_svn_dump(dump_name)
226 load_dump = subprocess32.Popen(
226 load_dump = subprocess.Popen(
227 ['svnadmin', 'load', repo_path],
227 ['svnadmin', 'load', repo_path],
228 stdin=subprocess32.PIPE, stdout=subprocess32.PIPE,
228 stdin=subprocess.PIPE, stdout=subprocess.PIPE,
229 stderr=subprocess32.PIPE)
229 stderr=subprocess.PIPE)
230 out, err = load_dump.communicate(dump)
230 out, err = load_dump.communicate(dump)
231 if load_dump.returncode != 0:
231 if load_dump.returncode != 0:
232 log.error("Output of load_dump command: %s", out)
232 log.error("Output of load_dump command: %s", out)
@@ -20,7 +20,7 b''
20
20
21 import os
21 import os
22 import datetime
22 import datetime
23 import subprocess32
23 import subprocess
24
24
25 import pytest
25 import pytest
26
26
@@ -86,8 +86,8 b' class TestGetScm(object):'
86 def test_get_two_scms_for_path(self, tmpdir):
86 def test_get_two_scms_for_path(self, tmpdir):
87 multialias_repo_path = str(tmpdir)
87 multialias_repo_path = str(tmpdir)
88
88
89 subprocess32.check_call(['hg', 'init', multialias_repo_path])
89 subprocess.check_call(['hg', 'init', multialias_repo_path])
90 subprocess32.check_call(['git', 'init', multialias_repo_path])
90 subprocess.check_call(['git', 'init', multialias_repo_path])
91
91
92 with pytest.raises(VCSError):
92 with pytest.raises(VCSError):
93 get_scm(multialias_repo_path)
93 get_scm(multialias_repo_path)
@@ -27,7 +27,7 b' import os'
27 import re
27 import re
28 import sys
28 import sys
29
29
30 from subprocess32 import Popen
30 from subprocess import Popen
31
31
32
32
33 class VCSTestError(Exception):
33 class VCSTestError(Exception):
@@ -28,7 +28,7 b' Base for test suite for making push/pull'
28 """
28 """
29
29
30 from os.path import join as jn
30 from os.path import join as jn
31 from subprocess32 import Popen, PIPE
31 from subprocess import Popen, PIPE
32 import logging
32 import logging
33 import os
33 import os
34 import tempfile
34 import tempfile
General Comments 0
You need to be logged in to leave comments. Login now