diff --git a/glareclient/common/base.py b/glareclient/common/base.py deleted file mode 100644 index 6a2f0b7..0000000 --- a/glareclient/common/base.py +++ /dev/null @@ -1,35 +0,0 @@ -# Copyright 2012 OpenStack Foundation -# All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -""" -Base utilities to build API operation managers and objects on top of. - -DEPRECATED post v.0.12.0. Use 'glareclient.openstack.common.apiclient.base' -instead of this module." -""" - -import warnings - -from glareclient.openstack.common.apiclient import base - - -warnings.warn("The 'glareclient.common.base' module is deprecated post " - "v.0.12.0. Use 'glareclient.openstack.common.apiclient.base' " - "instead of this one.", DeprecationWarning) - - -getid = base.getid -Manager = base.ManagerWithFind -Resource = base.Resource diff --git a/glareclient/common/progressbar.py b/glareclient/common/progressbar.py index 01c7f6b..95c3f9c 100644 --- a/glareclient/common/progressbar.py +++ b/glareclient/common/progressbar.py @@ -19,7 +19,7 @@ import six class _ProgressBarBase(object): - """A progress bar provider for a wrapped obect. + """A progress bar provider for a wrapped object. Base abstract class used by specific class wrapper to show a progress bar when the wrapped object are consumed. diff --git a/glareclient/common/utils.py b/glareclient/common/utils.py index dc8bcad..83b84e1 100644 --- a/glareclient/common/utils.py +++ b/glareclient/common/utils.py @@ -18,9 +18,7 @@ from __future__ import print_function import errno import hashlib import os -import re import six -import six.moves.urllib.parse as urlparse import sys if os.name == 'nt': @@ -34,16 +32,6 @@ from oslo_utils import importutils SENSITIVE_HEADERS = ('X-Auth-Token', ) -# Decorator for cli-args -def arg(*args, **kwargs): - def _decorator(func): - # Because of the semantics of decorator composition if we just append - # to the options list positional options will appear to be backwards. - func.__dict__.setdefault('arguments', []).insert(0, (args, kwargs)) - return func - return _decorator - - def env(*vars, **kwargs): """Search for the first defined of possibly many env vars. @@ -66,36 +54,10 @@ def import_versioned_module(version, submodule=None): def exit(msg='', exit_code=1): if msg: - print_err(msg) + print(encodeutils.safe_decode(msg), file=sys.stderr) sys.exit(exit_code) -def print_err(msg): - print(encodeutils.safe_decode(msg), file=sys.stderr) - - -def strip_version(endpoint): - """Strip version from the last component of endpoint if present.""" - # NOTE(flaper87): This shouldn't be necessary if - # we make endpoint the first argument. However, we - # can't do that just yet because we need to keep - # backwards compatibility. - if not isinstance(endpoint, six.string_types): - raise ValueError("Expected endpoint") - - version = None - # Get rid of trailing '/' if present - endpoint = endpoint.rstrip('/') - url_parts = urlparse.urlparse(endpoint) - (scheme, netloc, path, __, __, __) = url_parts - path = path.lstrip('/') - # regex to match 'v1' or 'v2.0' etc - if re.match('v\d+\.?\d*', path): - version = float(path.lstrip('v')) - endpoint = scheme + '://' + netloc - return endpoint, version - - def integrity_iter(iter, checksum): """Check blob integrity. @@ -114,31 +76,6 @@ def integrity_iter(iter, checksum): (md5sum, checksum)) -def safe_header(name, value): - if value is not None and name in SENSITIVE_HEADERS: - h = hashlib.sha1(value) - d = h.hexdigest() - return name, "{SHA1}%s" % d - else: - return name, value - - -def endpoint_version_from_url(endpoint, default_version=None): - if endpoint: - endpoint, version = strip_version(endpoint) - return endpoint, version or default_version - else: - return None, default_version - - -def debug_enabled(argv): - if bool(env('GLARECLIENT_DEBUG')) is True: - return True - if '--debug' in argv or '-d' in argv: - return True - return False - - class IterableWithLength(object): def __init__(self, iterable, length): self.iterable = iterable diff --git a/glareclient/osc/v1/artifacts.py b/glareclient/osc/v1/artifacts.py index 6ff8b08..4fb4885 100644 --- a/glareclient/osc/v1/artifacts.py +++ b/glareclient/osc/v1/artifacts.py @@ -96,7 +96,7 @@ class ShowArtifact(command.ShowOne): parser.add_argument( 'id', metavar='', - help='ID of the artifact to update', + help='ID of the artifact to update.', ) return parser @@ -170,12 +170,12 @@ class UpdateArtifact(command.ShowOne): parser.add_argument( 'id', metavar='', - help='ID of the artifact to update', + help='ID of the artifact to update.', ) parser.add_argument( '--name', metavar='', - help='Name of the artifact', + help='Name of the artifact.', ), parser.add_argument( '--remove-property', @@ -228,7 +228,7 @@ class DeleteArtifact(command.ShowOne): parser.add_argument( 'id', metavar='', - help='ID of the artifact to update', + help='ID of the artifact to update.', ) return parser @@ -254,7 +254,7 @@ class ActivateArtifact(command.ShowOne): parser.add_argument( 'id', metavar='', - help='ID of the artifact to update', + help='ID of the artifact to update.', ) return parser @@ -280,7 +280,7 @@ class DeactivateArtifact(command.ShowOne): parser.add_argument( 'id', metavar='', - help='ID of the artifact to update', + help='ID of the artifact to update.', ) return parser @@ -306,7 +306,7 @@ class ReactivateArtifact(command.ShowOne): parser.add_argument( 'id', metavar='', - help='ID of the artifact to update', + help='ID of the artifact to update.', ) return parser @@ -319,7 +319,7 @@ class ReactivateArtifact(command.ShowOne): class PublishArtifact(command.ShowOne): - """Publish the artifact""" + """Publish the artifact""" def get_parser(self, prog_name): parser = super(PublishArtifact, self).get_parser(prog_name) @@ -332,7 +332,7 @@ class PublishArtifact(command.ShowOne): parser.add_argument( 'id', metavar='', - help='ID of the artifact to update', + help='ID of the artifact to update.', ) return parser diff --git a/glareclient/osc/v1/blobs.py b/glareclient/osc/v1/blobs.py index aa8fe3c..04802da 100644 --- a/glareclient/osc/v1/blobs.py +++ b/glareclient/osc/v1/blobs.py @@ -50,11 +50,11 @@ class UploadBlob(command.ShowOne): parser.add_argument( 'id', metavar='', - help='ID of the artifact to update', + help='ID of the artifact to update.', ) parser.add_argument( '--file', - metavar='', + metavar='', help='Local file that contains data to be uploaded.', ) parser.add_argument( @@ -109,7 +109,7 @@ class DownloadBlob(command.Command): parser.add_argument( 'id', metavar='', - help='ID of the artifact to update', + help='ID of the artifact to update.', ) parser.add_argument( '--progress', diff --git a/glareclient/tests/unit/test_utils.py b/glareclient/tests/unit/test_utils.py index b64976a..d8f2b81 100644 --- a/glareclient/tests/unit/test_utils.py +++ b/glareclient/tests/unit/test_utils.py @@ -15,7 +15,6 @@ import mock -from oslo_utils import encodeutils import six import testtools @@ -64,20 +63,3 @@ class TestUtils(testtools.TestCase): i = utils.IterableWithLength(data, 10) self.assertRaises(IOError, _iterate, i) data.close.assert_called_with() - - def test_safe_header(self): - self.assertEqual(('somekey', 'somevalue'), - utils.safe_header('somekey', 'somevalue')) - self.assertEqual(('somekey', None), - utils.safe_header('somekey', None)) - - for sensitive_header in utils.SENSITIVE_HEADERS: - (name, value) = utils.safe_header( - sensitive_header, - encodeutils.safe_encode('somestring')) - self.assertEqual(sensitive_header, name) - self.assertTrue(value.startswith("{SHA1}")) - - (name, value) = utils.safe_header(sensitive_header, None) - self.assertEqual(sensitive_header, name) - self.assertIsNone(value) diff --git a/glareclient/v1/artifacts.py b/glareclient/v1/artifacts.py index e3ba88a..770f387 100644 --- a/glareclient/v1/artifacts.py +++ b/glareclient/v1/artifacts.py @@ -27,7 +27,7 @@ class Controller(object): self.sort_dir_values = ('asc', 'desc') def _check_type_name(self, type_name): - """Check that type name and type versions were specified""" + """Check that type name and type versions were specified.""" type_name = type_name or self.type_name if type_name is None: msg = "Type name must be specified"