From b45a5036608f64179bda689464c834b01e8da242 Mon Sep 17 00:00:00 2001 From: serge-sans-paille Date: Tue, 19 Dec 2023 06:50:36 +0000 Subject: [PATCH] Bug 1866829 - Replace obsolete distutils reference by portable alternatives r=ahochheiden distutils.dir_util.copy_tree -> shutil.copytree distutils.spawn.find_executable -> shutil.which Also fix a warning about escape sequence in the process. Differential Revision: https://phabricator.services.mozilla.com/D194781 --- testing/mozbase/mozdevice/mozdevice/adb.py | 6 +++--- .../mozbase/mozdevice/mozdevice/remote_process_monitor.py | 2 +- testing/mozbase/mozrunner/mozrunner/application.py | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/testing/mozbase/mozdevice/mozdevice/adb.py b/testing/mozbase/mozdevice/mozdevice/adb.py index cf1b78064e20d..d2dcc88b46e39 100644 --- a/testing/mozbase/mozdevice/mozdevice/adb.py +++ b/testing/mozbase/mozdevice/mozdevice/adb.py @@ -15,7 +15,7 @@ import tempfile import time import traceback -from distutils import dir_util +from shutil import copytree from threading import Thread import six @@ -2983,7 +2983,7 @@ def push(self, local, remote, timeout=None): temp_parent = tempfile.mkdtemp() remote_name = os.path.basename(remote) new_local = os.path.join(temp_parent, remote_name) - dir_util.copy_tree(local, new_local) + copytree(local, new_local) local = new_local # See do_sync_push in # https://android.googlesource.com/platform/system/core/+/master/adb/file_sync_client.cpp @@ -3136,7 +3136,7 @@ def pull(self, remote, local, timeout=None): self.rm(intermediate, recursive=True, force=True, timeout=timeout) finally: if copy_required: - dir_util.copy_tree(local, original_local) + copytree(local, original_local, dirs_exist_ok=True) shutil.rmtree(temp_parent) def get_file(self, remote, offset=None, length=None, timeout=None): diff --git a/testing/mozbase/mozdevice/mozdevice/remote_process_monitor.py b/testing/mozbase/mozdevice/mozdevice/remote_process_monitor.py index 29e0d4e008ff1..2934a9f3d18bd 100644 --- a/testing/mozbase/mozdevice/mozdevice/remote_process_monitor.py +++ b/testing/mozbase/mozdevice/mozdevice/remote_process_monitor.py @@ -135,7 +135,7 @@ def read_stdout(self): self.last_test_seen = "Last test finished" elif message.get("action") == "log": line = message["message"].strip() - m = re.match(".*:\s*(\d*)", line) + m = re.match(r".*:\s*(\d*)", line) if m: try: val = int(m.group(1)) diff --git a/testing/mozbase/mozrunner/mozrunner/application.py b/testing/mozbase/mozrunner/mozrunner/application.py index d1dd91e4c0720..bbafa9ff5a8be 100644 --- a/testing/mozbase/mozrunner/mozrunner/application.py +++ b/testing/mozbase/mozrunner/mozrunner/application.py @@ -5,7 +5,7 @@ import os import posixpath from abc import ABCMeta, abstractmethod -from distutils.spawn import find_executable +from shutil import which import six from mozdevice import ADBDeviceFactory @@ -51,7 +51,7 @@ class RemoteContext(object): @property def bindir(self): if self._bindir is None: - paths = [find_executable("emulator")] + paths = [which("emulator")] paths = [p for p in paths if p is not None if os.path.isfile(p)] if not paths: self._bindir = "" @@ -88,7 +88,7 @@ def which(self, binary): paths.insert(0, os.path.abspath(self.bindir)) os.environ["PATH"] = os.pathsep.join(paths) - return find_executable(binary) + return which(binary) @abstractmethod def stop_application(self):