mirror of
https://github.com/ARM-software/devlib.git
synced 2025-01-31 02:00:45 +00:00
Import quote() form shlex rather than pipes
pipes module is deprecated since 3.11, and quote() has been available in shlex since 3.3.
This commit is contained in:
parent
cc3498d315
commit
111aa327ce
@ -21,7 +21,7 @@ import re
|
|||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
import contextlib
|
import contextlib
|
||||||
from pipes import quote
|
from shlex import quote
|
||||||
|
|
||||||
from devlib.collector import (CollectorBase, CollectorOutput,
|
from devlib.collector import (CollectorBase, CollectorOutput,
|
||||||
CollectorOutputEntry)
|
CollectorOutputEntry)
|
||||||
|
@ -20,7 +20,7 @@ import subprocess
|
|||||||
import logging
|
import logging
|
||||||
from distutils.dir_util import copy_tree
|
from distutils.dir_util import copy_tree
|
||||||
from getpass import getpass
|
from getpass import getpass
|
||||||
from pipes import quote
|
from shlex import quote
|
||||||
|
|
||||||
from devlib.exception import (
|
from devlib.exception import (
|
||||||
TargetTransientError, TargetStableError,
|
TargetTransientError, TargetStableError,
|
||||||
|
@ -23,7 +23,7 @@ import shlex
|
|||||||
from fcntl import fcntl, F_GETFL, F_SETFL
|
from fcntl import fcntl, F_GETFL, F_SETFL
|
||||||
from string import Template
|
from string import Template
|
||||||
from subprocess import Popen, PIPE, STDOUT
|
from subprocess import Popen, PIPE, STDOUT
|
||||||
from pipes import quote
|
from shlex import quote
|
||||||
|
|
||||||
from devlib import Instrument, CONTINUOUS, MeasurementsCsv
|
from devlib import Instrument, CONTINUOUS, MeasurementsCsv
|
||||||
from devlib.exception import HostError
|
from devlib.exception import HostError
|
||||||
|
@ -32,12 +32,12 @@
|
|||||||
# pylint: disable=W0613,E1101,access-member-before-definition,attribute-defined-outside-init
|
# pylint: disable=W0613,E1101,access-member-before-definition,attribute-defined-outside-init
|
||||||
from __future__ import division
|
from __future__ import division
|
||||||
import os
|
import os
|
||||||
import subprocess
|
|
||||||
import signal
|
|
||||||
from pipes import quote
|
|
||||||
|
|
||||||
import tempfile
|
|
||||||
import shutil
|
import shutil
|
||||||
|
import signal
|
||||||
|
import tempfile
|
||||||
|
import subprocess
|
||||||
|
from shlex import quote
|
||||||
|
|
||||||
|
|
||||||
from devlib.instrument import Instrument, CONTINUOUS, MeasurementsCsv
|
from devlib.instrument import Instrument, CONTINUOUS, MeasurementsCsv
|
||||||
from devlib.exception import HostError
|
from devlib.exception import HostError
|
||||||
|
@ -19,7 +19,7 @@ import tempfile
|
|||||||
import struct
|
import struct
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
from pipes import quote
|
from shlex import quote
|
||||||
|
|
||||||
from devlib.instrument import Instrument, CONTINUOUS, MeasurementsCsv
|
from devlib.instrument import Instrument, CONTINUOUS, MeasurementsCsv
|
||||||
from devlib.exception import HostError
|
from devlib.exception import HostError
|
||||||
|
@ -19,7 +19,7 @@ import shutil
|
|||||||
import time
|
import time
|
||||||
import types
|
import types
|
||||||
import shlex
|
import shlex
|
||||||
from pipes import quote
|
from shlex import quote
|
||||||
|
|
||||||
from devlib.exception import TargetStableError
|
from devlib.exception import TargetStableError
|
||||||
from devlib.host import PACKAGE_BIN_DIRECTORY
|
from devlib.host import PACKAGE_BIN_DIRECTORY
|
||||||
|
@ -36,10 +36,10 @@ import inspect
|
|||||||
import itertools
|
import itertools
|
||||||
from collections import namedtuple, defaultdict
|
from collections import namedtuple, defaultdict
|
||||||
from contextlib import contextmanager
|
from contextlib import contextmanager
|
||||||
from pipes import quote
|
|
||||||
from past.builtins import long
|
from past.builtins import long
|
||||||
from past.types import basestring
|
from past.types import basestring
|
||||||
from numbers import Number
|
from numbers import Number
|
||||||
|
from shlex import quote
|
||||||
try:
|
try:
|
||||||
from collections.abc import Mapping
|
from collections.abc import Mapping
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
@ -35,11 +35,7 @@ import threading
|
|||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
from io import StringIO
|
from io import StringIO
|
||||||
from lxml import etree
|
from lxml import etree
|
||||||
|
from shlex import quote
|
||||||
try:
|
|
||||||
from shlex import quote
|
|
||||||
except ImportError:
|
|
||||||
from pipes import quote
|
|
||||||
|
|
||||||
from devlib.exception import TargetTransientError, TargetStableError, HostError, TargetTransientCalledProcessError, TargetStableCalledProcessError, AdbRootError
|
from devlib.exception import TargetTransientError, TargetStableError, HostError, TargetTransientCalledProcessError, TargetStableCalledProcessError, AdbRootError
|
||||||
from devlib.utils.misc import check_output, which, ABI_MAP, redirect_streams, get_subprocess
|
from devlib.utils.misc import check_output, which, ABI_MAP, redirect_streams, get_subprocess
|
||||||
|
@ -47,11 +47,7 @@ try:
|
|||||||
except AttributeError:
|
except AttributeError:
|
||||||
from contextlib2 import ExitStack
|
from contextlib2 import ExitStack
|
||||||
|
|
||||||
try:
|
from shlex import quote
|
||||||
from shlex import quote
|
|
||||||
except ImportError:
|
|
||||||
from pipes import quote
|
|
||||||
|
|
||||||
from past.builtins import basestring
|
from past.builtins import basestring
|
||||||
|
|
||||||
# pylint: disable=redefined-builtin
|
# pylint: disable=redefined-builtin
|
||||||
@ -462,7 +458,7 @@ def escape_quotes(text):
|
|||||||
"""
|
"""
|
||||||
Escape quotes, and escaped quotes, in the specified text.
|
Escape quotes, and escaped quotes, in the specified text.
|
||||||
|
|
||||||
.. note:: :func:`pipes.quote` should be favored where possible.
|
.. note:: :func:`shlex.quote` should be favored where possible.
|
||||||
"""
|
"""
|
||||||
return re.sub(r'\\("|\')', r'\\\\\1', text).replace('\'', '\\\'').replace('\"', '\\\"')
|
return re.sub(r'\\("|\')', r'\\\\\1', text).replace('\'', '\\\'').replace('\"', '\\\"')
|
||||||
|
|
||||||
@ -471,7 +467,7 @@ def escape_single_quotes(text):
|
|||||||
"""
|
"""
|
||||||
Escape single quotes, and escaped single quotes, in the specified text.
|
Escape single quotes, and escaped single quotes, in the specified text.
|
||||||
|
|
||||||
.. note:: :func:`pipes.quote` should be favored where possible.
|
.. note:: :func:`shlex.quote` should be favored where possible.
|
||||||
"""
|
"""
|
||||||
return re.sub(r'\\("|\')', r'\\\\\1', text).replace('\'', '\'\\\'\'')
|
return re.sub(r'\\("|\')', r'\\\\\1', text).replace('\'', '\'\\\'\'')
|
||||||
|
|
||||||
@ -480,7 +476,7 @@ def escape_double_quotes(text):
|
|||||||
"""
|
"""
|
||||||
Escape double quotes, and escaped double quotes, in the specified text.
|
Escape double quotes, and escaped double quotes, in the specified text.
|
||||||
|
|
||||||
.. note:: :func:`pipes.quote` should be favored where possible.
|
.. note:: :func:`shlex.quote` should be favored where possible.
|
||||||
"""
|
"""
|
||||||
return re.sub(r'\\("|\')', r'\\\\\1', text).replace('\"', '\\\"')
|
return re.sub(r'\\("|\')', r'\\\\\1', text).replace('\"', '\\\"')
|
||||||
|
|
||||||
@ -489,7 +485,7 @@ def escape_spaces(text):
|
|||||||
"""
|
"""
|
||||||
Escape spaces in the specified text
|
Escape spaces in the specified text
|
||||||
|
|
||||||
.. note:: :func:`pipes.quote` should be favored where possible.
|
.. note:: :func:`shlex.quote` should be favored where possible.
|
||||||
"""
|
"""
|
||||||
return text.replace(' ', '\\ ')
|
return text.replace(' ', '\\ ')
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ import tempfile
|
|||||||
import threading
|
import threading
|
||||||
import time
|
import time
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
from pipes import quote
|
from shlex import quote
|
||||||
|
|
||||||
# pylint: disable=redefined-builtin
|
# pylint: disable=redefined-builtin
|
||||||
from devlib.exception import WorkerThreadError, TargetNotRespondingError, TimeoutError
|
from devlib.exception import WorkerThreadError, TargetNotRespondingError, TimeoutError
|
||||||
|
@ -32,8 +32,8 @@ import weakref
|
|||||||
import select
|
import select
|
||||||
import copy
|
import copy
|
||||||
import functools
|
import functools
|
||||||
from pipes import quote
|
|
||||||
from future.utils import raise_from
|
from future.utils import raise_from
|
||||||
|
from shlex import quote
|
||||||
|
|
||||||
from paramiko.client import SSHClient, AutoAddPolicy, RejectPolicy
|
from paramiko.client import SSHClient, AutoAddPolicy, RejectPolicy
|
||||||
import paramiko.ssh_exception
|
import paramiko.ssh_exception
|
||||||
|
Loading…
x
Reference in New Issue
Block a user