summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.zuul.yaml6
-rw-r--r--releasenotes/source/index.rst1
-rw-r--r--releasenotes/source/xena.rst6
-rwxr-xr-xrun_tests.sh2
-rw-r--r--swiftclient/service.py2
-rwxr-xr-xswiftclient/shell.py34
-rw-r--r--test/unit/test_shell.py29
-rw-r--r--tox.ini16
8 files changed, 59 insertions, 37 deletions
diff --git a/.zuul.yaml b/.zuul.yaml
index 7badb0e..e26260a 100644
--- a/.zuul.yaml
+++ b/.zuul.yaml
@@ -33,6 +33,10 @@
description: |
Run functional tests of python-swiftclient under Python 2
vars:
+ devstack_localrc:
+ # devstack dropped support for bionic, but we want it for easier py2 support.
+ # Set this so we install anyway.
+ FORCE: "yes"
tox_envlist: py2func
- project:
@@ -40,7 +44,7 @@
- check-requirements
- lib-forward-testing-python3
- openstack-python-jobs
- - openstack-python3-xena-jobs
+ - openstack-python3-yoga-jobs
- publish-openstack-docs-pti
- release-notes-jobs-python3
check:
diff --git a/releasenotes/source/index.rst b/releasenotes/source/index.rst
index 52c3814..fb60ee0 100644
--- a/releasenotes/source/index.rst
+++ b/releasenotes/source/index.rst
@@ -6,6 +6,7 @@
:maxdepth: 1
current
+ xena
wallaby
victoria
ussuri
diff --git a/releasenotes/source/xena.rst b/releasenotes/source/xena.rst
new file mode 100644
index 0000000..1be85be
--- /dev/null
+++ b/releasenotes/source/xena.rst
@@ -0,0 +1,6 @@
+=========================
+Xena Series Release Notes
+=========================
+
+.. release-notes::
+ :branch: stable/xena
diff --git a/run_tests.sh b/run_tests.sh
index 39ce191..6991cd1 100755
--- a/run_tests.sh
+++ b/run_tests.sh
@@ -18,7 +18,7 @@ command -v tox > /dev/null 2>&1
if [ $? -ne 0 ]; then
echo 'This script requires "tox" to run.'
echo 'You can install it with "pip install tox".'
- exit 1;
+ exit 1;
fi
just_pep8=0
diff --git a/swiftclient/service.py b/swiftclient/service.py
index cd96a5b..8e2c7b0 100644
--- a/swiftclient/service.py
+++ b/swiftclient/service.py
@@ -1036,8 +1036,8 @@ class SwiftService(object):
version_marker = items[-1].get('version_id', '')
except ClientException as err:
traceback, err_time = report_traceback()
- logger.exception(err)
if err.http_status != 404:
+ logger.exception(err)
error = (err, traceback, err_time)
else:
error = (
diff --git a/swiftclient/shell.py b/swiftclient/shell.py
index 43950e6..fed0ef9 100755
--- a/swiftclient/shell.py
+++ b/swiftclient/shell.py
@@ -531,8 +531,7 @@ Optional arguments:
def st_list(parser, args, output_manager, return_parser=False):
- def _print_stats(options, stats, human):
- total_count = total_bytes = 0
+ def _print_stats(options, stats, human, totals):
container = stats.get("container", None)
for item in stats["listing"]:
item_name = item.get('name')
@@ -543,7 +542,7 @@ def st_list(parser, args, output_manager, return_parser=False):
item_bytes = item.get('bytes')
byte_str = prt_bytes(item_bytes, human)
count = item.get('count')
- total_count += count
+ totals['count'] += count
try:
meta = item.get('meta')
utc = gmtime(float(meta.get('x-timestamp')))
@@ -552,7 +551,7 @@ def st_list(parser, args, output_manager, return_parser=False):
datestamp = '????-??-?? ??:??:??'
if not options['totals']:
output_manager.print_msg(
- "%5s %s %s %s", count, byte_str,
+ "%12s %s %s %s", count, byte_str,
datestamp, item_name)
else: # list container contents
subdir = item.get('subdir')
@@ -578,17 +577,7 @@ def st_list(parser, args, output_manager, return_parser=False):
output_manager.print_msg(
"%s %10s %8s %24s %s",
byte_str, date, xtime, content_type, item_name)
- total_bytes += item_bytes
-
- # report totals
- if options['long'] or human:
- if not container:
- output_manager.print_msg(
- "%5s %s", prt_bytes(total_count, True),
- prt_bytes(total_bytes, human))
- else:
- output_manager.print_msg(
- prt_bytes(total_bytes, human))
+ totals['bytes'] += item_bytes
parser.add_argument(
'-l', '--long', dest='long', action='store_true', default=False,
@@ -642,6 +631,7 @@ def st_list(parser, args, output_manager, return_parser=False):
try:
if not args:
stats_parts_gen = swift.list()
+ container = None
else:
container = args[0]
args = args[1:]
@@ -667,12 +657,24 @@ def st_list(parser, args, output_manager, return_parser=False):
sort_keys=True, indent=2)
output_manager.print_msg('')
return
+
+ totals = {'count': 0, 'bytes': 0}
for stats in stats_parts_gen:
if stats["success"]:
- _print_stats(options, stats, human)
+ _print_stats(options, stats, human, totals)
else:
raise stats["error"]
+ # report totals
+ if options['long'] or human:
+ if container is None:
+ output_manager.print_msg(
+ "%12s %s", prt_bytes(totals['count'], True),
+ prt_bytes(totals['bytes'], human))
+ else:
+ output_manager.print_msg(
+ prt_bytes(totals['bytes'], human))
+
except SwiftError as e:
output_manager.error(e.value)
diff --git a/test/unit/test_shell.py b/test/unit/test_shell.py
index ef5d166..e3c0bc7 100644
--- a/test/unit/test_shell.py
+++ b/test/unit/test_shell.py
@@ -474,9 +474,10 @@ class TestShell(unittest.TestCase):
mock.call(marker='container', prefix=None, headers={})]
connection.return_value.get_account.assert_has_calls(calls)
- self.assertEqual(output.out,
- ' 0 0 1970-01-01 00:00:01 container\n'
- ' 0 0\n')
+ self.assertEqual(
+ output.out,
+ ' 0 0 1970-01-01 00:00:01 container\n'
+ ' 0 0\n')
# Now test again, this time without returning metadata
connection.return_value.head_container.return_value = {}
@@ -494,9 +495,10 @@ class TestShell(unittest.TestCase):
mock.call(marker='container', prefix=None, headers={})]
connection.return_value.get_account.assert_has_calls(calls)
- self.assertEqual(output.out,
- ' 0 0 ????-??-?? ??:??:?? container\n'
- ' 0 0\n')
+ self.assertEqual(
+ output.out,
+ ' 0 0 ????-??-?? ??:??:?? container\n'
+ ' 0 0\n')
def test_list_account_totals_error(self):
# No --lh provided: expect info message about incorrect --totals use
@@ -522,7 +524,7 @@ class TestShell(unittest.TestCase):
swiftclient.shell.main(argv)
calls = [mock.call(marker='', prefix=None, headers={})]
connection.return_value.get_account.assert_has_calls(calls)
- self.assertEqual(output.out, ' 6 3\n')
+ self.assertEqual(output.out, ' 6 3\n')
@mock.patch('swiftclient.service.Connection')
def test_list_container(self, connection):
@@ -544,9 +546,12 @@ class TestShell(unittest.TestCase):
self.assertEqual(output.out, 'object_a\n')
- # Test container listing with --long
+ # Test container listing with --long and multiple pages
connection.return_value.get_container.side_effect = [
- [None, [{'name': 'object_a', 'bytes': 0,
+ [None, [{'name': 'object_a', 'bytes': 3,
+ 'content_type': 'type/content',
+ 'last_modified': '123T456'}]],
+ [None, [{'name': 'object_b', 'bytes': 5,
'content_type': 'type/content',
'last_modified': '123T456'}]],
[None, []],
@@ -564,9 +569,11 @@ class TestShell(unittest.TestCase):
connection.return_value.get_container.assert_has_calls(calls)
self.assertEqual(output.out,
- ' 0 123 456'
+ ' 3 123 456'
' type/content object_a\n'
- ' 0\n')
+ ' 5 123 456'
+ ' type/content object_b\n'
+ ' 8\n')
@mock.patch('swiftclient.service.Connection')
def test_list_container_with_headers(self, connection):
diff --git a/tox.ini b/tox.ini
index 10e7b8d..fbc58c7 100644
--- a/tox.ini
+++ b/tox.ini
@@ -1,6 +1,6 @@
[tox]
envlist = py27,py3,pep8
-minversion = 2.0
+minversion = 3.18.0
skipsdist = True
[testenv]
@@ -17,7 +17,7 @@ commands = sh -c '(find . -not \( -type d -name .?\* -prune \) \
\( -type d -name "__pycache__" -or -type f -name "*.py[co]" \) \
-print0) | xargs -0 rm -rf'
stestr run {posargs}
-whitelist_externals = sh
+allowlist_externals = sh
passenv = SWIFT_* *_proxy
[testenv:pep8]
@@ -45,7 +45,7 @@ basepython = python3
setenv =
OS_TEST_PATH=test.functional
PYTHON=coverage run --source swiftclient --parallel-mode
-whitelist_externals =
+allowlist_externals =
coverage
rm
commands =
@@ -59,13 +59,14 @@ commands =
[testenv:py2func]
basepython=python2
setenv = {[testenv:func]setenv}
-whitelist_externals = {[testenv:func]whitelist_externals}
+allowlist_externals = {[testenv:func]allowlist_externals}
commands = {[testenv:func]commands}
[testenv:docs]
basepython = python3
usedevelop = False
-deps = -r{toxinidir}/doc/requirements.txt
+deps = -c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master}
+ -r{toxinidir}/doc/requirements.txt
commands=
sphinx-build -W -b html doc/source doc/build/html -W
@@ -99,13 +100,14 @@ commands = bindep test
[testenv:releasenotes]
basepython = python3
usedevelop = False
-deps = -r{toxinidir}/doc/requirements.txt
+deps = -c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master}
+ -r{toxinidir}/doc/requirements.txt
commands = sphinx-build -a -W -E -d releasenotes/build/doctrees -b html releasenotes/source releasenotes/build/html
[testenv:pdf-docs]
basepython = python3
deps = {[testenv:docs]deps}
-whitelist_externals =
+allowlist_externals =
make
commands =
sphinx-build -W -b latex doc/source doc/build/pdf