summaryrefslogtreecommitdiff
path: root/swiftclient/shell.py
diff options
context:
space:
mode:
authorAlistair Coles <alistair.coles@hpe.com>2016-09-08 14:15:40 +0100
committerAlistair Coles <alistair.coles@hpe.com>2016-09-14 16:24:22 +0100
commit4c955751d340a8f71a2eebdb3c58d90b36874a66 (patch)
tree125940417cca382c0a34804aa53a16685fe0cf0c /swiftclient/shell.py
parent89ff29e788479334c218801beb0538b4a6bddf23 (diff)
downloadpython-swiftclient-4c955751d340a8f71a2eebdb3c58d90b36874a66.tar.gz
Make tempurl command check for valid object path
If the supplied path is not of the form /v1/a/c/o then swift tempurl subcommand will now return an error message. Also removes redundant check for seconds parameter being an int from shell.py because the same check is made when calling utils.generate_temp_url. Drive-by fix for missing param definition for generate_temp_url. Change-Id: I41f4389948b01fadaa5fc4939ea12e0ed2167345 Related-Change: I0fb2ce125fe12d660e4deb778265016bdd5ff31b
Diffstat (limited to 'swiftclient/shell.py')
-rwxr-xr-xswiftclient/shell.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/swiftclient/shell.py b/swiftclient/shell.py
index e1a5a8d..4e3ed0a 100755
--- a/swiftclient/shell.py
+++ b/swiftclient/shell.py
@@ -1239,17 +1239,17 @@ def st_tempurl(parser, args, thread_manager):
parsed = urlparse(path)
- try:
- seconds = int(seconds)
- except ValueError:
- thread_manager.error('Seconds must be an integer')
- return
if method.upper() not in ['GET', 'PUT', 'HEAD', 'POST', 'DELETE']:
thread_manager.print_msg('WARNING: Non default HTTP method %s for '
'tempurl specified, possibly an error' %
method.upper())
- path = generate_temp_url(parsed.path, seconds, key, method,
- absolute=options['absolute_expiry'])
+ try:
+ path = generate_temp_url(parsed.path, seconds, key, method,
+ absolute=options['absolute_expiry'])
+ except ValueError as err:
+ thread_manager.error(err)
+ return
+
if parsed.scheme and parsed.netloc:
url = "%s://%s%s" % (parsed.scheme, parsed.netloc, path)
else: