diff --git a/README.sync b/README.sync index 4830fa2b3..0fdce06c7 100644 --- a/README.sync +++ b/README.sync @@ -4,11 +4,11 @@ The pkg5 components have been updated to the latest upstream solaris-ips as of: -commit 616fce8ad21fc03eaa77ba38508c66c356f03d65 +commit 2cb20af7cc68247c0a809de5378915a99d2bc17b Author: Jakub Kulik -Date: Wed May 29 05:44:20 2024 -0700 +Date: Thu Jun 20 04:41:22 2024 -0700 - 36620736 TestPkgrepoMultiRepo.test_01_diff failing post 36247279 + 36752252 fix several real errors reported by pylint ----------------------------------------------------------------------------- diff --git a/src/modules/actions/driver.py b/src/modules/actions/driver.py index 315641b78..2250b510e 100644 --- a/src/modules/actions/driver.py +++ b/src/modules/actions/driver.py @@ -31,11 +31,11 @@ """ import os +import subprocess from pkg.actions import generic from tempfile import mkstemp -import pkg.pkgsubprocess as subprocess from pkg.client.debugvalues import DebugValues diff --git a/src/modules/client/bootenv.py b/src/modules/client/bootenv.py index 3967f884c..162ba38cb 100644 --- a/src/modules/client/bootenv.py +++ b/src/modules/client/bootenv.py @@ -26,6 +26,7 @@ import errno import os import shutil +import subprocess import tempfile from pkg.client import global_settings @@ -35,7 +36,6 @@ import pkg.client.api_errors as api_errors import pkg.misc as misc import pkg.portable as portable -import pkg.pkgsubprocess as subprocess # Since pkg(1) may be installed without libbe installed # check for libbe and import it if it exists. diff --git a/src/modules/client/client_api.py b/src/modules/client/client_api.py index 9f6bbb50e..595dcb105 100644 --- a/src/modules/client/client_api.py +++ b/src/modules/client/client_api.py @@ -3910,7 +3910,7 @@ def __handle_errors_json( def _wrapper(): raise __e.wrapped - ret_json = __handle_errors_json(_wrapper, non_wrap_print=False) + __, ret_json = __handle_errors_json(_wrapper, non_wrap_print=False) s = "" if ret_json["status"] == 99: diff --git a/src/modules/client/firmware.py b/src/modules/client/firmware.py index 3830432f0..f6214b1ae 100644 --- a/src/modules/client/firmware.py +++ b/src/modules/client/firmware.py @@ -24,10 +24,10 @@ # Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved. # import os.path +import subprocess import sys import pkg.misc as misc -import pkg.pkgsubprocess as subprocess import pkg.portable as portable from pkg.client.debugvalues import DebugValues diff --git a/src/modules/client/image.py b/src/modules/client/image.py index 2f2404cd2..84998a52a 100644 --- a/src/modules/client/image.py +++ b/src/modules/client/image.py @@ -36,6 +36,7 @@ import platform import shutil import stat +import subprocess import sys import tempfile import time @@ -68,7 +69,6 @@ import pkg.mediator as med import pkg.misc as misc import pkg.nrlock -import pkg.pkgsubprocess as subprocess import pkg.portable as portable import pkg.server.catalog import pkg.smf as smf diff --git a/src/modules/client/imageconfig.py b/src/modules/client/imageconfig.py index 1d9d7d477..a8715d943 100644 --- a/src/modules/client/imageconfig.py +++ b/src/modules/client/imageconfig.py @@ -40,7 +40,6 @@ import pkg.config as cfg import pkg.facet as facet import pkg.misc as misc -import pkg.pkgsubprocess as subprocess import pkg.portable as portable import pkg.smf as smf import pkg.variant as variant diff --git a/src/modules/client/linkedimage/common.py b/src/modules/client/linkedimage/common.py index 0fdd82223..743e819ba 100644 --- a/src/modules/client/linkedimage/common.py +++ b/src/modules/client/linkedimage/common.py @@ -67,7 +67,6 @@ import pkg.fmri import pkg.json as json import pkg.misc as misc -import pkg.pkgsubprocess import pkg.version from pkg.client import global_settings diff --git a/src/modules/client/linkedimage/zone.py b/src/modules/client/linkedimage/zone.py index 00608b632..4374674e0 100644 --- a/src/modules/client/linkedimage/zone.py +++ b/src/modules/client/linkedimage/zone.py @@ -35,12 +35,12 @@ # standard python classes import os import tempfile +import subprocess # pkg classes import pkg.client.api_errors as apx import pkg.client.pkgdefs as pkgdefs -import pkg.pkgsubprocess from pkg.client.debugvalues import DebugValues @@ -394,7 +394,7 @@ def _zonename(): # open a temporary file in text mode for compatible string handling fout = tempfile.TemporaryFile(mode="w+") ferrout = tempfile.TemporaryFile(mode="w+") - p = pkg.pkgsubprocess.Popen(cmd, stdout=fout, stderr=ferrout) + p = subprocess.Popen(cmd, stdout=fout, stderr=ferrout) p.wait() if p.returncode != 0: cmd = " ".join(cmd) @@ -471,7 +471,7 @@ def _list_zones(root, path_transform): # open a temporary file in text mode for compatible string handling fout = tempfile.TemporaryFile(mode="w+") ferrout = tempfile.TemporaryFile(mode="w+") - p = pkg.pkgsubprocess.Popen(cmd, stdout=fout, stderr=ferrout) + p = subprocess.Popen(cmd, stdout=fout, stderr=ferrout) p.wait() if p.returncode != 0: cmd = " ".join(cmd) diff --git a/src/modules/client/pkgremote.py b/src/modules/client/pkgremote.py index f388805ad..fd53c9321 100644 --- a/src/modules/client/pkgremote.py +++ b/src/modules/client/pkgremote.py @@ -137,15 +137,6 @@ def __rpc_server_fork( fstderr = tempfile.TemporaryFile() try: - # Under Python 3.4, os.pipe() returns non-inheritable - # file descriptors. On UNIX, subprocess makes file - # descriptors of the pass_fds parameter inheritable. - # Since our pkgsubprocess use posix_pspawn* and doesn't - # have an interface for pass_fds, we reuse the Python - # module subprocess here. - # unexpected-keyword-arg 'pass_fds'; - # pylint: disable=E1123 - # Redefinition of p type p = subprocess.Popen( pkg_cmd, stdout=fstdout, diff --git a/src/modules/cpiofile.py b/src/modules/cpiofile.py index 88f341f41..dc6a87532 100644 --- a/src/modules/cpiofile.py +++ b/src/modules/cpiofile.py @@ -43,7 +43,7 @@ import stat import time import struct -import pkg.pkgsubprocess as subprocess +import subprocess # cpio magic numbers # XXX matches actual cpio archives and /etc/magic, but not archives.h diff --git a/src/modules/depotcontroller.py b/src/modules/depotcontroller.py index 78e8d5329..f42d6c835 100755 --- a/src/modules/depotcontroller.py +++ b/src/modules/depotcontroller.py @@ -28,6 +28,7 @@ import shlex import signal import ssl +import subprocess import sys import time @@ -35,7 +36,6 @@ from urllib.request import pathname2url, urlopen from urllib.parse import urlunparse, urljoin -import pkg.pkgsubprocess as subprocess import pkg.server.repository as sr diff --git a/src/modules/indexer.py b/src/modules/indexer.py index b7a879379..d9193f67e 100644 --- a/src/modules/indexer.py +++ b/src/modules/indexer.py @@ -804,7 +804,7 @@ def _generic_update_index( self.empty_index = False else: - raise RuntimeError("Got unknown input_type: {0}", input_type) + raise RuntimeError(f"Got unknown input_type: {input_type}") # Write out the helper dictionaries self._write_assistant_dicts(tmp_index_dir) diff --git a/src/modules/lint/log.py b/src/modules/lint/log.py index b345f5e9f..8b59e9273 100644 --- a/src/modules/lint/log.py +++ b/src/modules/lint/log.py @@ -172,7 +172,7 @@ def open(self): """Start a new log file""" pass - def format(self, message): + def format(self, message, ignore_linted=False): """Given a LintMessage message, format that object appropriately.""" pass diff --git a/src/modules/manifest.py b/src/modules/manifest.py index 007a13554..bc608ba19 100644 --- a/src/modules/manifest.py +++ b/src/modules/manifest.py @@ -1956,7 +1956,7 @@ def __getitem__(self, key): def __setitem__(self, key, value): """No assignments to factored manifests allowed.""" - assert "FactoredManifests are not dicts" + assert False, "FactoredManifests are not dicts" def __contains__(self, key): if not self.loaded and not self.__load_attributes(): diff --git a/src/modules/pkgsubprocess.py b/src/modules/pkgsubprocess.py deleted file mode 100644 index ba4c2a13e..000000000 --- a/src/modules/pkgsubprocess.py +++ /dev/null @@ -1,311 +0,0 @@ -#!/usr/bin/python3 -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License (the "License"). -# You may not use this file except in compliance with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# - -# -# Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved. -# Copyright 2020 OmniOS Community Edition (OmniOSce) Association. -# - -import os -import sys -import types -import subprocess -import pkg.portable - -try: - import pkg.pspawn - from pkg.pspawn import posix_spawnp - from pkg.pspawn import SpawnFileAction -except ImportError: - pass - -__all__ = ["Popen", "PIPE", "STDOUT", "call"] - - -def call(*args, **kwargs): - return Popen(*args, **kwargs).wait() - - -PIPE = subprocess.PIPE -STDOUT = subprocess.STDOUT - - -class Popen(subprocess.Popen): - def __init__(self, args, pass_fds=None, **kwargs): - if "bufsize" not in kwargs: - kwargs["bufsize"] = 128 * 1024 - subprocess.Popen.__init__(self, args, **kwargs) - - if "posix_spawnp" in globals(): - if sys.version_info.minor >= 11: - # This is the signature for the private - # _execute_child() method in Python 3.11 - def _execute_child( - self, - args, - executable, - preexec_fn, - close_fds, - pass_fds, - cwd, - env, - startupinfo, - creationflags, - shell, - p2cread, - p2cwrite, - c2pread, - c2pwrite, - errread, - errwrite, - restore_signals, - gid, - gids, - uid, - umask, - start_new_session, - process_group, - ): - self._pkg_execute_child( - args, - executable, - preexec_fn, - close_fds, - cwd, - env, - shell, - p2cread, - p2cwrite, - c2pread, - c2pwrite, - errread, - errwrite, - ) - - elif sys.version_info.minor >= 9: - # This is the signature for the private - # _execute_child() method in Python 3.9 and 3.10 - def _execute_child( - self, - args, - executable, - preexec_fn, - close_fds, - pass_fds, - cwd, - env, - startupinfo, - creationflags, - shell, - p2cread, - p2cwrite, - c2pread, - c2pwrite, - errread, - errwrite, - restore_signals, - gid, - gids, - uid, - umask, - start_new_session, - ): - self._pkg_execute_child( - args, - executable, - preexec_fn, - close_fds, - cwd, - env, - shell, - p2cread, - p2cwrite, - c2pread, - c2pwrite, - errread, - errwrite, - ) - - else: - # This is the signature for the private - # _execute_child() method in Python 3.7 and 3.8 - def _execute_child( - self, - args, - executable, - preexec_fn, - close_fds, - pass_fds, - cwd, - env, - startupinfo, - creationflags, - shell, - p2cread, - p2cwrite, - c2pread, - c2pwrite, - errread, - errwrite, - restore_signals, - start_new_session, - ): - self._pkg_execute_child( - args, - executable, - preexec_fn, - close_fds, - cwd, - env, - shell, - p2cread, - p2cwrite, - c2pread, - c2pwrite, - errread, - errwrite, - ) - - # XXX - can this be replaced by the posix_spawn() support in - # subprocess? This implementation is using posix_spawnp() - # via pkg.pspawn. - def _pkg_execute_child( - self, - args, - executable, - preexec_fn, - close_fds, - cwd, - env, - shell, - p2cread, - p2cwrite, - c2pread, - c2pwrite, - errread, - errwrite, - ): - if isinstance(args, (str, bytes)): - args = [args] - - if shell: - args = ["/bin/sh", "-c"] + args - - if executable is None: - executable = args[0] - - sfa = SpawnFileAction() - - # Child file actions - # Close parent's pipe ends - closed_fds = [] - if p2cwrite != -1: - sfa.add_close(p2cwrite) - closed_fds.append(p2cwrite) - if c2pread != -1: - sfa.add_close(c2pread) - closed_fds.append(c2pread) - if errread != -1: - sfa.add_close(errread) - closed_fds.append(errread) - - # Dup fds for child - if p2cread != -1: - sfa.add_dup2(p2cread, 0) - if c2pwrite != -1: - sfa.add_dup2(c2pwrite, 1) - if errwrite != -1: - sfa.add_dup2(errwrite, 2) - - # Close pipe fds. Make sure we don't close the - # same fd more than once, or standard fds. - for fd in [p2cread, c2pwrite, errwrite]: - if fd > 2 and fd not in closed_fds: - sfa.add_close(fd) - closed_fds.append(fd) - - if cwd is not None: - os.chdir(cwd) - - if preexec_fn: - preexec_fn() - - # Close all other fds, if asked for - after - # preexec_fn(), which may open FDs. - if close_fds: - # - # This is a bit tricky. Due to a sad - # behaviour with posix_spawn in nevada - # builds before the fix for 6807216 (in - # nevada 110), (and perhaps on other OS's?) - # you can't have two close actions close the - # same FD, or an error results. So we track - # everything we have closed, then manually - # fstat and close up to the max we have - # closed) . Then we close everything above - # that efficiently with add_close_childfds(). - # - # max() can't call on empty list, use a - # trick "close_fds or [0]" to return 0 - # when closed_fds is empty. - for i in range(3, max(closed_fds or [0]) + 1): - # scheduled closed already? skip - if i in closed_fds: - continue - try: - os.fstat(i) - sfa.add_close(i) - closed_fds.append(i) - except OSError: - pass - closefrom = max([3, max(closed_fds or [0]) + 1]) - sfa.add_close_childfds(closefrom) - - if env is None: - # If caller didn't pass us an environment in - # env, borrow the env that the current process - # is using. - env = os.environ.copy() - - if type(env) == dict: - # The bundled subprocess module takes a dict in - # the "env" argument. Allow that here by doing - # the explicit conversion to a list. - env = ["{0}={1}".format(k, v) for k, v in env.items()] - - self.pid = posix_spawnp(executable, args, sfa, env) - self._child_created = True - - # parent - devnull_fd = getattr(self, "_devnull", None) - if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd: - os.close(p2cread) - if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd: - os.close(c2pwrite) - if errwrite != -1 and errread != -1 and errwrite != devnull_fd: - os.close(errwrite) - if devnull_fd is not None: - os.close(devnull_fd) - - -# Vim hints -# vim:ts=4:sw=4:et:fdm=marker diff --git a/src/modules/server/repository.py b/src/modules/server/repository.py index 0a9ef3f71..784339f3d 100644 --- a/src/modules/server/repository.py +++ b/src/modules/server/repository.py @@ -31,6 +31,7 @@ import os.path import shutil import stat +import subprocess import sys import tempfile import zlib @@ -59,7 +60,6 @@ import pkg.server.catalog as old_catalog import pkg.server.query_parser as sqp import pkg.server.transaction as trans -import pkg.pkgsubprocess as subprocess import pkg.version from pkg.pkggzip import PkgGzipFile @@ -2413,14 +2413,14 @@ def __gen_verify( # Stem must be decoded before use. try: pname = unquote(name) - except Exception: + except Exception as err: # Assume error is result of an # unexpected file in the directory. We # don't know the FMRI here, so use None. progtrack.repo_verify_start_pkg(None) progtrack.repo_verify_add_progress(None) yield self.__build_verify_error( - REPO_VERIFY_UNKNOWN, pdir, {"err": str(e)} + REPO_VERIFY_UNKNOWN, pdir, {"err": str(err)} ) progtrack.repo_verify_end_pkg(None) continue diff --git a/src/modules/smf.py b/src/modules/smf.py index 248c0f772..0ef0ab11d 100644 --- a/src/modules/smf.py +++ b/src/modules/smf.py @@ -29,9 +29,9 @@ import locale import os import shlex +import subprocess import pkg.misc as misc -import pkg.pkgsubprocess as subprocess from pkg.client import global_settings from pkg.client.debugvalues import DebugValues diff --git a/src/pull.py b/src/pull.py index c1a19105d..8aae9279b 100755 --- a/src/pull.py +++ b/src/pull.py @@ -35,6 +35,7 @@ import locale import os import shutil + import subprocess import sys import tempfile import traceback @@ -52,7 +53,6 @@ import pkg.misc as misc import pkg.mogrify as mog import pkg.p5p - import pkg.pkgsubprocess as subprocess import pkg.publish.transaction as trans import pkg.server.repository as sr import pkg.version as version diff --git a/src/tests/api/t_plat.py b/src/tests/api/t_plat.py index 91c3cfbd4..a76c75456 100644 --- a/src/tests/api/t_plat.py +++ b/src/tests/api/t_plat.py @@ -32,8 +32,8 @@ import os import shutil import sys +import subprocess import tempfile -import pkg.pkgsubprocess as subprocess import pkg.fmri as fmri import pkg.client.image as image import pkg.portable.util as util diff --git a/src/tests/ro_data/signing_certs/generate_certs.py b/src/tests/ro_data/signing_certs/generate_certs.py index 4f85c4106..9259fc000 100755 --- a/src/tests/ro_data/signing_certs/generate_certs.py +++ b/src/tests/ro_data/signing_certs/generate_certs.py @@ -25,8 +25,8 @@ # import os -import pkg.pkgsubprocess as subprocess import shutil +import subprocess import sys sys.path.append("../../")