Revision 91fc9266 snf-pithos-app/pithos/api/management/commands/file-show.py
b/snf-pithos-app/pithos/api/management/commands/file-show.py | ||
---|---|---|
38 | 38 |
from snf_django.management.commands import SynnefoCommand |
39 | 39 |
from snf_django.management import utils |
40 | 40 |
|
41 |
from pithos.api.util import get_backend, update_public_meta |
|
41 |
from pithos.api.util import get_backend, update_public_meta, is_uuid
|
|
42 | 42 |
|
43 | 43 |
|
44 | 44 |
class Command(SynnefoCommand): |
45 |
args = "<account> <container> <object>" |
|
45 |
args = "<account> <container> <object> or <object uuid>"
|
|
46 | 46 |
help = """Show file information""" |
47 | 47 |
|
48 | 48 |
option_list = SynnefoCommand.option_list + ( |
... | ... | |
52 | 52 |
make_option("--domain", dest="domain", |
53 | 53 |
default='pithos', |
54 | 54 |
help="Show file attributes from the specific domain."), |
55 |
make_option("--hashmap", dest="hashmap", |
|
56 |
default=False, |
|
57 |
action='store_true', |
|
58 |
help="Display also the object hashmap") |
|
55 | 59 |
) |
56 | 60 |
|
57 | 61 |
def handle(self, *args, **options): |
58 |
if len(args) != 3: |
|
59 |
raise CommandError("Invalid number of arguments") |
|
60 |
|
|
61 | 62 |
success_status = False |
62 | 63 |
try: |
63 | 64 |
b = get_backend() |
64 | 65 |
b.pre_exec() |
65 | 66 |
|
66 |
account, container, name = args |
|
67 |
if len(args) == 3: |
|
68 |
account, container, name = args |
|
69 |
elif len(args) == 1: |
|
70 |
if not is_uuid(args[0]): |
|
71 |
raise CommandError('Invalid UUID') |
|
72 |
try: |
|
73 |
account, container, name = b.get_uuid( |
|
74 |
None, args[0], check_permissions=False) |
|
75 |
except NameError: |
|
76 |
raise CommandError('Unknown UUID') |
|
77 |
else: |
|
78 |
raise CommandError("Invalid number of arguments") |
|
67 | 79 |
|
68 | 80 |
kv = b.get_object_meta(account, account, container, name, |
69 | 81 |
options['domain'], options['obj_version']) |
... | ... | |
80 | 92 |
if public is not None: |
81 | 93 |
update_public_meta(public, kv) |
82 | 94 |
|
83 |
kv['hashmap'] = b.get_object_hashmap(account, account, container, |
|
84 |
name, |
|
85 |
options['obj_version'])[-1] |
|
95 |
if options['hashmap']: |
|
96 |
_, kv['hashmap'] = b.get_object_hashmap(account, account, |
|
97 |
container, name, |
|
98 |
options['obj_version']) |
|
86 | 99 |
|
87 | 100 |
utils.pprint_table(self.stdout, [kv.values()], kv.keys(), |
88 | 101 |
options["output_format"], vertical=True) |
Also available in: Unified diff