Skip to content

Commit

Permalink
Bug 1866829 - Replace obsolete distutils reference by portable altern…
Browse files Browse the repository at this point in the history
…atives 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
  • Loading branch information
serge-sans-paille authored and hawkeye116477 committed May 25, 2024
1 parent 6f4550f commit b45a503
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions testing/mozbase/mozdevice/mozdevice/adb.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
6 changes: 3 additions & 3 deletions testing/mozbase/mozrunner/mozrunner/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 = ""
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit b45a503

Please sign in to comment.