diff --git a/src/mx/_impl/mx.py b/src/mx/_impl/mx.py index aa390a14..8a8e25fb 100755 --- a/src/mx/_impl/mx.py +++ b/src/mx/_impl/mx.py @@ -7709,17 +7709,18 @@ def redirect(stream): # wait 30 seconds for the Java process to launch and report the port number retries = 0 + myself = f"{self.name}[{p.pid}]" while self.port is None: retries = retries + 1 returncode = p.poll() if returncode is not None: - raise RuntimeError('Error starting ' + self.name() + ': returncode=' + str(returncode) + '\n' + ''.join(pout)) + raise RuntimeError(f'Error starting {myself}: returncode={returncode}\n{"".join(pout)}') if retries == 299: - warn('Killing ' + self.name() + ' after failing to see port number after nearly 30 seconds') + warn(f'Killing {myself} after failing to see port number after nearly 30 seconds') os.kill(p.pid, signal.SIGKILL) time.sleep(1.0) elif retries > 300: - raise RuntimeError('Error starting ' + self.name() + ': No port number was found in output after 30 seconds\n' + ''.join(pout)) + raise RuntimeError(f'Error starting {myself}: No port number was found in output after 30 seconds\n{"".join(pout)}') else: time.sleep(0.1) @@ -7727,10 +7728,10 @@ def redirect(stream): self.closed = False try: self.connection.connect(('127.0.0.1', self.port)) - logv('[Started ' + str(self) + ']') + logv(f'[Started {myself}') return except socket.error as e: - logv('[Error starting ' + str(self) + ': ' + str(e) + ']') + logv(f'[Error starting {myself}: {e}]') raise e def _noticePort(self, data): @@ -7767,7 +7768,7 @@ def compile(self, compilerArgs): if _opts.very_verbose: retcode = detailed_retcode else: - log('[exit code: ' + str(retcode) + ']') + log(f'[exit code: {retcode}]') elif retcode == 2: retcode = detailed_retcode abort(retcode) @@ -7780,9 +7781,9 @@ def shutdown(self): self.connection.send(f'{CompilerDaemon.header_shutdown}\n'.encode('utf8')) self.connection.close() self.closed = True - logv('[Stopped ' + str(self) + ']') + logv(f'[Stopped {self}]') except socket.error as e: - logv('Error stopping ' + str(self) + ': ' + str(e)) + logv(f'Error stopping {self}: {e}') def __str__(self): return f"{self.name()} on port {self.port} for {self.jdk} with VM args {self.jvmArgs}" @@ -18180,7 +18181,7 @@ def alarm_handler(signum, frame): _CACHE_DIR = get_env('MX_CACHE_DIR', join(dot_mx_dir(), 'cache')) # The version must be updated for every PR (checked in CI) and the comment should reflect the PR's issue -version = VersionSpec("7.25.0") # DownloadableLibrary +version = VersionSpec("7.25.1") # Avoid assuming there’s a PATH variable defined _mx_start_datetime = datetime.utcnow() diff --git a/src/mx/_impl/mx_proftool.py b/src/mx/_impl/mx_proftool.py index 6d2e361c..bcaf0199 100644 --- a/src/mx/_impl/mx_proftool.py +++ b/src/mx/_impl/mx_proftool.py @@ -920,14 +920,6 @@ def demangled_name(self, short_class_names: bool = False): return self.symbol -def _which(executable): - for path in os.environ['PATH'].split(os.pathsep): - f = os.path.join(path.strip('"'), executable) - if os.path.isfile(f) and os.access(f, os.X_OK): - return f - return None - - class CppDemangler: """An interface for the binutils c++filt demangler, which can demangle C++ symbols.""" @@ -945,7 +937,7 @@ def warn_if_unsupported(cls): def is_supported(cls) -> bool: """Lazily checks whether c++filt is supported.""" if cls._cppfilt_available is None: - cls._cppfilt_available = _which(cls.CPPFILT) is not None + cls._cppfilt_available = shutil.which(cls.CPPFILT) is not None return cls._cppfilt_available @classmethod @@ -1144,7 +1136,7 @@ def __init__(self, files): @staticmethod def is_supported(): if PerfOutput._perf_available is None: - PerfOutput._perf_available = _which('perf') is not None + PerfOutput._perf_available = shutil.which('perf') is not None return PerfOutput._perf_available @staticmethod