Removing Python 2-compatible imports of urllib.request.open and shlex.quote

This commit is contained in:
Yannick Jadoul
2020-02-04 11:58:52 +01:00
parent b900b2d51e
commit 67ec8fe99f
4 changed files with 7 additions and 26 deletions
+4 -9
View File
@@ -1,13 +1,8 @@
from __future__ import print_function from __future__ import print_function
import os, subprocess, sys, uuid, textwrap import os, shlex, subprocess, sys, textwrap, uuid
from collections import namedtuple from collections import namedtuple
from .util import prepare_command, get_build_verbosity_extra_flags from .util import prepare_command, get_build_verbosity_extra_flags
try:
from shlex import quote as shlex_quote
except ImportError:
from pipes import quote as shlex_quote
def get_python_configurations(build_selector): def get_python_configurations(build_selector):
PythonConfiguration = namedtuple('PythonConfiguration', ['identifier', 'path']) PythonConfiguration = namedtuple('PythonConfiguration', ['identifier', 'path'])
@@ -132,14 +127,14 @@ def build(project_dir, output_dir, test_command, test_requires, test_extras, bef
pybin_paths=' '.join(c.path+'/bin' for c in platform_configs), pybin_paths=' '.join(c.path+'/bin' for c in platform_configs),
test_requires=' '.join(test_requires), test_requires=' '.join(test_requires),
test_extras=test_extras, test_extras=test_extras,
test_command=shlex_quote( test_command=shlex.quote(
prepare_command(test_command, project='/project') if test_command else '' prepare_command(test_command, project='/project') if test_command else ''
), ),
before_build=shlex_quote( before_build=shlex.quote(
prepare_command(before_build, project='/project') if before_build else '' prepare_command(before_build, project='/project') if before_build else ''
), ),
build_verbosity_flag=' '.join(get_build_verbosity_extra_flags(build_verbosity)), build_verbosity_flag=' '.join(get_build_verbosity_extra_flags(build_verbosity)),
repair_command=shlex_quote( repair_command=shlex.quote(
prepare_command(repair_command, wheel='"$1"', dest_dir='/tmp/repaired_wheels') if repair_command else '' prepare_command(repair_command, wheel='"$1"', dest_dir='/tmp/repaired_wheels') if repair_command else ''
), ),
environment_exports='\n'.join(environment.as_shell_commands()), environment_exports='\n'.join(environment.as_shell_commands()),
+1 -5
View File
@@ -3,10 +3,6 @@ import tempfile
import os, subprocess, shlex, sys, shutil import os, subprocess, shlex, sys, shutil
from collections import namedtuple from collections import namedtuple
from glob import glob from glob import glob
try:
from shlex import quote as shlex_quote
except ImportError:
from pipes import quote as shlex_quote
from .util import prepare_command, get_build_verbosity_extra_flags, download from .util import prepare_command, get_build_verbosity_extra_flags, download
@@ -46,7 +42,7 @@ def build(project_dir, output_dir, test_command, test_requires, test_extras, bef
if shell: if shell:
print('+ %s' % args) print('+ %s' % args)
else: else:
print('+ ' + ' '.join(shlex_quote(a) for a in args)) print('+ ' + ' '.join(shlex.quote(a) for a in args))
return subprocess.check_call(args, env=env, cwd=cwd, shell=shell) return subprocess.check_call(args, env=env, cwd=cwd, shell=shell)
+2 -7
View File
@@ -1,13 +1,8 @@
from fnmatch import fnmatch from fnmatch import fnmatch
import warnings import warnings
import os import os, urllib.request
from time import sleep from time import sleep
try:
from urllib.request import urlopen
except ImportError:
from urllib2 import urlopen
def prepare_command(command, **kwargs): def prepare_command(command, **kwargs):
''' '''
@@ -68,7 +63,7 @@ def download(url, dest):
repeat_num = 3 repeat_num = 3
for i in range(repeat_num): for i in range(repeat_num):
try: try:
response = urlopen(url) response = urllib.request.urlopen(url)
except: except:
if i == repeat_num - 1: if i == repeat_num - 1:
raise raise
-5
View File
@@ -3,11 +3,6 @@ import os, tempfile, subprocess, shutil, sys
from collections import namedtuple from collections import namedtuple
from glob import glob from glob import glob
try:
from shlex import quote as shlex_quote
except ImportError:
from pipes import quote as shlex_quote
from .util import prepare_command, get_build_verbosity_extra_flags, download from .util import prepare_command, get_build_verbosity_extra_flags, download