From a2defd864f08fdc7c155e5bdd3b481a0fdac52b3 Mon Sep 17 00:00:00 2001 From: Sofia Papagiannaki Date: Wed, 22 Jun 2011 18:08:40 +0300 Subject: [PATCH] - display command usage instead of client usage - include trashed objects in listing using meta filtering Refs #576 --- pithos/lib/client.py | 4 +--- tools/store | 30 ++++++++++++++++++++---------- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/pithos/lib/client.py b/pithos/lib/client.py index cb0ac5e..3e03941 100644 --- a/pithos/lib/client.py +++ b/pithos/lib/client.py @@ -347,11 +347,9 @@ class Client(object): def update_object(self, container, object, f=stdin, chunked=False, blocksize=1024, headers=None): - if not f: - return path = '/%s/%s' % (container, object) if not chunked and f != stdin: - data = f.read() + data = f.read() if f else None self.post(path, data, headers=headers) else: self._chunked_transfer(path, 'POST', f, headers=headers, diff --git a/tools/store b/tools/store index 5ed0225..0cd55df 100755 --- a/tools/store +++ b/tools/store @@ -63,8 +63,8 @@ def class_for_cli_command(name): return _cli_commands[name] class Command(object): - def __init__(self, argv): - parser = OptionParser() + def __init__(self, name, argv): + parser = OptionParser('%%prog %s [options] %s' % (name, self.syntax)) parser.add_option('--host', dest='host', metavar='HOST', default=DEFAULT_HOST, help='use server HOST') parser.add_option('--user', dest='user', metavar='USERNAME', @@ -166,7 +166,10 @@ class List(Command): params['until'] = int(_time.mktime(t)) detail = 'json' - l = self.client.list_objects(container, detail, params, headers) + #if request with meta quering disable trash filtering + show_trashed = True if self.meta else False + l = self.client.list_objects(container, detail, params, headers, + include_trashed = show_trashed) print_list(l, detail=self.detail) @cli_command('meta') @@ -417,7 +420,7 @@ class UpdateObject(Command): default=True, help='append data') parser.add_option('--start', action='store', dest='start', - default=None, help='range of data to be updated') + default=None, help='starting offest to be updated') 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', @@ -434,6 +437,10 @@ class UpdateObject(Command): parser.add_option('--sharing', action='store', dest='sharing', default=None, help='define sharing object policy') + parser.add_option('--touch', action='store_true', + dest='touch', default=False, + help='change file properties') + def execute(self, path, srcpath='-', *args): @@ -460,11 +467,15 @@ class UpdateObject(Command): container, sep, object = path.partition('/') - f = srcpath != '-' and open(srcpath) or stdin - chunked = (self.chunked or f == stdin) and True or False + f = None + chunked = False + if not self.touch: + f = srcpath != '-' and open(srcpath) or stdin + chunked = (self.chunked or f == stdin) and True or False self.client.update_object(container, object, f, chunked=chunked, headers=headers) - f.close() + if f: + f.close() @cli_command('move', 'mv') class MoveObject(Command): @@ -481,7 +492,7 @@ class MoveObject(Command): self.client.move_object(src_container, src_object, dst_container, dst_object, headers) -@cli_command('remove', 'rm') +@cli_command('remove') class TrashObject(Command): syntax = '/' description = 'trashes an object' @@ -599,12 +610,11 @@ def main(): print_usage() exit(1) - cmd = cls(argv[2:]) + cmd = cls(name, argv[2:]) try: cmd.execute(*cmd.args) except TypeError, e: - cmd.parser.usage = '%%prog %s [options] %s' % (name, cmd.syntax) cmd.parser.print_help() exit(1) except Fault, f: -- 1.7.10.4