From b808b1bcdd79b344246e0147e98708b91b4573fa Mon Sep 17 00:00:00 2001 From: Gavin Mak Date: Mon, 29 Jan 2024 21:29:31 +0000 Subject: [PATCH] Use shlex instead of pipes Importing pipes gets a DeprecationWarning. shlex.quote is equivalent to pipes.quote. Use that instead. Bug: 1522874 Change-Id: I18b8598f2e961d58ba71d886921bda9d9ad956ca Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5243707 Reviewed-by: Joanna Wang Auto-Submit: Gavin Mak Commit-Queue: Joanna Wang --- fetch.py | 6 +++--- gclient_utils.py | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/fetch.py b/fetch.py index 8ae37e314..2c860429f 100755 --- a/fetch.py +++ b/fetch.py @@ -20,7 +20,7 @@ These parameters will be passed through to the config's main method. import json import argparse import os -import pipes +import shlex import subprocess import sys @@ -57,7 +57,7 @@ class Checkout(object): pass def run(self, cmd, return_stdout=False, **kwargs): - print('Running: %s' % (' '.join(pipes.quote(x) for x in cmd))) + print('Running: %s' % (' '.join(shlex.quote(x) for x in cmd))) if self.options.dry_run: return '' if return_stdout: @@ -98,7 +98,7 @@ class GclientCheckout(Checkout): class GitCheckout(Checkout): def run_git(self, *cmd, **kwargs): - print('Running: git %s' % (' '.join(pipes.quote(x) for x in cmd))) + print('Running: git %s' % (' '.join(shlex.quote(x) for x in cmd))) if self.options.dry_run: return '' return git_common.run(*cmd, **kwargs) diff --git a/gclient_utils.py b/gclient_utils.py index 95006cf0b..eb911e7a0 100644 --- a/gclient_utils.py +++ b/gclient_utils.py @@ -13,10 +13,10 @@ import io import logging import operator import os -import pipes import platform import queue import re +import shlex import stat import subprocess import sys @@ -369,7 +369,7 @@ def safe_makedirs(tree): def CommandToStr(args): """Converts an arg list into a shell escaped string.""" - return ' '.join(pipes.quote(arg) for arg in args) + return ' '.join(shlex.quote(arg) for arg in args) class Wrapper(object):