diff --git a/src/brand/bhyve/bootlib.py b/src/brand/bhyve/bootlib.py index 8c920a467..d12d2cd39 100644 --- a/src/brand/bhyve/bootlib.py +++ b/src/brand/bhyve/bootlib.py @@ -364,7 +364,7 @@ def parse_ram(v): m = re.search(rf"^(\d+)(.?)$", v) if not m: fatal(f'Could not parse ram value "{v}"') - (mem, suffix) = m.groups() + mem, suffix = m.groups() mem = int(mem) if not suffix: diff --git a/src/brand/emu/boot.py b/src/brand/emu/boot.py index 016009ed0..56ff83c5b 100755 --- a/src/brand/emu/boot.py +++ b/src/brand/emu/boot.py @@ -94,15 +94,13 @@ def usage(msg=None): - print( - """ + print(""" boot [-t] [-x xml] <[-z] zone> -t Test mode - just show what would be done -j Output the computed zone data in JSON format -x Path to zone's XML file -z Name of zone -""" - ) +""") if msg: print(msg) diff --git a/src/cffi_src/build_arch.py b/src/cffi_src/build_arch.py index b3a13db28..096459b95 100755 --- a/src/cffi_src/build_arch.py +++ b/src/cffi_src/build_arch.py @@ -38,8 +38,7 @@ extra_compile_args=["-O3"], ) -ffi.cdef( - """ +ffi.cdef(""" /* Macros */ #define SI_RELEASE 3 /* return release of operating system */ #define SI_ARCHITECTURE_32 516 /* basic 32-bit SI_ARCHITECTURE */ @@ -51,8 +50,7 @@ void *realloc(void *, size_t); void free(void *); int sysinfo(int, char *, long); -""" -) +""") if __name__ == "__main__": ffi.compile(verbose=False) diff --git a/src/cffi_src/build_sha512_t.py b/src/cffi_src/build_sha512_t.py index 409d1c05e..5b68e8033 100755 --- a/src/cffi_src/build_sha512_t.py +++ b/src/cffi_src/build_sha512_t.py @@ -40,8 +40,7 @@ libraries=["md"], ) -ffi.cdef( - """ +ffi.cdef(""" #define SHA512_224 9 #define SHA512_256 10 @@ -68,8 +67,7 @@ void SHA2Update(SHA2_CTX *ctx, const void *buf, size_t bufsz); void SHA2Final(void *digest, SHA2_CTX *ctx); void *memcpy(void *restrict s1, const void *restrict s2, size_t n); -""" -) +""") if __name__ == "__main__": ffi.compile(verbose=False) diff --git a/src/cffi_src/build_sysattr.py b/src/cffi_src/build_sysattr.py index f7b27304d..7d770f052 100755 --- a/src/cffi_src/build_sysattr.py +++ b/src/cffi_src/build_sysattr.py @@ -42,8 +42,7 @@ libraries=["nvpair"], ) -ffi.cdef( - """ +ffi.cdef(""" /* Macros */ #define NV_UNIQUE_NAME 0x1 @@ -148,8 +147,7 @@ char *nvpair_name(nvpair_t *); data_type_t nvpair_type(nvpair_t *); int nvpair_value_boolean_value(nvpair_t *, boolean_t *); -""" -) +""") if __name__ == "__main__": ffi.compile(verbose=False) diff --git a/src/cffi_src/build_syscallat.py b/src/cffi_src/build_syscallat.py index fe6ef113f..76aee4699 100755 --- a/src/cffi_src/build_syscallat.py +++ b/src/cffi_src/build_syscallat.py @@ -40,8 +40,7 @@ extra_compile_args=["-O3"], ) -ffi.cdef( - """ +ffi.cdef(""" /* Types */ typedef int... mode_t; /* file attribute type */ @@ -50,8 +49,7 @@ int openat(int, const char *, int, mode_t); int renameat(int, const char *, int, const char *); int unlinkat(int, const char *, int); -""" -) +""") if __name__ == "__main__": ffi.compile(verbose=False) diff --git a/src/client.py b/src/client.py index 12ae6376d..c069f283c 100755 --- a/src/client.py +++ b/src/client.py @@ -50,15 +50,13 @@ import sys if sys.platform == "sunos5": - print( - """ + print(""" The Python environment on this system is damaged and missing a critical core component (pkg.site_paths) and can not be repaired with pkg(1). To recover this system reboot and select an alternate Boot Environment (BE) from the boot menu. From the alternate BE mount and run 'pkg fix' on this BE. -""" - ) +""") sys.exit(1) pkg.site_paths.init() @@ -600,23 +598,17 @@ def print_cmds(cmd_list, cmd_dic): if verbose: # Display a verbose usage message of subcommands. - logger.error( - _( - """\ + logger.error(_("""\ Usage: pkg [options] command [cmd_options] [operands] -""" - ) - ) +""")) logger.error(_("Basic subcommands:")) print_cmds(basic_cmds, basic_usage) logger.error(_("\nAdvanced subcommands:")) print_cmds(advanced_cmds, adv_usage) - logger.error( - _( - """ + logger.error(_(""" Options: -R dir --no-network-cache @@ -624,21 +616,13 @@ def print_cmds(cmd_list, cmd_dic): Environment: PKG_IMAGE - PKG_SUCCESS_ON_NOP""" - ) - ) + PKG_SUCCESS_ON_NOP""")) else: # Display the full list of subcommands. - logger.error( - _( - """\ -Usage: pkg [options] command [cmd_options] [operands]""" - ) - ) + logger.error(_("""\ +Usage: pkg [options] command [cmd_options] [operands]""")) logger.error(_("The following commands are supported:")) - logger.error( - _( - """ + logger.error(_(""" Package Information : list search info contents Package Transitions : update install uninstall history exact-install apply-hot-fix @@ -653,9 +637,7 @@ def print_cmds(cmd_list, cmd_dic): property set-property add-property-value unset-property remove-property-value Miscellaneous : image-create dehydrate rehydrate clean -For more info, run: pkg help """ - ) - ) +For more info, run: pkg help """)) sys.exit(retcode) @@ -997,31 +979,23 @@ def __display_plan(api_inst, verbose, noexecute, op=None): if api_inst.is_liveroot and not api_inst.is_active_liveroot_be: # Warn the user since this isn't likely what they wanted. if plan.new_be: - logger.warning( - _( - """\ + logger.warning(_("""\ ****************************************************************************** WARNING: The boot environment being modified is not the active one. Changes made in the active BE will not be reflected on the next boot. ****************************************************************************** -""" - ) - ) +""")) else: - logger.warning( - _( - """\ + logger.warning(_("""\ ****************************************************************************** WARNING: The boot environment being modified is not the active one. Changes made will not be reflected on the next boot. ****************************************************************************** -""" - ) - ) +""")) # a = change(!!!) (due to fix or mediator/variant/facet) # c = update @@ -2109,12 +2083,12 @@ def __api_plan_exception(op, noexecute, verbose, api_inst): return e.lix_exitrv if e_type == api_errors.IpkgOutOfDateException: msg( - _( - """\ + _("""\ WARNING: pkg(7) appears to be out of date, and should be updated before running {op}. Please update pkg(7) by executing 'pkg install -pkg:/package/pkg' as a privileged user and then retry the {op}.""" - ).format(**locals()) +pkg:/package/pkg' as a privileged user and then retry the {op}.""").format( + **locals() + ) ) return EXIT_OOPS if e_type == api_errors.NonLeafPackageException: @@ -2249,6 +2223,10 @@ def __api_plan( if _stage != API_STAGE_DEFAULT: kwargs["pubcheck"] = False + # display full solver rejection trees in error messages + if _verbose > 0: + DebugValues["plan-errors"] = "True" + # display plan debugging information if _verbose > 2: DebugValues["plan"] = "True" @@ -2904,16 +2882,12 @@ def _emit_error_general_cb( if selected_type and err["errtype"] not in selected_type: return False - emsg( - _( - """ + emsg(_(""" To add a publisher using this repository, execute the following command as a privileged user: pkg set-publisher -g {0} -""" - ).format(add_info["repo_uri"]) - ) +""").format(add_info["repo_uri"])) elif "info" in err: msg(err["info"]) elif "reason" in err: @@ -3894,6 +3868,8 @@ def set_mediator( cmd=op, ) + if verbose > 0: + DebugValues["plan-errors"] = "True" if verbose > 2: DebugValues["plan"] = "True" @@ -4004,6 +3980,8 @@ def unset_mediator( if not pargs: usage(_("at least one mediator must be specified"), cmd=op) + if verbose > 0: + DebugValues["plan-errors"] = "True" if verbose > 2: DebugValues["plan"] = "True" @@ -4968,15 +4946,9 @@ def list_contents(api_inst, args): if invalid_atype == action_types: usage(_("no valid action types specified"), cmd=subcommand) elif invalid_atype: - emsg( - _( - """\ + emsg(_("""\ WARNING: invalid action types specified: {0} -""".format( - ",".join(invalid_atype) - ) - ) - ) +""".format(",".join(invalid_atype)))) check_attrs(attrs, subcommand) @@ -5108,12 +5080,8 @@ def list_contents(api_inst, args): rval = EXIT_OK if attr_match and manifests and not found: rval = EXIT_OOPS - logger.error( - _( - """\ -pkg: contents: no matching actions found in the listed packages""" - ) - ) + logger.error(_("""\ +pkg: contents: no matching actions found in the listed packages""")) if manifests and rval == EXIT_OK: displayed_results = display_contents_results( @@ -5169,22 +5137,14 @@ def list_contents(api_inst, args): if manifests: logger.error("") if local: - logger.error( - _( - """\ + logger.error(_("""\ pkg: contents: no packages matching the following patterns you specified are -installed on the system. Try specifying -r to query remotely:""" - ) - ) +installed on the system. Try specifying -r to query remotely:""")) elif remote: - logger.error( - _( - """\ + logger.error(_("""\ pkg: contents: no packages matching the following patterns you specified were found in the catalog. Try relaxing the patterns, refreshing, and/or -examining the catalogs:""" - ) - ) +examining the catalogs:""")) logger.error("") for p in notfound: logger.error(" {0}".format(p)) @@ -6524,7 +6484,7 @@ def attach_linked( api_inst.progresstracker.set_major_phase( api_inst.progresstracker.PHASE_UTILITY ) - (rv, err, p_dict) = api_inst.attach_linked_child( + rv, err, p_dict = api_inst.attach_linked_child( lin, li_path, li_props, @@ -7914,13 +7874,9 @@ def handle_errors(func, non_wrap_print=True, *args, **kwargs): except api_errors.InvalidCatalogFile as __e: if _api_inst: _api_inst.abort(result=RESULT_FAILED_STORAGE) - logger.error( - _( - """ + logger.error(_(""" An error was encountered while attempting to read image state information -to perform the requested operation. Details follow:\n\n{0}""" - ).format(__e) - ) +to perform the requested operation. Details follow:\n\n{0}""").format(__e)) __ret = EXIT_OOPS except api_errors.InvalidDepotResponseException as __e: if _api_inst: diff --git a/src/depot-config.py b/src/depot-config.py index e0b3106ff..dea0000d4 100755 --- a/src/depot-config.py +++ b/src/depot-config.py @@ -96,16 +96,12 @@ file 1 manifest 0 status 0 -""".format( - pkg.VERSION -) +""".format(pkg.VERSION) # versions response used when we provide search capability DEPOT_VERSIONS_STR = """{0}admin 0 search 0 1 -""".format( - DEPOT_FRAGMENT_VERSIONS_STR -) +""".format(DEPOT_FRAGMENT_VERSIONS_STR) DEPOT_USER = "pkg5srv" DEPOT_GROUP = "pkg5srv" @@ -145,9 +141,7 @@ def usage(usage_error=None, cmd=None, retcode=EXIT_BADOPT): if usage_error: error(usage_error, cmd=cmd) - msg( - _( - """\ + msg(_("""\ Usage: pkg.depot-config ( -d repository_dir | -S ) -r runtime_dir [-c cache_dir] [-s cache_size] [-p port] [-h hostname] @@ -158,9 +152,7 @@ def usage(usage_error=None, cmd=None, retcode=EXIT_BADOPT): --cert-key-dir cert_key_directory ) [ (--ca-cert ca_cert_file --ca-key ca_key_file ) ] [--smf-fmri smf_pkg_depot_fmri] ] ) -""" - ) - ) +""")) sys.exit(retcode) diff --git a/src/depot.py b/src/depot.py index 6d04f8500..77fd1dd1f 100755 --- a/src/depot.py +++ b/src/depot.py @@ -144,8 +144,7 @@ def usage(text=None, retcode=EXIT_BADOPT, full=False): emsg(_("Try `pkg.depotd --help or -?' for more " "information.")) sys.exit(retcode) - print( - """\ + print("""\ Usage: /usr/lib/pkg.depotd [-a address] [-d inst_root] [-p port] [-s threads] [-t socket_timeout] [--cfg] [--content-root] [--disable-ops op[/1][,...]] [--debug feature_list] @@ -240,8 +239,7 @@ def usage(text=None, retcode=EXIT_BADOPT, full=False): Environment: PKG_REPO Used as default inst_root if -d not provided. PKG_DEPOT_CONTENT Used as default content_root if --content-root - not provided.""" - ) + not provided.""") sys.exit(retcode) diff --git a/src/modules/actions/driver.py b/src/modules/actions/driver.py index 2250b510e..0eea76a30 100644 --- a/src/modules/actions/driver.py +++ b/src/modules/actions/driver.py @@ -259,22 +259,17 @@ def install(self, pkgplan, orig): "imgroot": image.get_root(), } if name in driver_actions: - raise RuntimeError( - "\ + raise RuntimeError("\ The '{new}' driver shares the alias '{alias}' with the '{old}'\n\ driver; both drivers cannot be installed simultaneously. Please remove\n\ the package delivering '{old}' or ensure that the package delivering\n\ -'{new}' will not be installed, and try the operation again.".format( - **errdict - ) - ) +'{new}' will not be installed, and try the operation again.".format(**errdict)) else: comment = "# pkg(7): " lines[line] = comment + lines[line] # XXX Module printing if be_name: - print( - "\ + print("\ The '{new}' driver shares the alias '{alias}' with the '{old}'\n\ driver, but the system cannot determine how the latter was delivered.\n\ Its entry on line {line:d} in /etc/driver_aliases has been commented\n\ @@ -283,22 +278,15 @@ def install(self, pkgplan, orig): as well as removing line {line:d} from /etc/driver_aliases or, before\n\ rebooting, mounting the '{be}' boot environment and running\n\ 'rem_drv -b {old}' and removing line {line:d} from\n\ -/etc/driver_aliases.".format( - **errdict - ) - ) +/etc/driver_aliases.".format(**errdict)) else: - print( - "\ + print("\ The '{new}' driver shares the alias '{alias}' with the '{old}'\n\ driver, but the system cannot determine how the latter was delivered.\n\ Its entry on line {line:d} in /etc/driver_aliases has been commented\n\ out. If this driver is no longer needed, it may be removed by invoking\n\ 'rem_drv -b {imgroot} {old}' as well as removing line {line:d}\n\ -from {imgroot}/etc/driver_aliases.".format( - **errdict - ) - ) +from {imgroot}/etc/driver_aliases.".format(**errdict)) dap = image.get_root() + "/etc/driver_aliases" datd, datp = mkstemp( diff --git a/src/modules/altroot.py b/src/modules/altroot.py index 4152adfdb..2d221987b 100644 --- a/src/modules/altroot.py +++ b/src/modules/altroot.py @@ -53,7 +53,7 @@ def __path_abs_to_relative(path): path_new = None while True: - (path, tail) = os.path.split(path) + path, tail = os.path.split(path) if not tail: break if path_new: diff --git a/src/modules/api_common.py b/src/modules/api_common.py index 512141b55..cfe9fb15a 100644 --- a/src/modules/api_common.py +++ b/src/modules/api_common.py @@ -30,7 +30,6 @@ """Contains API functions and classes common to both pkg.client.api and pkg.server.api.""" - import pkg.client.pkgdefs as pkgdefs import pkg.fmri as fmri import pkg.misc as misc diff --git a/src/modules/client/api.py b/src/modules/client/api.py index 0c45bdf69..6b1e7262d 100644 --- a/src/modules/client/api.py +++ b/src/modules/client/api.py @@ -375,14 +375,12 @@ def __init__( and "PKG_NO_RUNPY_CMDPATH" in os.environ and self.cmdpath.endswith(os.sep + "run.py") ): - raise RuntimeError( - """ + raise RuntimeError(""" An ImageInterface object was allocated from within ipkg test suite and cmdpath was not explicitly overridden. Please make sure to set explicitly set cmdpath when allocating an ImageInterface object, or override cmdpath when allocating an Image object by setting PKG_CMDPATH -in the environment or by setting simulate_cmdpath in DebugValues.""" - ) +in the environment or by setting simulate_cmdpath in DebugValues.""") if isinstance(img_path, str): # Store this for reset(). diff --git a/src/modules/client/api_errors.py b/src/modules/client/api_errors.py index fec640356..c30173821 100644 --- a/src/modules/client/api_errors.py +++ b/src/modules/client/api_errors.py @@ -55,10 +55,8 @@ def verbose_info(self): class SuidUnsupportedError(ApiException): def __str__(self): - return _( - """ -The pkg client api module can not be invoked from an setuid executable.""" - ) + return _(""" +The pkg client api module can not be invoked from an setuid executable.""") class HistoryException(ApiException): @@ -277,17 +275,13 @@ def __init__(self, paths): def __str__(self): return "{0}\n\n {1}\n\n{2}".format( - _( - """\ + _("""\ The files listed below match exclusions which are configured -on this image and can therefore not be installed:""" - ), +on this image and can therefore not be installed:"""), "\n ".join(list(self.paths)), - _( - """\ + _("""\ See the 'exclude-patterns' and 'exclude-policy' image properties in pkg(1) for -more information.""" - ), +more information."""), ) @@ -468,12 +462,10 @@ def __str__(self): "command again as a privileged user." ).format(self.path) else: - return _( - """ + return _(""" Could not complete the operation because of insufficient permissions. Please try the command again as a privileged user. -""" - ) +""") class FileInUseException(PermissionsException): @@ -658,31 +650,25 @@ def __init__( def __str__(self): res = [] if self.unmatched_fmris: - s = _( - """\ + s = _("""\ The following pattern(s) did not match any allowable packages. Try using a different matching pattern, or refreshing publisher information: -""" - ) +""") res += [s] res += ["\t{0}".format(p) for p in self.unmatched_fmris] if self.rejected_pats: - s = _( - """\ + s = _("""\ The following pattern(s) only matched packages rejected by user request. Try using a different matching pattern, or refreshing publisher information: -""" - ) +""") res += [s] res += ["\t{0}".format(p) for p in self.rejected_pats] if self.wrong_variants: - s = _( - """\ + s = _("""\ The following pattern(s) only matched packages that are not available -for the current image's architecture, zone type, and/or other variant:""" - ) +for the current image's architecture, zone type, and/or other variant:""") res += [s] res += ["\t{0}".format(p) for p in self.wrong_variants] @@ -756,11 +742,9 @@ def __str__(self): res.extend(self.no_solution) if self.pkg_updates_required: - s = _( - """\ + s = _("""\ Syncing this linked image would require the following package updates: -""" - ) +""") res += [s] for oldfmri, newfmri in self.pkg_updates_required: res += [ @@ -773,14 +757,12 @@ def __str__(self): res += self.no_version if self.no_tmp_origins: - s = _( - """ + s = _(""" The proposed operation on this parent image can not be performed because temporary origins were specified and this image has children. Please either retry the operation again without specifying any temporary origins, or if packages from additional origins are required, please configure those origins -persistently.""" - ) +persistently.""") res = [s] if self.missing_dependency: @@ -842,27 +824,19 @@ def __format_li_pubs(pubs, res): if self.linked_pub_error: res = [] - (pubs, parent_pubs) = self.linked_pub_error + pubs, parent_pubs = self.linked_pub_error - res.append( - _( - """ + res.append(_(""" Invalid child image publisher configuration. Child image publisher configuration must be a superset of the parent image publisher configuration. Please update the child publisher configuration to match the parent. If the child image is a zone this can be done automatically by detaching and attaching the zone. -The parent image has the following enabled publishers:""" - ) - ) +The parent image has the following enabled publishers:""")) __format_li_pubs(parent_pubs, res) - res.append( - _( - """ -The child image has the following enabled publishers:""" - ) - ) + res.append(_(""" +The child image has the following enabled publishers:""")) __format_li_pubs(pubs, res) if self.no_repo_pubs: @@ -1977,11 +1951,9 @@ def __init__(self, be_name): self.be_name = be_name def __str__(self): - return _( - """\ + return _("""\ Boot environment naming during package install is not supported on this -version of OpenSolaris. Please update without the --be-name option.""" - ) +version of OpenSolaris. Please update without the --be-name option.""") class UnableToCopyBE(BEException): @@ -1997,11 +1969,9 @@ def __init__(self, orig, dest): def __str__(self): d = {"orig": self.original_name, "dest": self.destination_name} - return _( - """\ + return _("""\ A problem occurred while attempting to rename the boot environment -currently named {orig} to {dest}.""" - ).format(**d) +currently named {orig} to {dest}.""").format(**d) class UnableToMountBE(BEException): @@ -2022,11 +1992,9 @@ def __init__(self, be_name): self.name = be_name def __str__(self): - return _( - """\ + return _("""\ Naming a boot environment when operating on a non-live image is -not allowed.""" - ) +not allowed.""") class UnrecognizedOptionsToInfo(ApiException): @@ -2259,14 +2227,12 @@ def __init__(self, prefix): self.publisher = prefix def __str__(self): - return _( - """ + return _(""" The requested operation requires that one or more package repositories are configured for publisher '{0}'. Use 'pkg set-publisher' to add new package repositories or restore previously -configured package repositories for publisher '{0}'.""" - ).format(self.publisher) +configured package repositories for publisher '{0}'.""").format(self.publisher) class MoveRelativeToSelf(PublisherError): @@ -2523,15 +2489,13 @@ class UnknownSysrepoConfiguration(ApiException): repository but can't find the configuration for it.""" def __str__(self): - return _( - """\ + return _("""\ pkg is configured to use the system repository (via the use-system-repo property) but it could not get the host and port from svc:/application/pkg/zones-proxy-client nor svc:/application/pkg/system-repository, and the PKG_SYSREPO_URL environment variable was not set. Please try enabling one of those services or setting the PKG_SYSREPO_URL environment variable. -""" - ) +""") class ModifyingSyspubException(ApiException): @@ -3516,7 +3480,7 @@ def __init__( err = _("Unknown child linked image: {0}").format(child_unknown) if cmd_failed is not None: - (rv, cmd, errout) = cmd_failed + rv, cmd, errout = cmd_failed err = _( "The following subprocess returned an " "unexpected exit code of {rv:d}:\n {cmd}" @@ -3528,7 +3492,7 @@ def __init__( ) if cmd_output_invalid is not None: - (cmd, output) = cmd_output_invalid + cmd, output = cmd_output_invalid err = _( "The following subprocess:\n" " {cmd}\n" @@ -3614,26 +3578,23 @@ def __init__( if pkg_op_failed is not None: assert lin - (op, exitrv, errout, e) = pkg_op_failed + op, exitrv, errout, e = pkg_op_failed assert op is not None if e is None: - err = _( - """ + err = _(""" A '{op}' operation failed for child '{lin}' with an unexpected return value of {exitrv:d} and generated the following output: {errout} -""" - ).format( +""").format( lin=lin, op=op, exitrv=exitrv, errout=force_str(errout), ) else: - err = _( - """ + err = _(""" A '{op}' operation failed for child '{lin}' with an unexpected exception: {e} @@ -3641,8 +3602,7 @@ def __init__( The child generated the following output: {errout} -""" - ).format( +""").format( lin=lin, op=op, errout=force_str(errout), @@ -3662,9 +3622,8 @@ def __init__( ) if unparsable_output is not None: - (op, errout, e) = unparsable_output - err = _( - """ + op, errout, e = unparsable_output + err = _(""" A '{op}' operation for child '{lin}' generated non-json output. The json parser failed with the following error: {e} @@ -3672,8 +3631,7 @@ def __init__( The child generated the following output: {errout} -""" - ).format( +""").format( lin=lin, op=op, e=e, @@ -3726,12 +3684,10 @@ def __init__( def __str__(self): res = [] if self.multiversions: - s = _( - """\ + s = _("""\ The following packages were frozen at two different versions by the patterns provided. The package stem and the versions it was frozen at are -provided:""" - ) +provided:""") res += [s] res += [ "\t{0}\t{1}".format( @@ -3741,22 +3697,18 @@ def __str__(self): ] if self.unmatched_wildcards: - s = _( - """\ + s = _("""\ The following patterns contained wildcards but matched no -installed packages.""" - ) +installed packages.""") res += [s] res += [ "\t{0}".format(pat) for pat in sorted(self.unmatched_wildcards) ] if self.version_mismatch: - s = _( - """\ + s = _("""\ The following patterns attempted to freeze the listed packages -at a version different from the version at which the packages are installed.""" - ) +at a version different from the version at which the packages are installed.""") res += [s] for pat in sorted(self.version_mismatch): res += ["\t{0}".format(pat)] @@ -3767,12 +3719,10 @@ def __str__(self): ] if self.versionless_uninstalled: - s = _( - """\ + s = _("""\ The following patterns don't match installed packages and contain no version information. Uninstalled packages can only be frozen by -providing a version at which to freeze them.""" - ) +providing a version at which to freeze them.""") res += [s] res += [ "\t{0}".format(p) for p in sorted(self.versionless_uninstalled) diff --git a/src/modules/client/bootenv.py b/src/modules/client/bootenv.py index 0542bd9af..16a33d92e 100644 --- a/src/modules/client/bootenv.py +++ b/src/modules/client/bootenv.py @@ -565,31 +565,23 @@ def activate_live_be(): os.rmdir(self.clone_dir) if set_active: - logger.info( - _( - """ + logger.info(_(""" A clone of {be_name} exists and has been updated and activated. On the next boot the Boot Environment {be_name_clone} will be mounted on '/'. Reboot when ready to switch to this updated BE. *** Reboot required *** New BE: {be_name_clone} -""" - ).format(**self.__dict__) - ) +""").format(**self.__dict__)) else: - logger.info( - _( - """ + logger.info(_(""" A clone of {be_name} exists and has been updated. To set the new BE as the active one on next boot, execute the following command as a privileged user and reboot when ready to switch to the updated BE: beadm activate {be_name_clone} -""" - ).format(**self.__dict__) - ) +""").format(**self.__dict__)) def activate_be(): # Delete the snapshot that was taken before we diff --git a/src/modules/client/client_api.py b/src/modules/client/client_api.py index dd818db0f..99fabc590 100644 --- a/src/modules/client/client_api.py +++ b/src/modules/client/client_api.py @@ -1309,12 +1309,12 @@ def __api_plan_exception( return __prepare_json(e.lix_exitrv, errors=errors_json) if e_type == api_errors.IpkgOutOfDateException: error = { - "info": _( - """\ + "info": _("""\ WARNING: pkg(7) appears to be out of date, and should be updated before running {op}. Please update pkg(7) by executing 'pkg install -pkg:/package/pkg' as a privileged user and then retry the {op}.""" - ).format(**locals()) +pkg:/package/pkg' as a privileged user and then retry the {op}.""").format( + **locals() + ) } errors_json.append(error) return __prepare_json(EXIT_OOPS, errors=errors_json) @@ -1445,6 +1445,10 @@ def __api_plan( if _stage != API_STAGE_DEFAULT: kwargs["pubcheck"] = False + # display full solver rejection trees in error messages + if _verbose > 0: + DebugValues["plan-errors"] = "True" + # display plan debugging information if _verbose > 2: DebugValues["plan"] = "True" @@ -2203,13 +2207,11 @@ def get_pubs(): # specified publisher prefix. if "data" not in ret_json: _error_json( - _( - """ + _(""" The specified repository did not contain any publisher configuration information. This is likely the result of a repository configuration error. Please contact the repository administrator for further -assistance.""" - ), +assistance."""), errors_json=errors_json, ) return __prepare_json(EXIT_OOPS, errors=errors_json) @@ -3059,18 +3061,14 @@ def __append_attr_lists(label, values): err = EXIT_OOPS if not quiet: if info_local: - err_txt += _( - """\ + err_txt += _("""\ pkg: info: no packages matching the following patterns you specified are -installed on the system. Try querying remotely instead:\n""" - ) +installed on the system. Try querying remotely instead:\n""") elif info_remote: - err_txt += _( - """\ + err_txt += _("""\ pkg: info: no packages matching the following patterns you specified were found in the catalog. Try relaxing the patterns, refreshing, and/or -examining the catalogs:\n""" - ) +examining the catalogs:\n""") err_txt += "\n" for p in notfound: err_txt += " {0}".format(p) diff --git a/src/modules/client/image.py b/src/modules/client/image.py index 27c093575..8f5d33625 100644 --- a/src/modules/client/image.py +++ b/src/modules/client/image.py @@ -158,14 +158,12 @@ def __init__( and "PKG_NO_RUNPY_CMDPATH" in os.environ and self.cmdpath.endswith(os.sep + "run.py") ): - raise RuntimeError( - """ + raise RuntimeError(""" An Image object was allocated from within ipkg test suite and cmdpath was not explicitly overridden. Please make sure to explicitly set cmdpath when allocating an Image object, or override cmdpath when allocating an Image object by setting PKG_CMDPATH -in the environment or by setting simulate_cmdpath in DebugValues.""" - ) +in the environment or by setting simulate_cmdpath in DebugValues.""") self.linked = None diff --git a/src/modules/client/imageplan.py b/src/modules/client/imageplan.py index a458d23e5..3238a02e9 100644 --- a/src/modules/client/imageplan.py +++ b/src/modules/client/imageplan.py @@ -4729,12 +4729,10 @@ def __make_excl_msg(self, elided: list[str]) -> str: actions.""" return ( - _( - """\ + _("""\ ***************************************************************************** WARNING: The following actions have not been installed as this is a partial -image (there are configured exclusions):""" - ) +image (there are configured exclusions):""") + "\n\n " + "\n ".join(elided) + """ diff --git a/src/modules/client/linkedimage/common.py b/src/modules/client/linkedimage/common.py index 5c30b3784..ce5f1ef1e 100644 --- a/src/modules/client/linkedimage/common.py +++ b/src/modules/client/linkedimage/common.py @@ -51,7 +51,6 @@ from functools import reduce - # pkg classes import pkg.actions import pkg.altroot as ar @@ -1701,7 +1700,7 @@ def __validate_child_attach(self, lin, path, props, allow_relink=False): # Does the parent image (ourselves) reside in clonable BE? # Unused variable 'be_uuid'; pylint: disable=W0612 - (be_name, be_uuid) = bootenv.BootEnv.get_be_name(self.__root) + be_name, be_uuid = bootenv.BootEnv.get_be_name(self.__root) # pylint: enable=W0612 img_is_clonable = bool(be_name) @@ -3501,7 +3500,7 @@ def child_op_rv(self, expect_plan): # make sure we're not going to block assert self.__pkg_remote.is_done() - (rv, e, stdout, stderr) = self.__pkg_remote.result() + rv, e, stdout, stderr = self.__pkg_remote.result() if e is not None: rv = pkgdefs.EXIT_OOPS diff --git a/src/modules/client/linkedimage/zone.py b/src/modules/client/linkedimage/zone.py index 4374674e0..2fa7df185 100644 --- a/src/modules/client/linkedimage/zone.py +++ b/src/modules/client/linkedimage/zone.py @@ -37,7 +37,6 @@ import tempfile import subprocess - # pkg classes import pkg.client.api_errors as apx import pkg.client.pkgdefs as pkgdefs diff --git a/src/modules/client/pkg_solver.py b/src/modules/client/pkg_solver.py index f0432bc52..caa7ddd99 100644 --- a/src/modules/client/pkg_solver.py +++ b/src/modules/client/pkg_solver.py @@ -31,7 +31,7 @@ import operator import time -from collections import defaultdict +from collections import defaultdict, deque from functools import reduce from itertools import chain @@ -85,7 +85,8 @@ _TRIM_VARIANT = 21 # unsupported variant (e.g. i386 on sparc) _TRIM_EXPLICIT_INSTALL = 22 # pkg.depend.explicit-install is true. _TRIM_SYNCED_INC = 23 # incorporation must be in sync with parent -_TRIM_MAX = 24 # number of trim constants +_TRIM_PROPOSED_DEP = 24 # rejected by a proposed package's dependency +_TRIM_MAX = 25 # number of trim constants class DependencyException(Exception): @@ -374,6 +375,236 @@ def __raise_solution_error(self, no_version=EmptyI, no_solution=EmptyI): solver_errors=solver_errors, ) + def __verbose_errors(self): + """Whether error output should include the full rejection tree + for each package rather than the default root cause summary.""" + + # Value 'DebugValues' is unsubscriptable; + # pylint: disable=E1136 + return bool(DebugValues["plan"] or DebugValues["plan-errors"]) + + def __verbose_hint(self): + """Common hint appended to summarised error output.""" + + return _( + "Re-run the operation with the -v option to see all of the " + "rejected\npackages and detailed reasons." + ) + + @staticmethod + def __name_list(names, limit=8): + """Return a bounded, indented list of package names for use in + summarised error output.""" + + names = sorted(names) + if len(names) > limit: + shown = names[:limit] + shown.append(_("... and {0:d} others").format(len(names) - limit)) + else: + shown = names + return ["\t{0}".format(n) for n in shown] + + def __summary_fmri(self, fmri): + """Format an FMRI for the summarised error output, including the + timestamp only if some dependency elsewhere in the output has + one. The build is always excluded, for brevity.""" + + if self.__depend_ts: + return fmri.get_fmri(include_build=False) + return fmri.get_short_fmri() + + def __rejection_summary(self, fmri_list): + """Walk the trim database starting from the given FMRIs, + mirroring the walk used to render the full rejection tree, and + distil the many reasons for rejection down to the root causes: + those which are not themselves just the consequence of another + package having been rejected. + + Returns a tuple of a list of strings describing the root + causes and the number of rejected package versions considered, + or (None, 0) if no root causes could be identified, in which + case the caller should fall back to the full rejection tree.""" + + # These reasons reflect the requested operation or the + # installed image state rather than a cause of failure; the + # rejection tree omits them by default too. + uninteresting = frozenset( + [ + _TRIM_INSTALLED_NEWER, + _TRIM_PROPOSED_PUB, + _TRIM_PROPOSED_VER, + ] + ) + + def trims(f): + """The trim records for a package version, in a stable + order.""" + + return sorted(self.__trim_dict.get(f, EmptyI)) + + outright = {} + + def rejected_outright(f): + """Whether this version was rejected in its own right + rather than because something that it depends on was + rejected, and for a reason which is worth reporting.""" + + if f not in outright: + reportable = False + for reason_id, reason_t, fmris in trims(f): + if reason_id == _TRIM_DEP_TRIMMED: + reportable = False + break + if reason_id not in uninteresting: + reportable = True + outright[f] = reportable + return outright[f] + + # Walk the tree of rejections breadth first, recording the + # order in which package versions are reached. + started = frozenset(fmri_list) + seen = set() + order = [] + # Sorted, like the versions added below, so that the output + # does not depend on set iteration order. + pending = deque(sorted(started)) + nrejected = 0 + + while pending: + f = pending.popleft() + if f in seen: + continue + seen.add(f) + order.append(f) + self.__progress() + + reasons = trims(f) + if reasons: + nrejected += 1 + for reason_id, reason_t, fmris in reasons: + if reason_id in uninteresting: + continue + + if reason_id == _TRIM_DEP_TRIMMED and len(reason_t[1]) == 2: + # Don't descend through dependencies on + # incorporations that don't specify a version; any + # version-specific dependencies lead to the same + # roots. + dtype, fstr = reason_t[1] + if ( + dtype == "require" + and "@" not in fstr + and fstr in self.__known_incs + ): + continue + + pending.extend(sorted(fmris)) + + # A version rejected because one of its own dependencies could + # not be satisfied is a consequence, not a cause. The cascade + # ends at the dependencies for which every candidate version was + # rejected in its own right. Only those versions, and the ones + # the caller started from, can be root causes. The rest is + # collateral damage. + required_by = {} + for f in order: + for reason_id, reason_t, fmris in trims(f): + if reason_id != _TRIM_DEP_TRIMMED or not fmris: + continue + if not all(rejected_outright(c) for c in fmris): + continue + for c in sorted(fmris): + required_by.setdefault(c, (f, reason_t[1])) + + def collect(eligible): + """Group the reportable reasons of the eligible versions by + reason text, returning the carriers in discovery order.""" + + # (package name, reason text) -> extra carrier count. + # Grouping on the reason alone would hide the version that + # matters behind an unrelated package's count. + roots = {} + # First carrier fmri -> reason texts, in discovery order + carriers = {} + found = [] + + for f in order: + if not eligible(f): + continue + for reason_id, reason_t, fmris in trims(f): + if ( + reason_id in uninteresting + or reason_id == _TRIM_DEP_TRIMMED + ): + continue + + if isinstance(reason_t, tuple): + reason = _(reason_t[0]).format(*reason_t[1]) + else: + reason = _(reason_t) + + key = (f.pkg_name, reason) + if key in roots: + roots[key] += 1 + continue + + roots[key] = 0 + if f not in carriers: + carriers[f] = [] + found.append(f) + carriers[f].append(reason) + + return roots, carriers, found + + roots, carriers, found = collect( + lambda f: f in started or f in required_by + ) + if not found: + # Every dependency had a candidate whose own rejection + # needs explaining, as when the rejections form a cycle. + # Fall back to reporting each cause wherever it appears. + roots, carriers, found = collect(lambda f: True) + if not found: + return (None, 0) + + ms = [_("This is due to the following root cause(s):"), ""] + for f in found: + ms.append(_(" Package: {0}").format(self.__summary_fmri(f))) + for reason in carriers[f]: + ms.append(_(" Reason: {0}").format(reason)) + extra = roots[f.pkg_name, reason] + if extra: + ms.append( + _( + " (and {0:d} other rejected " + "package versions with the same reason)" + ).format(extra) + ) + dep = required_by.get(f) + if dep is not None: + ms.append( + _(" Blocks: {0}").format(self.__summary_fmri(dep[0])) + ) + if len(dep[1]) == 2: + ms.append( + _(" ('{0}' dependency on {1})").format( + *dep[1] + ) + ) + ms.append("") + if nrejected == 1: + ms.append( + _("The above led to the rejection of one package version.") + ) + else: + ms.append( + _( + "The above led to the rejection of {0:d} package " + "versions in total." + ).format(nrejected) + ) + return (ms, nrejected) + def __trim_proposed(self, proposed_dict): """Remove any versions from proposed_dict that are in trim_dict and raise an exception if no matching version of a proposed @@ -383,16 +614,49 @@ def __trim_proposed(self, proposed_dict): # Nothing to do. return - # Used to de-dup errors. - already_seen = set() - - ret = [] + # Trim proposed packages and collect those for which no + # matching version can now be installed. + failed = [] for name in proposed_dict: tv = self.__dotrim(proposed_dict[name]) if tv: proposed_dict[name] = tv continue + # continue processing and accumulate all errors + failed.append(name) + if not failed: + return + + if not self.__verbose_errors(): + summary, nrejected = self.__rejection_summary( + [f for name in failed for f in proposed_dict[name]] + ) + if summary is not None: + if len(failed) == 1: + ret = [ + _( + "No matching version of {0} can be installed." + ).format(failed[0]) + ] + else: + ret = [ + _( + "No matching version of the following\n" + "{0:d} proposed packages can be installed:" + ).format(len(failed)) + ] + ret.extend(self.__name_list(failed)) + ret.append("") + ret.extend(summary) + ret.append(self.__verbose_hint()) + self.__raise_solution_error(no_version=ret) + + # Used to de-dup errors. + already_seen = set() + + ret = [] + for name in failed: ret.extend( [_("No matching version of {0} can be installed:").format(name)] ) @@ -401,9 +665,7 @@ def __trim_proposed(self, proposed_dict): proposed_dict[name], already_seen=already_seen ) ) - # continue processing and accumulate all errors - if ret: - self.__raise_solution_error(no_version=ret) + self.__raise_solution_error(no_version=ret) def __set_removed_and_required_packages(self, rejected, proposed=None): """Sets the list of package to be removed from the image, the @@ -737,6 +999,7 @@ def __assert_installed_allowed(self, excludes, proposed=None): if ret: self.__raise_solution_error(no_version=ret) + flists = [] for fmri in uninstall_fmris: flist = [fmri] if fmri in self.__linked_pkgs: @@ -755,7 +1018,31 @@ def __assert_installed_allowed(self, excludes, proposed=None): # error messaging for clarity if # different flist.append(pf) + flists.append((fmri, flist)) + + if flists and not self.__verbose_errors(): + summary, nrejected = self.__rejection_summary( + [f for ufmri, flist in flists for f in flist] + ) + if summary is not None: + ret.append( + _( + "The following installed packages must be " + "uninstalled or upgraded\nif the requested " + "operation is to be performed:" + ) + ) + ret.extend( + self.__name_list( + [ufmri.pkg_name for ufmri, flist in flists] + ) + ) + ret.append("") + ret.extend(summary) + ret.append(self.__verbose_hint()) + self.__raise_solution_error(no_version=ret) + for fmri, flist in flists: res = self.__fmri_list_errors(flist, already_seen=already_seen) # If no errors returned, that implies that all of the @@ -877,7 +1164,11 @@ def __raise_install_error( for s in ms: info.append(" {0}".format(s)) - if not info: # both error detection methods insufficent. + if info and not self.__verbose_errors(): + info.append("") + info.append(self.__verbose_hint()) + + if not info: # both error detection methods insufficient. info.append( _( "Plan Creation: Package solver is " @@ -889,7 +1180,7 @@ def __raise_install_error( ) info.append( _( - "Try running with -vv to " + "Try running with -vvv to " "obtain more detailed error messages." ) ) @@ -1518,14 +1809,17 @@ def solve_update_all( info.append(" ") for s in ms: info.append(" {0}".format(s)) + if not self.__verbose_errors(): + info.append(" ") + info.append(self.__verbose_hint()) else: info.append( _("Dependency analysis is unable to determine the cause.") ) info.append( _( - "Try running with -vv to " - "obtain more detailed error messages." + "Try running with -vv, which evaluates packages " + "individually\nand can identify the specific cause." ) ) @@ -2646,7 +2940,7 @@ def __parse_dependency( )[0] self.__trim( nm, - _TRIM_DEP_TRIMMED, + _TRIM_PROPOSED_DEP, ( N_( "Rejected by '{0}' dependency in proposed " @@ -2728,6 +3022,14 @@ def __generate_dependency_errors(self, fmri_list, excludes=EmptyI): ret.extend(errors) already_processed.add(fmri) needs_processing |= newfmris - already_processed + + if ret and not self.__verbose_errors(): + # The walk above also populates the trim database for + # packages whose dependencies could not be satisfied, so + # this must happen afterwards. + summary = self.__rejection_summary(fmri_list)[0] + if summary is not None: + return summary return ret def get_trim_errors(self): @@ -2749,10 +3051,8 @@ def __check_installed(self): """Generate list of strings describing why currently installed packages cannot be installed, or empty list""" - # Used to de-dup errors. - already_seen = set() - ret = [] + failed = [] for f in self.__installed_fmris - self.__removal_fmris: matching = self.__comb_newer_fmris( f, dotrim=True, obsolete_ok=True @@ -2763,10 +3063,36 @@ def __check_installed(self): matching = self.__comb_newer_fmris( f, dotrim=False, obsolete_ok=True )[0] + failed.append((f, matching)) + + if not failed: + return ret + + if not self.__verbose_errors(): + summary = self.__rejection_summary( + [m for pf, matching in failed for m in matching] + )[0] + if summary is not None: + ret.append( + _( + "No suitable version of the following " + "installed packages could be found:" + ) + ) + ret.extend( + self.__name_list([pf.pkg_name for pf, matching in failed]) + ) + ret.append("") + ret.extend(summary) + return ret + + # Used to de-dup errors. + already_seen = set() + for pf, matching in failed: ret.append( _("No suitable version of installed package {0} found").format( - f.pkg_name + pf.pkg_name ) ) ret.extend( diff --git a/src/modules/client/pkgremote.py b/src/modules/client/pkgremote.py index fd53c9321..30188e3bc 100644 --- a/src/modules/client/pkgremote.py +++ b/src/modules/client/pkgremote.py @@ -37,7 +37,6 @@ import tempfile import traceback - # pkg classes import pkg.client.api_errors as apx import pkg.client.pkgdefs as pkgdefs diff --git a/src/modules/client/plandesc.py b/src/modules/client/plandesc.py index bc9f7aa1e..863def3c6 100644 --- a/src/modules/client/plandesc.py +++ b/src/modules/client/plandesc.py @@ -485,8 +485,8 @@ def get_mediators(self): ret = [] for m, ver, impl in sorted(self.mediators): - ((orig_ver, orig_ver_source), (new_ver, new_ver_source)) = ver - ((orig_impl, orig_impl_source), (new_impl, new_impl_source)) = impl + (orig_ver, orig_ver_source), (new_ver, new_ver_source) = ver + (orig_impl, orig_impl_source), (new_impl, new_impl_source) = impl out = "mediator {0}:\n".format(m) if orig_ver and new_ver: out += ( diff --git a/src/modules/client/progress.py b/src/modules/client/progress.py index 7fd543691..3da85dbb7 100644 --- a/src/modules/client/progress.py +++ b/src/modules/client/progress.py @@ -173,7 +173,7 @@ def newdata(self, nbytes, timestamp=None): # Step 2: Expunge old data # while len(self.__deque) > 0: - (ts, val) = self.__deque[0] + ts, val = self.__deque[0] if ts < curtime - self.INTERVAL: self.__intervalbytes -= val self.__deque.popleft() diff --git a/src/modules/client/publisher.py b/src/modules/client/publisher.py index 9f9ab8996..73933fc0f 100644 --- a/src/modules/client/publisher.py +++ b/src/modules/client/publisher.py @@ -1769,8 +1769,7 @@ def __validate_metadata(self, croot, repo): origins = repo.origins origin = origins[0] logger.error( - _( - """ + _(""" Unable to retrieve package data for publisher '{prefix}' from one of the following origin(s): @@ -1778,8 +1777,7 @@ def __validate_metadata(self, croot, repo): The catalog retrieved from one of the origin(s) listed above only contains package data for: {pubs}. -""" - ).format( +""").format( origins="\n".join(str(o) for o in origins), prefix=self.prefix, pubs=", ".join(pubs), @@ -1787,54 +1785,36 @@ def __validate_metadata(self, croot, repo): ) if global_settings.client_name != "pkg": - logger.error( - _( - """\ + logger.error(_("""\ This is either a result of invalid origin information being provided for publisher '{0}', or because the wrong publisher name was provided when this publisher was added. -""" - ).format(self.prefix) - ) +""").format(self.prefix)) # Remaining messages are for pkg client only. return - logger.error( - _( - """\ + logger.error(_("""\ To resolve this issue, correct the origin information provided for publisher '{prefix}' using the pkg set-publisher subcommand, or re-add the publisher using the correct name and remove the '{prefix}' publisher. -""" - ).format(prefix=self.prefix) - ) +""").format(prefix=self.prefix)) if len(pubs) == 1: - logger.warning( - _( - """\ + logger.warning(_("""\ To re-add this publisher with the correct name, execute the following commands as a privileged user: pkg set-publisher -P -g {origin} {pub} pkg unset-publisher {prefix} -""" - ).format( - origin=origin, prefix=self.prefix, pub=list(pubs)[0] - ) - ) +""").format(origin=origin, prefix=self.prefix, pub=list(pubs)[0])) return - logger.warning( - _( - """\ + logger.warning(_("""\ The origin(s) listed above contain package data for more than one publisher, but this issue can likely be resolved by executing one of the following commands as a privileged user: -""" - ) - ) +""")) for pfx in pubs: logger.warning( @@ -1843,16 +1823,12 @@ def __validate_metadata(self, croot, repo): ) ) - logger.warning( - _( - """\ + logger.warning(_("""\ Afterwards, the old publisher should be removed by executing the following command as a privileged user: pkg unset-publisher {0} -""" - ).format(self.prefix) - ) +""").format(self.prefix)) @property def catalog(self): diff --git a/src/modules/client/transport/repo.py b/src/modules/client/transport/repo.py index 94a2f61e1..987c9e720 100644 --- a/src/modules/client/transport/repo.py +++ b/src/modules/client/transport/repo.py @@ -353,36 +353,28 @@ def _analyze_server_error(error_header): SERVER_ERROR = "SVR" MAINTENANCE = "MNT" - entitlement_err_msg = N_( - """ + entitlement_err_msg = N_(""" This account is not entitled to access this repository. Ensure that the correct certificate is being used and that the support contract for the product being accessed is still valid. -""" - ) +""") - license_err_msg = N_( - """ + license_err_msg = N_(""" The license agreement required to access this repository has not been accepted yet or the license agreement for the product has changed. Please go to https://pkg-register.oracle.com and accept the license for the product you are trying to access. -""" - ) +""") - server_err_msg = N_( - """ + server_err_msg = N_(""" Repository access is currently unavailable due to service issues. Please retry later or contact your customer service representative. -""" - ) +""") - maintenance_msg = N_( - """ + maintenance_msg = N_(""" Repository access rights can currently not be verified due to server maintenance. Please retry later. -""" - ) +""") msg = "" # multiple errors possible (e.g. license and entitlement not ok) diff --git a/src/modules/file_layout/layout.py b/src/modules/file_layout/layout.py index 9cd5c6ffa..d0ca18d73 100644 --- a/src/modules/file_layout/layout.py +++ b/src/modules/file_layout/layout.py @@ -57,7 +57,6 @@ a server can open a file to serve it. File sizes from 1 to 10M were used to asses the scalability of the different layouts.""" - import os diff --git a/src/modules/indexer.py b/src/modules/indexer.py index 9f26815b0..2ad7262f1 100644 --- a/src/modules/indexer.py +++ b/src/modules/indexer.py @@ -622,7 +622,7 @@ def _update_index(self, dicts, out_dir): try: for line in file_handle: - (tok, at_lst) = self._data_main_dict.parse_main_dict_line(line) + tok, at_lst = self._data_main_dict.parse_main_dict_line(line) existing_entries = [] for at, st_list in at_lst: st_res = [] diff --git a/src/modules/lint/config.py b/src/modules/lint/config.py index d9e9b6321..7467c4e96 100644 --- a/src/modules/lint/config.py +++ b/src/modules/lint/config.py @@ -31,7 +31,6 @@ import configparser from collections import OrderedDict - defaults = { "log_level": "INFO", "do_pub_checks": "True", diff --git a/src/modules/lint/engine.py b/src/modules/lint/engine.py index 752a45422..8eada79e5 100644 --- a/src/modules/lint/engine.py +++ b/src/modules/lint/engine.py @@ -381,7 +381,7 @@ def _load_checker_module(self, name, config): # the fifth parameter is 'level', which defautls to -1 # in Python 2 and 0 in Python 3. __import__(name, None, None, []) - (checkers, excluded) = base.get_checkers(sys.modules[name], config) + checkers, excluded = base.get_checkers(sys.modules[name], config) return (checkers, excluded) except (KeyError, ImportError) as err: raise base.LintException(err) @@ -459,12 +459,12 @@ def load_config(self, config, verbose=False): if "pkglint.ext" in key: if value in excl: # want to exclude everything from here - (checkers, exclude) = self._load_checker_module(value, conf) + checkers, exclude = self._load_checker_module(value, conf) self.excluded_checkers.extend(checkers) self.excluded_checkers.extend(exclude) continue try: - (checkers, exclude) = self._load_checker_module(value, conf) + checkers, exclude = self._load_checker_module(value, conf) self.checkers.extend(checkers) self.excluded_checkers.extend(exclude) diff --git a/src/modules/misc.py b/src/modules/misc.py index d1c89435e..1b8e54f01 100644 --- a/src/modules/misc.py +++ b/src/modules/misc.py @@ -127,12 +127,10 @@ def get_traceback_message(): is necessary since the _() call must be done at runtime after locale setup.""" - return _( - """\n + return _("""\n This is an internal error in pkg(7) version {version}. Please log a Service Request about this issue including the information above and this -message.""" - ).format(version=VERSION) +message.""").format(version=VERSION) def get_release_notes_url(): @@ -3256,7 +3254,7 @@ def set_fd_limits(printer=None): printer = emsg try: - (soft, hard) = resource.getrlimit(resource.RLIMIT_NOFILE) + soft, hard = resource.getrlimit(resource.RLIMIT_NOFILE) soft = max(hard, FILE_DESCRIPTOR_LIMIT) resource.setrlimit(resource.RLIMIT_NOFILE, (soft, hard)) except (OSError, ValueError) as e: diff --git a/src/modules/publish/dependencies.py b/src/modules/publish/dependencies.py index 07867ab86..decf2caa1 100644 --- a/src/modules/publish/dependencies.py +++ b/src/modules/publish/dependencies.py @@ -218,15 +218,13 @@ def __init__(self, conditionals, pkg_vars): self.pkg_vct = pkg_vars def __str__(self): - s = _( - """\ + s = _("""\ pkgdepend has inferred conditional dependencies with different targets but which share a predicate. pkg(7) can not represent these dependencies. This issue can be resolved by changing the packaging of the links which generated the conditional dependencies so that they have different predicates or share the same FMRI. Each pair of problematic conditional dependencies follows: -""" - ) +""") for i, (d1, d2, v) in enumerate(self.conditionals): i += 1 v.simplify(self.pkg_vct) diff --git a/src/modules/server/feed.py b/src/modules/server/feed.py index d6566ca5b..25494d03a 100644 --- a/src/modules/server/feed.py +++ b/src/modules/server/feed.py @@ -45,7 +45,6 @@ import pkg.catalog as catalog import pkg.misc as misc - MIME_TYPE = "application/atom+xml" CACHE_FILENAME = "feed.xml" RFC3339_FMT = "%Y-%m-%dT%H:%M:%SZ" diff --git a/src/modules/sysvpkg.py b/src/modules/sysvpkg.py index fa164ecd3..cd4a827cb 100644 --- a/src/modules/sysvpkg.py +++ b/src/modules/sysvpkg.py @@ -69,7 +69,7 @@ def __init__(self, line, basedir=""): self.klass = None if self.type == "i": - (self.pathname, self.size, self.chksum, self.modtime) = array[2:] + self.pathname, self.size, self.chksum, self.modtime = array[2:] return self.klass = array[2] @@ -96,10 +96,10 @@ def __init__(self, line, basedir=""): ) = array[3:] elif self.type == "d" or self.type == "x" or self.type == "p": - (self.pathname, self.mode, self.owner, self.group) = array[3:] + self.pathname, self.mode, self.owner, self.group = array[3:] elif self.type == "l" or self.type == "s": - (self.pathname, self.target) = array[3].split("=") + self.pathname, self.target = array[3].split("=") self.target = self.target.replace("$BASEDIR", basedir) else: raise ValueError("Invalid file type: " + self.type) @@ -212,7 +212,7 @@ def readDependFile(self): fp = open(self.pkgpath + "/install/depend") except IOError as xxx_todo_changeme: # Missing depend file is just fine - (err, msg) = xxx_todo_changeme.args + err, msg = xxx_todo_changeme.args # Missing depend file is just fine if err == errno.ENOENT: return [] @@ -255,7 +255,7 @@ def readPkginfoFile(self): pkginfo["faspac"] = line.lstrip("#FASPACD=").split() continue - (key, val) = line.split("=", 1) + key, val = line.split("=", 1) pkginfo[key] = val.strip('"') # Expose the platform-specific package name, too. diff --git a/src/pkgdep.py b/src/pkgdep.py index efac98d93..a4712f344 100755 --- a/src/pkgdep.py +++ b/src/pkgdep.py @@ -98,9 +98,7 @@ def usage(usage_error=None, cmd=None, retcode=EXIT_BADOPT): if usage_error: error(usage_error, cmd=cmd) - emsg( - _( - """\ + emsg(_("""\ Usage: pkgdepend [options] command [cmd_options] [operands] @@ -114,9 +112,7 @@ def usage(usage_error=None, cmd=None, retcode=EXIT_BADOPT): -R dir --help or -? Environment: - PKG_IMAGE""" - ) - ) + PKG_IMAGE""")) sys.exit(retcode) diff --git a/src/pkgrepo.py b/src/pkgrepo.py index 714acc68a..af4d2753b 100755 --- a/src/pkgrepo.py +++ b/src/pkgrepo.py @@ -152,9 +152,7 @@ def usage(usage_error=None, cmd=None, retcode=EXIT_BADOPT, full=False): logger.error(_("Try `pkgrepo --help or -?' for more information.")) sys.exit(retcode) - msg( - _( - """\ + msg(_("""\ Usage: pkgrepo [options] command [cmd_options] [operands] @@ -205,9 +203,7 @@ def usage(usage_error=None, cmd=None, retcode=EXIT_BADOPT, full=False): Options: --help or -? - Displays a usage message.""" - ) - ) + Displays a usage message.""")) sys.exit(retcode) @@ -1375,13 +1371,9 @@ def subcmd_contents(conf, args): if unmatched: if manifests: logger.error("") - logger.error( - _( - """\ + logger.error(_("""\ pkgrepo: contents: no packages matching the following patterns you specified -were found in the repository.""" - ) - ) +were found in the repository.""")) logger.error("") for p in unmatched: logger.error(" {0}".format(p)) @@ -2493,14 +2485,10 @@ def __diff_pub_helper(pub, symbol): # Here "number of packages" and "total distinct # versions" are shown outside and inside of square # brackets respectively. - msg( - _( - """ + msg(_(""" The table below shows the number of packages [total distinct versions] by publisher in the specified repositories. -""" - ) - ) +""")) for leg in res_dict["table_legend"]: msg("* " + leg[0] + ": " + leg[1]) msg("") diff --git a/src/publish.py b/src/publish.py index 3b5c6f6d2..c2cbc4a74 100755 --- a/src/publish.py +++ b/src/publish.py @@ -105,9 +105,7 @@ def usage(usage_error=None, cmd=None, retcode=EXIT_BADOPT): if usage_error: error(usage_error, cmd=cmd) - print( - _( - """\ + print(_("""\ Usage: pkgsend [options] command [cmd_options] [operands] @@ -121,9 +119,7 @@ def usage(usage_error=None, cmd=None, retcode=EXIT_BADOPT): --help or -? display usage message Environment: - PKG_REPO The path or URI of the destination repository.""" - ) - ) + PKG_REPO The path or URI of the destination repository.""")) sys.exit(retcode) diff --git a/src/pull.py b/src/pull.py index 3b0d5079b..c5de32114 100755 --- a/src/pull.py +++ b/src/pull.py @@ -105,9 +105,7 @@ def usage(usage_error=None, retcode=pkgdefs.EXIT_BADOPT): if usage_error: error(usage_error) - msg( - _( - """\ + msg(_("""\ Usage: pkgrecv [-aknrv] [-s src_uri] [-d (path|dest_uri)] [-c cache_dir] [-m match] [--mog-file file_path ...] [--raw] @@ -202,9 +200,7 @@ def usage(usage_error=None, retcode=pkgdefs.EXIT_BADOPT): Environment: PKG_DEST Destination directory or URI - PKG_SRC Source URI or path""" - ) - ) + PKG_SRC Source URI or path""")) sys.exit(retcode) diff --git a/src/sign.py b/src/sign.py index 374776326..718f4921f 100755 --- a/src/sign.py +++ b/src/sign.py @@ -97,16 +97,12 @@ def usage(usage_error=None, cmd=None, retcode=EXIT_BADOPT): if usage_error: error(usage_error, cmd=cmd) - emsg( - _( - """\ + emsg(_("""\ Usage: pkgsign -s path_or_uri [-acikn] [--no-index] [--no-catalog] [--dkey dest_key --dcert dest_cert] (fmri|pattern) ... -""" - ) - ) +""")) sys.exit(retcode) diff --git a/src/sysrepo.py b/src/sysrepo.py index 53ce608b3..839ba29f9 100755 --- a/src/sysrepo.py +++ b/src/sysrepo.py @@ -122,9 +122,7 @@ file 1 syspub 0 manifest 0 -""".format( - pkg.VERSION -) +""".format(pkg.VERSION) SYSREPO_USER = "pkg5srv" SYSREPO_GROUP = "pkg5srv" @@ -171,16 +169,12 @@ def usage(usage_error=None, cmd=None, retcode=EXIT_BADOPT): if usage_error: error(usage_error, cmd=cmd) - msg( - _( - """\ + msg(_("""\ Usage: pkg.sysrepo -p [-R image_root] [ -c cache_dir] [-h hostname] [-l logs_dir] [-r runtime_dir] [-s cache_size] [-t template_dir] [-T http_timeout] [-w http_proxy] [-W https_proxy] - """ - ) - ) + """)) sys.exit(retcode) diff --git a/src/tests/api/t_action.py b/src/tests/api/t_action.py index abd819a64..2303b79e3 100644 --- a/src/tests/api/t_action.py +++ b/src/tests/api/t_action.py @@ -95,25 +95,17 @@ def assertAttributeValue(self, action, attr, value): value.sort() if attrs != value: - self.fail( - """\ + self.fail("""\ Incorrect attribute value. Expected: {0} - Actual: {1}""".format( - value, attrs - ) - ) + Actual: {1}""".format(value, attrs)) def assertAttributes(self, action, attrlist): if sorted(action.attrs.keys()) != sorted(attrlist): - self.fail( - """\ + self.fail("""\ Incorrect attribute list. Expected: {0} - Actual: {1}""".format( - sorted(attrlist), sorted(action.attrs.keys()) - ) - ) + Actual: {1}""".format(sorted(attrlist), sorted(action.attrs.keys()))) def test_action_parser(self): action.fromstr("file 12345 name=foo path=/tmp/foo") diff --git a/src/tests/api/t_api.py b/src/tests/api/t_api.py index 3629f572b..3cd6e9898 100644 --- a/src/tests/api/t_api.py +++ b/src/tests/api/t_api.py @@ -776,7 +776,7 @@ def validate_results(results): # Verify that parse returns the expected object and information # when provided a file path. fobj.seek(0) - (fd1, path1) = tempfile.mkstemp(dir=self.test_root) + fd1, path1 = tempfile.mkstemp(dir=self.test_root) with open(path1, "w") as f: f.write(fobj.read()) validate_results(api_obj.parse_p5i(location=path1)) diff --git a/src/tests/api/t_api_list.py b/src/tests/api/t_api_list.py index d2791af46..048cd640b 100644 --- a/src/tests/api/t_api_list.py +++ b/src/tests/api/t_api_list.py @@ -196,9 +196,7 @@ def setUp(self): open {stem}@{ver} add set name=pkg.summary value="{summ}" add set name=pkg.description value="{desc}" -""".format( - stem=stem, ver=ver, summ=summ, desc=desc - ) +""".format(stem=stem, ver=ver, summ=summ, desc=desc) cats = self.__get_pkg_cats(stem, sver) if cats: diff --git a/src/tests/api/t_api_refresh.py b/src/tests/api/t_api_refresh.py index a99e5e95d..292d59910 100644 --- a/src/tests/api/t_api_refresh.py +++ b/src/tests/api/t_api_refresh.py @@ -59,13 +59,9 @@ class TestApiRefresh(pkg5unittest.ManyDepotTestCase): pkgs_data = {} for i, pkg in enumerate(pkgs): - pkgs_data[i] = ( - """ + pkgs_data[i] = """ open {pkg} - close""".format( - pkg=pkg - ) - ) + close""".format(pkg=pkg) def setUp(self): # we want two publishers with the same name diff --git a/src/tests/api/t_config.py b/src/tests/api/t_config.py index 367b2d0f1..533be4f38 100644 --- a/src/tests/api/t_config.py +++ b/src/tests/api/t_config.py @@ -1482,9 +1482,7 @@ def test_base(self): bool_basic = False str_basic = {0} -""".format( - TH_PACKAGE - ), +""".format(TH_PACKAGE), str(conf), ) @@ -1509,9 +1507,7 @@ def test_base(self): bool_basic = False str_basic = {0} -""".format( - TH_PACKAGE - ), +""".format(TH_PACKAGE), str(conf), ) @@ -1623,9 +1619,7 @@ def test_file_read_write(self): [unknown_section] unknown_property = {0} -""".format( - TH_PACKAGE - ) +""".format(TH_PACKAGE) scpath = self.make_misc_files({"cfg_cache": content})[0] conf = cfg.FileConfig(scpath, definitions=self._defs) self.assertEqual(conf.version, 0) @@ -1642,9 +1636,7 @@ def test_file_read_write(self): [new_section] new_property = {0} -""".format( - TH_PACKAGE - ) +""".format(TH_PACKAGE) scpath = self.make_misc_files({"cfg_cache": content})[0] conf = cfg.FileConfig(scpath, definitions=self._defs) self.assertEqual(conf.version, 2) diff --git a/src/tests/api/t_dependencies.py b/src/tests/api/t_dependencies.py index a1e435ed1..b89ac108f 100644 --- a/src/tests/api/t_dependencies.py +++ b/src/tests/api/t_dependencies.py @@ -129,113 +129,81 @@ class TestDependencyAnalyzer(pkg5unittest.Pkg5TestCase): hardlink path=usr/foo target=../{syslog_path} hardlink path=usr/bar target=../{syslog_path} hardlink path=baz target={authlog_path} -""".format( - **paths - ) +""".format(**paths) int_hardlink_manf = """ \ hardlink path=usr/foo target=../{syslog_path} file NOHASH group=sys mode=0644 owner=root path={syslog_path} -""".format( - **paths - ) +""".format(**paths) int_hardlink_manf_test_symlink = """ \ hardlink path=usr/foo target=../{syslog_path} file NOHASH group=sys mode=0644 owner=root path=bar/syslog -""".format( - **paths - ) +""".format(**paths) ext_script_manf = """ \ file NOHASH group=bin mode=0755 owner=root path={script_path} -""".format( - **paths - ) +""".format(**paths) int_script_manf = """ \ file NOHASH group=bin mode=0755 owner=root path={script_path} file NOHASH group=bin mode=0755 owner=root path={ksh_path} -""".format( - **paths - ) +""".format(**paths) ext_elf_manf = """ \ file NOHASH group=bin mode=0755 owner=root path={curses_path} -""".format( - **paths - ) +""".format(**paths) int_elf_manf = """ \ file NOHASH group=bin mode=0755 owner=root path={libc_path} file NOHASH group=bin mode=0755 owner=root path={curses_path} -""".format( - **paths - ) +""".format(**paths) ext_python_manf = """ \ file NOHASH group=bin mode=0755 owner=root path={indexer_path} -""".format( - **paths - ) +""".format(**paths) ext_python_pkg_manf = """ \ file NOHASH group=bin mode=0755 owner=root path={pkg_path} -""".format( - **paths - ) +""".format(**paths) python_mod_manf = """ \ file NOHASH group=bin mode=0755 owner=root path={py_mod_path} file NOHASH group=bin mode=0755 owner=root path={py_mod_path_alt} -""".format( - **paths - ) +""".format(**paths) relative_ext_depender_manf = """ \ file NOHASH group=bin mode=0755 owner=root path={relative_depender} -""".format( - **paths - ) +""".format(**paths) relative_int_manf = """ \ file NOHASH group=bin mode=0755 owner=root path={relative_dependee} file NOHASH group=bin mode=0755 owner=root path={relative_depender} -""".format( - **paths - ) +""".format(**paths) variant_manf_1 = """ \ set name=variant.arch value=foo value=bar value=baz file NOHASH group=bin mode=0755 owner=root path={script_path} file NOHASH group=bin mode=0755 owner=root path={ksh_path} variant.arch=foo -""".format( - **paths - ) +""".format(**paths) variant_manf_2 = """ \ set name=variant.arch value=foo value=bar value=baz file NOHASH group=bin mode=0755 owner=root path={script_path} variant.arch=foo file NOHASH group=bin mode=0755 owner=root path={ksh_path} variant.arch=foo -""".format( - **paths - ) +""".format(**paths) variant_manf_3 = """ \ set name=variant.arch value=foo value=bar value=baz file NOHASH group=bin mode=0755 owner=root path={script_path} variant.arch=bar file NOHASH group=bin mode=0755 owner=root path={ksh_path} variant.arch=foo -""".format( - **paths - ) +""".format(**paths) variant_manf_4 = """ \ set name=variant.arch value=foo set name=variant.opensolaris.zone value=global value=nonglobal file NOHASH group=bin mode=0755 owner=root path={script_path} variant.opensolaris.zone=global file NOHASH group=bin mode=0755 owner=root path={ksh_path} variant.opensolaris.zone=global -""".format( - **paths - ) +""".format(**paths) python_abs_text = """\ #!/usr/bin/python @@ -284,9 +252,7 @@ def run(self): ] smf_manifest_text = {} - smf_manifest_text[ - "service_single" - ] = """ + smf_manifest_text["service_single"] = """ @@ -356,9 +322,7 @@ def run(self): "svc:/application/pkg5test/delivered-many:nodeps2", ] - smf_manifest_text[ - "service_single_specific" - ] = """ + smf_manifest_text["service_single_specific"] = """ @@ -432,9 +396,7 @@ def run(self): "svc:/application/pkg5test/delivered-many" ] - smf_manifest_text[ - "service_general" - ] = """ + smf_manifest_text["service_general"] = """ @@ -511,9 +473,7 @@ def run(self): "svc:/application/pkg5test/foreign-many" ] - smf_manifest_text[ - "service_many" - ] = """ + smf_manifest_text["service_many"] = """ @@ -606,9 +566,7 @@ def run(self): "svc:/application/pkg5test/another-unknown:default", ] - smf_manifest_text[ - "service_unknown" - ] = """ + smf_manifest_text["service_unknown"] = """ @@ -695,9 +653,7 @@ def run(self): smf_known_deps["svc:/application/pkg5test/delivered-many:nodeps"] = [] smf_known_deps["svc:/application/pkg5test/delivered-many:nodeps1"] = [] - smf_manifest_text[ - "delivered_many_nodeps" - ] = """ + smf_manifest_text["delivered_many_nodeps"] = """ -\"{2}\"
""".format( - url, fname, title - ) +\"{2}\"
""".format(url, fname, title) rf.close() @@ -371,9 +360,7 @@ def report_by_country(data, title, summary_file=None):
    -""".format( - title, title, title - ) +""".format(title, title, title) sel = 'class="selected"' for r in map_regions: diff --git a/src/util/log-scripts/an_search.py b/src/util/log-scripts/an_search.py index 15620be65..edd1aadd8 100644 --- a/src/util/log-scripts/an_search.py +++ b/src/util/log-scripts/an_search.py @@ -64,9 +64,7 @@ def emit_search_report(summary_file, searchtype, label, results):
    - """.format( - label=label, searchtype=searchtype - ), + """.format(label=label, searchtype=searchtype), file=summary_file, ) @@ -100,9 +98,7 @@ def emit_search_report(summary_file, searchtype, label, results): myColumnDefs, myDataSource, {sortedBy:{key:"{label}", dir:YAHOO.widget.DataTable.CLASS_DESC}}); - """.format( - label=label, searchtype=searchtype - ), + """.format(label=label, searchtype=searchtype), file=summary_file, ) diff --git a/src/util/log-scripts/in_header.py b/src/util/log-scripts/in_header.py index 9c8bbc2d1..2ef4df146 100644 --- a/src/util/log-scripts/in_header.py +++ b/src/util/log-scripts/in_header.py @@ -110,9 +110,7 @@

    {1} {2} Statistics

    -""".format( - hostname, hostname, hostname -) +""".format(hostname, hostname, hostname) print(header) diff --git a/src/util/log-scripts/translate.py b/src/util/log-scripts/translate.py index 5528e5f06..10e6da104 100644 --- a/src/util/log-scripts/translate.py +++ b/src/util/log-scripts/translate.py @@ -58,7 +58,7 @@ # print("line: [{0}]".format(line)) fields = line.split() - (ip, d, fullop) = (fields[0], fields[3], fields[6]) + ip, d, fullop = (fields[0], fields[3], fields[6]) del fields # Get country code and translate ip -> md5 of ip diff --git a/src/util/publish/pkgdiff.py b/src/util/publish/pkgdiff.py index 55cd36f0b..69d06b66b 100755 --- a/src/util/publish/pkgdiff.py +++ b/src/util/publish/pkgdiff.py @@ -63,15 +63,11 @@ def usage(errmsg="", exitcode=EXIT_BADOPT): if errmsg: print("pkgdiff: {0}".format(errmsg), file=sys.stderr) - print( - _( - """\ + print(_("""\ Usage: pkgdiff [-i attribute]... [-o attribute] [-t action_name[,action_name]...]... - [-v name=value]... (file1 | -) (file2 | -)""" - ) - ) + [-v name=value]... (file1 | -) (file2 | -)""")) sys.exit(exitcode) diff --git a/src/util/publish/pkgfmt.py b/src/util/publish/pkgfmt.py index 255d964e1..8133ab408 100755 --- a/src/util/publish/pkgfmt.py +++ b/src/util/publish/pkgfmt.py @@ -105,11 +105,9 @@ def usage(errmsg="", exitcode=EXIT_BADOPT): error(errmsg) print( - _( - """\ + _("""\ Usage: - pkgfmt [-cdsu] [-f v1|v2] [file1] ... """ - ), + pkgfmt [-cdsu] [-f v1|v2] [file1] ... """), file=sys.stderr, ) diff --git a/src/util/publish/pkgmerge.py b/src/util/publish/pkgmerge.py index 3d60e352f..020629b05 100755 --- a/src/util/publish/pkgmerge.py +++ b/src/util/publish/pkgmerge.py @@ -108,9 +108,7 @@ def usage(errmsg="", exitcode=EXIT_BADOPT): if errmsg: emsg("pkgmerge: {0}".format(errmsg)) - msg( - _( - """\ + msg(_("""\ Usage: pkgmerge [-n] -d dest_repo -s variant=value[,...],src_repo ... [-p publisher_prefix ... ] [pkg_fmri_pattern ...] @@ -146,9 +144,7 @@ def usage(errmsg="", exitcode=EXIT_BADOPT): TMPDIR, TEMP, TMP The absolute path of the directory where temporary data should be stored during program execution. -""" - ) - ) +""")) sys.exit(exitcode) diff --git a/src/util/publish/pkgmogrify.py b/src/util/publish/pkgmogrify.py index 52399e0ee..2326222a0 100755 --- a/src/util/publish/pkgmogrify.py +++ b/src/util/publish/pkgmogrify.py @@ -51,14 +51,10 @@ def usage(errmsg="", exitcode=EXIT_BADOPT): if errmsg: print("pkgmogrify: {0}".format(errmsg), file=sys.stderr) - print( - _( - """\ + print(_("""\ Usage: pkgmogrify [-vi] [-I includedir ...] [-D macro=value ...] - [-O outputfile] [-P printfile] [inputfile ...]""" - ) - ) + [-O outputfile] [-P printfile] [inputfile ...]""")) sys.exit(exitcode) diff --git a/src/util/publish/pkgsurf.py b/src/util/publish/pkgsurf.py index f4c17b94f..f4eb077b3 100755 --- a/src/util/publish/pkgsurf.py +++ b/src/util/publish/pkgsurf.py @@ -135,18 +135,14 @@ def cleanup(no_msg=False): global temp_root if repo_modified and not repo_finished and not no_msg: - error( - _( - """ + error(_(""" The target repository has been modified but the operation did not finish successfully. It is now in an inconsistent state. To re-try the operation, run the following commands: /usr/bin/pkgrepo rebuild -s {repo} {argv} -""" - ).format(repo=repo_uri, argv=" ".join(sys.argv)) - ) +""").format(repo=repo_uri, argv=" ".join(sys.argv))) if temp_root: shutil.rmtree(temp_root) @@ -160,9 +156,7 @@ def usage(usage_error=None, cmd=None, retcode=pkgdefs.EXIT_BADOPT): if usage_error: error(usage_error, cmd=cmd) - emsg( - _( - """\ + emsg(_("""\ Usage: pkgsurf -s target_path -r ref_uri [-n] [-p publisher ...] [-i name ...] [-c pattern ...] @@ -188,9 +182,7 @@ def usage(usage_error=None, cmd=None, retcode=pkgdefs.EXIT_BADOPT): filesystem-based repository. -?/--help Print this message. -""" - ) - ) +""")) sys.exit(retcode)
    Term{label}