summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CONTRIBUTING.md13
-rw-r--r--swiftclient/client.py6
-rwxr-xr-xswiftclient/shell.py23
-rw-r--r--tests/unit/test_swiftclient.py22
-rw-r--r--tox.ini5
5 files changed, 58 insertions, 11 deletions
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
new file mode 100644
index 0000000..866da8a
--- /dev/null
+++ b/CONTRIBUTING.md
@@ -0,0 +1,13 @@
+If you would like to contribute to the development of OpenStack,
+you must follow the steps in the "If you're a developer"
+section of this page: [http://wiki.openstack.org/HowToContribute](http://wiki.openstack.org/HowToContribute#If_you.27re_a_developer)
+
+Once those steps have been completed, changes to OpenStack
+should be submitted for review via the Gerrit tool, following
+the workflow documented at [http://wiki.openstack.org/GerritWorkflow](http://wiki.openstack.org/GerritWorkflow).
+
+Gerrit is the review system used in the OpenStack projects. We're sorry, but
+we won't be able to respond to pull requests submitted through GitHub.
+
+Bugs should be filed [on Launchpad](https://bugs.launchpad.net/python-swiftclient),
+not in GitHub's issue tracker.
diff --git a/swiftclient/client.py b/swiftclient/client.py
index f13e829..7b50860 100644
--- a/swiftclient/client.py
+++ b/swiftclient/client.py
@@ -88,8 +88,8 @@ def http_log(args, kwargs, resp, body):
else:
log_method = logger.info
- log_method("REQ: %s" % "".join(string_parts))
- log_method("RESP STATUS: %s %s" % (resp.status, resp.reason))
+ log_method("REQ: %s", "".join(string_parts))
+ log_method("RESP STATUS: %s %s", resp.status, resp.reason)
log_method("RESP HEADERS: %s", resp.getheaders())
if body:
log_method("RESP BODY: %s", body)
@@ -361,7 +361,7 @@ def get_auth(auth_url, user, key, **kwargs):
if kwargs.get('tenant_name'):
os_options['tenant_name'] = kwargs['tenant_name']
- if ('tenant_name' not in os_options):
+ if not (os_options.get('tenant_name') or os_options.get('tenant_id')):
raise ClientException('No tenant specified')
cacert = kwargs.get('cacert', None)
diff --git a/swiftclient/shell.py b/swiftclient/shell.py
index 12eeb63..3b3757c 100755
--- a/swiftclient/shell.py
+++ b/swiftclient/shell.py
@@ -1335,6 +1335,25 @@ def parse_args(parser, args, enforce_requires=True):
'region_name': options.os_region_name,
}
+ if len(args) > 1 and args[1] == '--help':
+ if args[0] == 'capabilities':
+ print(st_capabilities_help)
+ elif args[0] == 'delete':
+ print(st_delete_help)
+ elif args[0] == 'download':
+ print(st_download_help)
+ elif args[0] == 'list':
+ print(st_list_help)
+ elif args[0] == 'post':
+ print(st_post_help)
+ elif args[0] == 'stat':
+ print(st_stat_help)
+ elif args[0] == 'upload':
+ print(st_upload_help)
+ else:
+ print("no help for %s" % args[0])
+ exit()
+
if len(args) > 1 and args[0] == "capabilities":
return options, args
@@ -1378,7 +1397,7 @@ usage: %%prog [--version] [--help] [--snet] [--verbose]
[--os-endpoint-type <endpoint-type>]
[--os-cacert <ca-certificate>] [--insecure]
[--no-ssl-compression]
- <subcommand> ...
+ <subcommand> [--help]
Command-line interface to the OpenStack Swift API.
@@ -1398,6 +1417,8 @@ Positional arguments:
Examples:
+ %%prog download --help
+
%%prog -A https://auth.api.rackspacecloud.com/v1.0 -U user -K api_key stat -v
%%prog --os-auth-url https://api.example.com/v2.0 --os-tenant-name tenant \\
diff --git a/tests/unit/test_swiftclient.py b/tests/unit/test_swiftclient.py
index 283400e..d473765 100644
--- a/tests/unit/test_swiftclient.py
+++ b/tests/unit/test_swiftclient.py
@@ -285,7 +285,7 @@ class TestGetAuth(MockHttpTest):
'asdf', 'asdf',
auth_version='1.0')
- def test_auth_v2(self):
+ def test_auth_v2_with_tenant_name(self):
os_options = {'tenant_name': 'asdf'}
c.get_keystoneclient_2_0 = fake_get_keystoneclient_2_0(os_options)
url, token = c.get_auth('http://www.test.com', 'asdf', 'asdf',
@@ -294,13 +294,31 @@ class TestGetAuth(MockHttpTest):
self.assertTrue(url.startswith("http"))
self.assertTrue(token)
- def test_auth_v2_no_tenant_name(self):
+ def test_auth_v2_with_tenant_id(self):
+ os_options = {'tenant_id': 'asdf'}
+ c.get_keystoneclient_2_0 = fake_get_keystoneclient_2_0(os_options)
+ url, token = c.get_auth('http://www.test.com', 'asdf', 'asdf',
+ os_options=os_options,
+ auth_version="2.0")
+ self.assertTrue(url.startswith("http"))
+ self.assertTrue(token)
+
+ def test_auth_v2_no_tenant_name_or_tenant_id(self):
c.get_keystoneclient_2_0 = fake_get_keystoneclient_2_0({})
self.assertRaises(c.ClientException, c.get_auth,
'http://www.tests.com', 'asdf', 'asdf',
os_options={},
auth_version='2.0')
+ def test_auth_v2_with_tenant_name_none_and_tenant_id_none(self):
+ os_options = {'tenant_name': None,
+ 'tenant_id': None}
+ c.get_keystoneclient_2_0 = fake_get_keystoneclient_2_0(os_options)
+ self.assertRaises(c.ClientException, c.get_auth,
+ 'http://www.tests.com', 'asdf', 'asdf',
+ os_options=os_options,
+ auth_version='2.0')
+
def test_auth_v2_with_tenant_user_in_user(self):
tenant_option = {'tenant_name': 'foo'}
c.get_keystoneclient_2_0 = fake_get_keystoneclient_2_0(tenant_option)
diff --git a/tox.ini b/tox.ini
index 5cee4cd..95cd94f 100644
--- a/tox.ini
+++ b/tox.ini
@@ -12,11 +12,6 @@ deps = -r{toxinidir}/requirements.txt
-r{toxinidir}/test-requirements.txt
commands = python setup.py testr --testr-args="{posargs}"
-[testenv:pypy]
-deps = setuptools<3.2
- -r{toxinidir}/requirements.txt
- -r{toxinidir}/test-requirements.txt
-
[testenv:pep8]
commands =
flake8 swiftclient tests