Revision a2defd86 tools/store
b/tools/store | ||
---|---|---|
63 | 63 |
return _cli_commands[name] |
64 | 64 |
|
65 | 65 |
class Command(object): |
66 |
def __init__(self, argv): |
|
67 |
parser = OptionParser() |
|
66 |
def __init__(self, name, argv):
|
|
67 |
parser = OptionParser('%%prog %s [options] %s' % (name, self.syntax))
|
|
68 | 68 |
parser.add_option('--host', dest='host', metavar='HOST', |
69 | 69 |
default=DEFAULT_HOST, help='use server HOST') |
70 | 70 |
parser.add_option('--user', dest='user', metavar='USERNAME', |
... | ... | |
166 | 166 |
params['until'] = int(_time.mktime(t)) |
167 | 167 |
|
168 | 168 |
detail = 'json' |
169 |
l = self.client.list_objects(container, detail, params, headers) |
|
169 |
#if request with meta quering disable trash filtering |
|
170 |
show_trashed = True if self.meta else False |
|
171 |
l = self.client.list_objects(container, detail, params, headers, |
|
172 |
include_trashed = show_trashed) |
|
170 | 173 |
print_list(l, detail=self.detail) |
171 | 174 |
|
172 | 175 |
@cli_command('meta') |
... | ... | |
417 | 420 |
default=True, help='append data') |
418 | 421 |
parser.add_option('--start', action='store', |
419 | 422 |
dest='start', |
420 |
default=None, help='range of data to be updated')
|
|
423 |
default=None, help='starting offest to be updated')
|
|
421 | 424 |
parser.add_option('--range', action='store', dest='content-range', |
422 | 425 |
default=None, help='range of data to be updated') |
423 | 426 |
parser.add_option('--chunked', action='store_true', dest='chunked', |
... | ... | |
434 | 437 |
parser.add_option('--sharing', action='store', |
435 | 438 |
dest='sharing', default=None, |
436 | 439 |
help='define sharing object policy') |
440 |
parser.add_option('--touch', action='store_true', |
|
441 |
dest='touch', default=False, |
|
442 |
help='change file properties') |
|
443 |
|
|
437 | 444 |
|
438 | 445 |
|
439 | 446 |
def execute(self, path, srcpath='-', *args): |
... | ... | |
460 | 467 |
|
461 | 468 |
container, sep, object = path.partition('/') |
462 | 469 |
|
463 |
f = srcpath != '-' and open(srcpath) or stdin |
|
464 |
chunked = (self.chunked or f == stdin) and True or False |
|
470 |
f = None |
|
471 |
chunked = False |
|
472 |
if not self.touch: |
|
473 |
f = srcpath != '-' and open(srcpath) or stdin |
|
474 |
chunked = (self.chunked or f == stdin) and True or False |
|
465 | 475 |
self.client.update_object(container, object, f, chunked=chunked, |
466 | 476 |
headers=headers) |
467 |
f.close() |
|
477 |
if f: |
|
478 |
f.close() |
|
468 | 479 |
|
469 | 480 |
@cli_command('move', 'mv') |
470 | 481 |
class MoveObject(Command): |
... | ... | |
481 | 492 |
self.client.move_object(src_container, src_object, dst_container, |
482 | 493 |
dst_object, headers) |
483 | 494 |
|
484 |
@cli_command('remove', 'rm')
|
|
495 |
@cli_command('remove') |
|
485 | 496 |
class TrashObject(Command): |
486 | 497 |
syntax = '<container>/<object>' |
487 | 498 |
description = 'trashes an object' |
... | ... | |
599 | 610 |
print_usage() |
600 | 611 |
exit(1) |
601 | 612 |
|
602 |
cmd = cls(argv[2:]) |
|
613 |
cmd = cls(name, argv[2:])
|
|
603 | 614 |
|
604 | 615 |
try: |
605 | 616 |
cmd.execute(*cmd.args) |
606 | 617 |
except TypeError, e: |
607 |
cmd.parser.usage = '%%prog %s [options] %s' % (name, cmd.syntax) |
|
608 | 618 |
cmd.parser.print_help() |
609 | 619 |
exit(1) |
610 | 620 |
except Fault, f: |
Also available in: Unified diff