Revision 7812e1f9 tools/store
b/tools/store | ||
---|---|---|
210 | 210 |
if getattr(self, 'until'): |
211 | 211 |
t = _time.strptime(self.until, self.format) |
212 | 212 |
args['until'] = int(_time.mktime(t)) |
213 |
|
|
213 |
|
|
214 | 214 |
if object: |
215 | 215 |
meta = self.client.retrieve_object_metadata(container, object, |
216 | 216 |
self.restricted, |
... | ... | |
372 | 372 |
help='file descriptor to read from (pass - for standard input)') |
373 | 373 |
parser.add_option('--public', action='store_true', |
374 | 374 |
dest='x_object_public', default=False, |
375 |
help='make object publicly accessible (\'True\'/\'False\')')
|
|
375 |
help='make object publicly accessible') |
|
376 | 376 |
|
377 | 377 |
def execute(self, path, *args): |
378 | 378 |
if path.find('=') != -1: |
... | ... | |
416 | 416 |
|
417 | 417 |
@cli_command('copy', 'cp') |
418 | 418 |
class CopyObject(Command): |
419 |
syntax = '<src container>/<src object> [<dst container>/]<dst object>' |
|
419 |
syntax = '<src container>/<src object> [<dst container>/]<dst object> [key=val] [...]'
|
|
420 | 420 |
description = 'copy an object to a different location' |
421 | 421 |
|
422 | 422 |
def add_options(self, parser): |
423 | 423 |
parser.add_option('--version', action='store', |
424 | 424 |
dest='version', default=False, |
425 | 425 |
help='copy specific version') |
426 |
parser.add_option('--public', action='store', |
|
427 |
dest='public', default=None,
|
|
428 |
help='publish/unpublish object (\'True\'/\'False\')')
|
|
426 |
parser.add_option('--public', action='store_true',
|
|
427 |
dest='public', default=False,
|
|
428 |
help='make object publicly accessible')
|
|
429 | 429 |
|
430 |
def execute(self, src, dst): |
|
430 |
def execute(self, src, dst, *args):
|
|
431 | 431 |
src_container, sep, src_object = src.partition('/') |
432 | 432 |
dst_container, sep, dst_object = dst.partition('/') |
433 |
|
|
434 |
#prepare user defined meta |
|
435 |
meta = {} |
|
436 |
for arg in args: |
|
437 |
key, sep, val = arg.partition('=') |
|
438 |
meta[key] = val |
|
439 |
|
|
433 | 440 |
if not sep: |
434 | 441 |
dst_container = src_container |
435 | 442 |
dst_object = dst |
436 |
version = getattr(self, 'version') |
|
437 |
headers = None |
|
438 |
if version: |
|
439 |
headers = {} |
|
440 |
headers['X_SOURCE_VERSION'] = version |
|
441 |
if self.public and self.nopublic: |
|
442 |
raise Fault('Conflicting options') |
|
443 |
if self.public not in ['True', 'False', None]: |
|
444 |
raise Fault('Not acceptable value for public') |
|
445 |
public = eval(self.public) if self.public else None |
|
443 |
|
|
446 | 444 |
self.client.copy_object(src_container, src_object, dst_container, |
447 |
dst_object, public, headers)
|
|
445 |
dst_object, meta, self.public, self.version, **meta)
|
|
448 | 446 |
|
449 | 447 |
@cli_command('set') |
450 | 448 |
class SetMeta(Command): |
... | ... | |
503 | 501 |
parser.add_option('-f', action='store', |
504 | 502 |
dest='srcpath', default=None, |
505 | 503 |
help='file descriptor to read from: pass - for standard input') |
506 |
parser.add_option('--public', action='store', |
|
504 |
parser.add_option('--public', action='store_true',
|
|
507 | 505 |
dest='x_object_public', default=False, |
508 |
help='publish/unpublish object (\'True\'/\'False\')')
|
|
506 |
help='make object publicly accessible')
|
|
509 | 507 |
|
510 | 508 |
def execute(self, path, *args): |
511 | 509 |
if path.find('=') != -1: |
... | ... | |
545 | 543 |
description = 'move an object to a different location' |
546 | 544 |
|
547 | 545 |
def add_options(self, parser): |
548 |
parser.add_option('--public', action='store', |
|
549 |
dest='public', default=None, |
|
550 |
help='publish/unpublish object (\'True\'/\'False\')') |
|
546 |
parser.add_option('--version', action='store', |
|
547 |
dest='version', default=None, |
|
548 |
help='move a specific object version') |
|
549 |
parser.add_option('--public', action='store_true', |
|
550 |
dest='public', default=False, |
|
551 |
help='make object publicly accessible') |
|
551 | 552 |
|
552 |
def execute(self, src, dst): |
|
553 |
def execute(self, src, dst, *args):
|
|
553 | 554 |
src_container, sep, src_object = src.partition('/') |
554 | 555 |
dst_container, sep, dst_object = dst.partition('/') |
555 | 556 |
if not sep: |
556 | 557 |
dst_container = src_container |
557 | 558 |
dst_object = dst |
558 |
if self.public not in ['True', 'False', None]: |
|
559 |
raise Fault('Not acceptable value for public') |
|
560 |
public = eval(self.public) if self.public else None |
|
559 |
|
|
560 |
#prepare user defined meta |
|
561 |
meta = {} |
|
562 |
for arg in args: |
|
563 |
key, sep, val = arg.partition('=') |
|
564 |
meta[key] = val |
|
565 |
|
|
561 | 566 |
self.client.move_object(src_container, src_object, dst_container, |
562 |
dst_object, public, headers)
|
|
567 |
dst_object, meta, self.public, self.version)
|
|
563 | 568 |
|
564 | 569 |
@cli_command('remove') |
565 | 570 |
class TrashObject(Command): |
... | ... | |
741 | 746 |
|
742 | 747 |
cmd = cls(name, argv[2:]) |
743 | 748 |
|
744 |
#cmd.execute(*cmd.args)
|
|
745 |
try: |
|
746 |
cmd.execute(*cmd.args) |
|
747 |
except TypeError, e: |
|
748 |
cmd.parser.print_help() |
|
749 |
exit(1) |
|
750 |
except Fault, f: |
|
751 |
status = f.status and '%s ' % f.status or '' |
|
752 |
print '%s%s' % (status, f.data) |
|
749 |
cmd.execute(*cmd.args) |
|
750 |
#try:
|
|
751 |
# cmd.execute(*cmd.args)
|
|
752 |
#except TypeError, e:
|
|
753 |
# cmd.parser.print_help()
|
|
754 |
# exit(1)
|
|
755 |
#except Fault, f:
|
|
756 |
# status = f.status and '%s ' % f.status or ''
|
|
757 |
# print '%s%s' % (status, f.data)
|
|
753 | 758 |
|
754 | 759 |
if __name__ == '__main__': |
755 | 760 |
main() |
Also available in: Unified diff