Commit e5401a16 authored by Sofia Papagiannaki's avatar Sofia Papagiannaki

pithos-sh: introduce hashmap option in get command to retrieve an object's...

pithos-sh: introduce hashmap option in get command to retrieve an object's hashmap instead of data & fix update command (manifest, range & offset options)

Refs: #2062
parent 5d61c996
......@@ -356,13 +356,13 @@ class OOS_Client(Client):
data = minidom.parseString(data)
return data
def retrieve_object_hashmap(self, container, object, params={},
def retrieve_object_hashmap(self, container, object, format='json', params={},
account=None, **headers):
"""returns the hashmap representing object's data"""
args = locals().copy()
for elem in ['self', 'container', 'object']:
return self.retrieve_object(container, object, format='json', **args)
if not params:
params = {}
return self.retrieve_object(container, object, params, format, account, **headers)
def create_directory_marker(self, container, object, account=None):
"""creates a dierectory marker"""
......@@ -291,10 +291,13 @@ class GetObject(Command):
parser.add_option('--versionlist', action='store_true',
dest='versionlist', default=False,
help='get the full object version list')
parser.add_option('--hashmap', action='store_true',
dest='hashmap', default=False,
help='get the object hashmap instead')
def execute(self, path):
attrs = ['if_match', 'if_none_match', 'if_modified_since',
'if_unmodified_since', 'hashmap']
args = self._build_args(attrs)
args['format'] = 'json' if self.detail else 'text'
if self.range:
......@@ -313,11 +316,17 @@ class GetObject(Command):
elif self.version:
data = self.client.retrieve_object_version(container, object,
self.version, **args)
elif self.hashmap:
if 'detail' in args.keys():
self.detail = True
data = self.client.retrieve_object_hashmap(container, object, **args)
data = self.client.retrieve_object(container, object, **args)
f = open(self.file, 'w') if self.file else stdout
if self.detail:
if self.detail or type(data) == types.DictionaryType:
if self.versionlist:
print_versions(data, f=f)
......@@ -358,7 +367,7 @@ class PutObject(Command):
# help='use for large file support')
parser.add_option('--manifest', action='store',
dest='x_object_manifest', default=None,
help='upload a manifestation file')
help='provide object parts prefix in <container>/<object> form')
parser.add_option('--content-type', action='store',
dest='content_type', default=None,
help='create object with specific content type')
......@@ -485,7 +494,7 @@ class UpdateObject(Command):
parser.add_option('--offset', action='store',
default=None, help='starting offest to be updated')
parser.add_option('--range', action='store', dest='content-range',
parser.add_option('--range', action='store', dest='content_range',
default=None, help='range of data to be updated')
parser.add_option('--chunked', action='store_true', dest='chunked',
default=False, help='set chunked transfer mode')
......@@ -526,7 +535,8 @@ class UpdateObject(Command):
attrs = ['content_encoding', 'content_disposition', 'x_object_sharing',
'x_object_public', 'replace']
'x_object_public', 'x_object_manifest', 'replace', 'offset',
args = self._build_args(attrs)
if self.no_sharing:
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment