__init__.py revision 2693
#
# 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
# 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
#
#
#
# Missing docstring; pylint: disable-msg=C0111
import logging
import os
import sys
__all__ = ["global_settings"]
"""Simple subclass to ignore exceptions raised during logging output."""
return
class GlobalSettings(object):
""" This class defines settings which are global
to the client instance """
self.__info_log_handler = None
self.__error_log_handler = None
#
# These properties allow the client to describe how it
# has been asked to behave with respect to output. This
# allows subprocess invocations (e.g. for linked images) to
# discover from the global settings how they are expected
# to behave.
#
# runid, used by the pkg.1 client and the linked image
# subsystem when when generating temporary files.
# file descriptor used by ProgressTracker classes when running
# process.
self.client_output_progfd = None
# concurrency value used for linked image recursion
try:
"PKG_CONCURRENCY",
# remove PKG_CONCURRENCY from the environment so child
# processes don't inherit it.
except ValueError:
pass
self.client_name = None
# Default maximum number of redirects received before
# aborting a connection.
# Default number of retries per-host
# Default number of seconds to give up if not connected
# Default number of seconds beneath low-speed limit before
# giving up.
# on connection.
# Maximum number of transient errors before we abort an
# endpoint.
# The location within the image of the cache for pkg.sysrepo(1M)
try:
# Maximum number of timeouts before client gives up.
"PKG_CLIENT_MAX_TIMEOUT",
except ValueError:
try:
# Number of seconds trying to connect before client
# aborts.
"PKG_CLIENT_CONNECT_TIMEOUT",
except ValueError:
try:
# Number of seconds below lowspeed limit before
# transaction is aborted.
"PKG_CLIENT_LOWSPEED_TIMEOUT",
except ValueError:
try:
# Number of transient errors before transaction
# is aborted.
except ValueError:
try:
# Number of redirects before a connection is
# aborted.
except ValueError:
def __get_error_log_handler(self):
return self.__error_log_handler
def __get_info_log_handler(self):
return self.__info_log_handler
def __get_verbose(self):
if val:
if val:
if val:
else:
# Method could be a function; pylint: disable-msg=R0201
def reset_logging(self):
"""Resets client logging to its default state. This will cause
all logging.INFO entries to go to sys.stdout, and all entries of
logging.WARNING or higher to go to sys.stderr."""
# Don't pass messages that are rejected to the root logger.
# By default, log all informational messages, but not warnings
# and above to stdout.
# Minimum logging level for informational messages.
else:
# Enforce maximum logging level for informational messages.
# By default, log all warnings and above to stderr.
# Stash the handles so they can be removed later.