__init__.py revision 2678
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.
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen# When distributing Covered Code, include this CDDL HEADER in each
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen# If applicable, add the following below this CDDL HEADER, with the
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen# fields enclosed by brackets "[]" replaced with your own identifying
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen# information: Portions Copyright [yyyy] [name of copyright owner]
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen# CDDL HEADER END
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen# Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved.
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen def __init__(self, max_level=logging.CRITICAL):
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen """Simple subclass to ignore exceptions raised during logging output."""
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen # Ignore exceptions raised during output to stdout/stderr.
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen """ This class defines settings which are global
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen to the client instance """
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen # Default maximum number of redirects received before
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen # aborting a connection.
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen # Default number of retries per-host
d8b77aef97e89f1ccc5cbdaef77be9052279e35fTimo Sirainen # Default number of seconds to give up if not connected
d8b77aef97e89f1ccc5cbdaef77be9052279e35fTimo Sirainen # Default number of seconds beneath low-speed limit before
d8b77aef97e89f1ccc5cbdaef77be9052279e35fTimo Sirainen # Minimum bytes/sec before client thinks about giving up
d8b77aef97e89f1ccc5cbdaef77be9052279e35fTimo Sirainen # on connection.
d8b77aef97e89f1ccc5cbdaef77be9052279e35fTimo Sirainen # Maximum number of transient errors before we abort an
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen self.pkg_client_max_consecutive_error_default = 4
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen # The location within the image of the cache for pkg.sysrepo(1M)
d8b77aef97e89f1ccc5cbdaef77be9052279e35fTimo Sirainen # Maximum number of timeouts before client gives up.
d8b77aef97e89f1ccc5cbdaef77be9052279e35fTimo Sirainen self.PKG_CLIENT_MAX_TIMEOUT = int(os.environ.get(
d8b77aef97e89f1ccc5cbdaef77be9052279e35fTimo Sirainen "PKG_CLIENT_MAX_TIMEOUT",
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen # Number of seconds trying to connect before client
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen self.PKG_CLIENT_CONNECT_TIMEOUT = int(os.environ.get(
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen "PKG_CLIENT_CONNECT_TIMEOUT",
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen # Number of seconds below lowspeed limit before
b2105c78f0fd58281317e6d777ded860f33153a3Timo Sirainen # transaction is aborted.
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen self.PKG_CLIENT_LOWSPEED_TIMEOUT = int(os.environ.get(
31ddc75584c5cde53d2e78a737587f2e7fdcb0d2Timo Sirainen "PKG_CLIENT_LOWSPEED_TIMEOUT",
31ddc75584c5cde53d2e78a737587f2e7fdcb0d2Timo Sirainen # Number of transient errors before transaction
b2105c78f0fd58281317e6d777ded860f33153a3Timo Sirainen # is aborted.
b2105c78f0fd58281317e6d777ded860f33153a3Timo Sirainen os.environ.get("PKG_CLIENT_MAX_CONSECUTIVE_ERROR",
b2105c78f0fd58281317e6d777ded860f33153a3Timo Sirainen self.pkg_client_max_consecutive_error_default))
690af4a90eaf8611c2573d34126bb7a852c50a44Timo Sirainen # Number of redirects before a connection is
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen logger.removeHandler(self.__error_log_handler)
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen """Resets client logging to its default state. This will cause
b7b81543899e306c71e6152516d8698416162bcbTimo Sirainen all logging.INFO entries to go to sys.stdout, and all entries of
b7b81543899e306c71e6152516d8698416162bcbTimo Sirainen logging.WARNING or higher to go to sys.stderr."""
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen # Don't pass messages that are rejected to the root logger.
fd3d711f219fd6813492acbe051e04327f0ca0f0Timo Sirainen # By default, log all informational messages, but not warnings
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen # and above to stdout.
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen # Minimum logging level for informational messages.
b7b81543899e306c71e6152516d8698416162bcbTimo Sirainen # Enforce maximum logging level for informational messages.
fd3d711f219fd6813492acbe051e04327f0ca0f0Timo Sirainen # By default, log all warnings and above to stderr.
b7b81543899e306c71e6152516d8698416162bcbTimo Sirainen # Stash the handles so they can be removed later.
b7b81543899e306c71e6152516d8698416162bcbTimo Sirainen error_log_handler = property(__get_error_log_handler,
b7b81543899e306c71e6152516d8698416162bcbTimo Sirainen info_log_handler = property(__get_info_log_handler,