bundlewrap/scripts/passwords-for

31 lines
928 B
Python
Executable file

#!/usr/bin/env python3
from os import environ
from sys import argv
from bundlewrap.exceptions import FaultUnavailable
from bundlewrap.repo import Repository
from bundlewrap.utils import Fault
path = environ.get('BW_REPO_PATH', '.')
repo = Repository(path)
def print_faults(dictionary, keypath=[]):
for key, value in sorted(dictionary.items()):
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))
elif isinstance(value, dict):
print_faults(value, keypath=keypath+[key])
if len(argv) == 1:
print('node name missing')
exit(1)
node = repo.get_node(argv[1])
print_faults(node.metadata)