__init__.py revision 2828
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen# CDDL HEADER START
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen# The contents of this file are subject to the terms of the
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen# Common Development and Distribution License (the "License").
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen# You may not use this file except in compliance with the License.
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen# See the License for the specific language governing permissions
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen# and limitations under the License.
f16c114c20bbd7d292d93415d1e56c8dd6abd3e7Timo Sirainen# When distributing Covered Code, include this CDDL HEADER in each
f16c114c20bbd7d292d93415d1e56c8dd6abd3e7Timo Sirainen# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
f16c114c20bbd7d292d93415d1e56c8dd6abd3e7Timo Sirainen# If applicable, add the following below this CDDL HEADER, with the
f16c114c20bbd7d292d93415d1e56c8dd6abd3e7Timo Sirainen# fields enclosed by brackets "[]" replaced with your own identifying
f16c114c20bbd7d292d93415d1e56c8dd6abd3e7Timo Sirainen# information: Portions Copyright [yyyy] [name of copyright owner]
f16c114c20bbd7d292d93415d1e56c8dd6abd3e7Timo Sirainen# CDDL HEADER END
f16c114c20bbd7d292d93415d1e56c8dd6abd3e7Timo Sirainen# Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved.
f16c114c20bbd7d292d93415d1e56c8dd6abd3e7Timo Sirainen# Missing docstring; pylint: disable=C0111
16f816d3f3c32ae3351834253f52ddd0212bcbf3Timo Sirainen def __init__(self, max_level=logging.CRITICAL):
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen """Simple subclass to ignore exceptions raised during logging output."""
98c1cf256927e254f0c092acd2ddcd7ea50bd009Timo Sirainen # Ignore exceptions raised during output to stdout/stderr.
e06c0b65c16ccce69bbee009ead14d7d3d17a256Timo Sirainen """ This class defines settings which are global
7a6b45405fb1544ac476e6eb1402a70cc1ddcdcfTimo Sirainen to the client instance """
98c1cf256927e254f0c092acd2ddcd7ea50bd009Timo Sirainen # These properties allow the client to describe how it
98c1cf256927e254f0c092acd2ddcd7ea50bd009Timo Sirainen # has been asked to behave with respect to output. This
98c1cf256927e254f0c092acd2ddcd7ea50bd009Timo Sirainen # allows subprocess invocations (e.g. for linked images) to
a2637488c8d514ec1ac3914811deee814f9761b3Timo Sirainen # discover from the global settings how they are expected
a2637488c8d514ec1ac3914811deee814f9761b3Timo Sirainen # runid, used by the pkg.1 client and the linked image
a2637488c8d514ec1ac3914811deee814f9761b3Timo Sirainen # subsystem when when generating temporary files.
a2637488c8d514ec1ac3914811deee814f9761b3Timo Sirainen # file descriptor used by ProgressTracker classes when running
a2637488c8d514ec1ac3914811deee814f9761b3Timo Sirainen # "pkg remote" to indicate progress back to the parent/client
1d2b188f0eedc3cab6e27ceac5425a037f38042eTimo Sirainen # concurrency value used for linked image recursion
a2637488c8d514ec1ac3914811deee814f9761b3Timo Sirainen self.client_concurrency = self.client_concurrency_default
02b79f9c2636da1829eee5b92753602bba8b67edTimo Sirainen "PKG_CONCURRENCY",
02b79f9c2636da1829eee5b92753602bba8b67edTimo Sirainen # remove PKG_CONCURRENCY from the environment so child
a2637488c8d514ec1ac3914811deee814f9761b3Timo Sirainen # processes don't inherit it.
02b79f9c2636da1829eee5b92753602bba8b67edTimo Sirainen # Default maximum number of redirects received before
a2637488c8d514ec1ac3914811deee814f9761b3Timo Sirainen # aborting a connection.
299183fbb6ec5d0828a0880da372540421ac4665Timo Sirainen # Default number of retries per-host
a2637488c8d514ec1ac3914811deee814f9761b3Timo Sirainen # Default number of seconds to give up if not connected
299183fbb6ec5d0828a0880da372540421ac4665Timo Sirainen # Default number of seconds beneath low-speed limit before
299183fbb6ec5d0828a0880da372540421ac4665Timo Sirainen # Minimum bytes/sec before client thinks about giving up
299183fbb6ec5d0828a0880da372540421ac4665Timo Sirainen # on connection.
299183fbb6ec5d0828a0880da372540421ac4665Timo Sirainen # Maximum number of transient errors before we abort an
a2637488c8d514ec1ac3914811deee814f9761b3Timo Sirainen self.pkg_client_max_consecutive_error_default = 4
299183fbb6ec5d0828a0880da372540421ac4665Timo Sirainen # The location within the image of the cache for pkg.sysrepo(1M)
299183fbb6ec5d0828a0880da372540421ac4665Timo Sirainen # Maximum number of timeouts before client gives up.
299183fbb6ec5d0828a0880da372540421ac4665Timo Sirainen self.PKG_CLIENT_MAX_TIMEOUT = int(os.environ.get(
299183fbb6ec5d0828a0880da372540421ac4665Timo Sirainen "PKG_CLIENT_MAX_TIMEOUT",
299183fbb6ec5d0828a0880da372540421ac4665Timo Sirainen # Number of seconds trying to connect before client
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen self.PKG_CLIENT_CONNECT_TIMEOUT = int(os.environ.get(
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen "PKG_CLIENT_CONNECT_TIMEOUT",
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen # Number of seconds below lowspeed limit before
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen # transaction is aborted.
2e937ed8585299b2e879a28314902a5f644813d2Timo Sirainen self.PKG_CLIENT_LOWSPEED_TIMEOUT = int(os.environ.get(
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen "PKG_CLIENT_LOWSPEED_TIMEOUT",
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen # Number of transient errors before transaction
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen # is aborted.
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen os.environ.get("PKG_CLIENT_MAX_CONSECUTIVE_ERROR",
e5c08648676d1989f6e70b95e5990c26b3e8b96bTimo Sirainen self.pkg_client_max_consecutive_error_default))
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen # Number of redirects before a connection is
6843896c40bee4f9b6680ca7ced598c446e9f999Timo Sirainen logger.removeHandler(self.__error_log_handler)
73b50eecfc31750a312e2f940023f522eb07178cTimo Sirainen # Method could be a function; pylint: disable=R0201
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen """Resets client logging to its default state. This will cause
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen all logging.INFO entries to go to sys.stdout, and all entries of
a393d9d6dabdc46cf724f8cb004a652b4036d53dTimo Sirainen logging.WARNING or higher to go to sys.stderr."""
9a06cabdfdf4d5e2f19a07e506c3c7d08a7e7038Timo Sirainen # Don't pass messages that are rejected to the root logger.
2bf7bb14894faf721518e2122a14a2389ef94078Timo Sirainen # By default, log all informational messages, but not warnings
1d2b188f0eedc3cab6e27ceac5425a037f38042eTimo Sirainen # and above to stdout.
9a06cabdfdf4d5e2f19a07e506c3c7d08a7e7038Timo Sirainen # Minimum logging level for informational messages.
73b50eecfc31750a312e2f940023f522eb07178cTimo Sirainen # Enforce maximum logging level for informational messages.
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen # By default, log all warnings and above to stderr.
7f3be7d885c75cdd77f536929a45bc9764595960Timo Sirainen # Stash the handles so they can be removed later.
f6699a08521aacc4c2bb5b6175691dad5f715f8cTimo Sirainen error_log_handler = property(__get_error_log_handler,
f6699a08521aacc4c2bb5b6175691dad5f715f8cTimo Sirainen info_log_handler = property(__get_info_log_handler,