def inner(namespace, *args, **kwargs): """ :param namespace: :class:`argparse.Namespace` instance. This is the only required/expected parameter for a command function. """ log_level = zpmlib.LOG_LEVEL_MAP.get(namespace.log_level) logging.getLogger('zpmlib').setLevel(log_level) # This allows us to see `swiftclient` log messages, specifically HTTP # REQ/RESP swift_log = zpmlib.get_logger('swiftclient') swift_log.setLevel(log_level) swift_log.addFilter(SwiftLogFilter()) return func(namespace, *args, **kwargs)
import jinja2 import prettytable import six import swiftclient import yaml import zpmlib from zpmlib import util from zpmlib import zappbundler from zpmlib import zapptemplate _DEFAULT_UI_TEMPLATES = ['index.html.tmpl', 'style.css', 'zerocloud.js'] _ZAPP_YAML = 'python-zapp.yaml' _ZAPP_WITH_UI_YAML = 'python-zapp-with-ui.yaml' LOG = zpmlib.get_logger(__name__) BUFFER_SIZE = 65536 #: path/filename of the system.map (job description) in every zapp SYSTEM_MAP_ZAPP_PATH = 'boot/system.map' #: Message displayed if insufficient auth settings are specified, either on the #: command line or in environment variables. Shamelessly copied from #: ``python-swiftclient``. NO_AUTH_MSG = """\ Auth version 1.0 requires ST_AUTH, ST_USER, and ST_KEY environment variables to be set or overridden with -A, -U, or -K. Auth version 2.0 requires OS_AUTH_URL, OS_USERNAME, OS_PASSWORD, and OS_TENANT_NAME OS_TENANT_ID to be set or overridden with --os-auth-url, --os-username, --os-password, --os-tenant-name or os-tenant-id. Note: adding "-V 2" is necessary for this."""
# See the License for the specific language governing permissions and # limitations under the License. import functools import logging import os import operator import argparse import zpmlib from zpmlib import zpm # List of function that will be the top-level zpm commands. _commands = [] LOG = zpmlib.get_logger(__name__) class SwiftLogFilter(logging.Filter): def filter(self, record): # We want to filter out 404 errors when fetching containers. # In cases where this happens, we already deal with the exception, # so there's no need to constantly show spurious ERROR level messages # to the user. if (record.levelname == 'ERROR' and record.msg.msg == 'Container GET failed' and record.msg.http_status == 404): return False return True