2020-11-10 08:12:43 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
from os import environ
|
|
|
|
from sys import argv
|
|
|
|
|
2023-03-28 20:52:10 +00:00
|
|
|
from bundlewrap.metagen import NodeMetadataProxy
|
2023-02-05 16:30:58 +00:00
|
|
|
from bundlewrap.exceptions import FaultUnavailable
|
2020-11-10 08:12:43 +00:00
|
|
|
from bundlewrap.repo import Repository
|
|
|
|
from bundlewrap.utils import Fault
|
|
|
|
|
|
|
|
path = environ.get('BW_REPO_PATH', '.')
|
|
|
|
repo = Repository(path)
|
|
|
|
|
|
|
|
def print_faults(dictionary, keypath=[]):
|
2020-11-10 11:49:47 +00:00
|
|
|
for key, value in sorted(dictionary.items()):
|
2020-11-10 08:12:43 +00:00
|
|
|
if isinstance(value, Fault):
|
|
|
|
try:
|
|
|
|
resolved_fault = value.value
|
|
|
|
except FaultUnavailable:
|
|
|
|
print('{}/{}: [permission denied]'.format('/'.join(keypath), key))
|
|
|
|
else:
|
|
|
|
if '\n' not in resolved_fault:
|
|
|
|
print('{}/{}: {}'.format('/'.join(keypath), key, value))
|
2023-03-28 20:52:10 +00:00
|
|
|
elif isinstance(value, (list, set, tuple)):
|
|
|
|
print_faults(dict(enumerate(value)), keypath=keypath+[key])
|
|
|
|
elif isinstance(value, (dict, NodeMetadataProxy)):
|
2020-11-10 08:12:43 +00:00
|
|
|
print_faults(value, keypath=keypath+[key])
|
|
|
|
|
|
|
|
if len(argv) == 1:
|
|
|
|
print('node name missing')
|
|
|
|
exit(1)
|
|
|
|
|
|
|
|
node = repo.get_node(argv[1])
|
2023-03-28 20:52:10 +00:00
|
|
|
print_faults({
|
|
|
|
'password': node.password,
|
|
|
|
'metadata': node.metadata,
|
|
|
|
})
|