-
Notifications
You must be signed in to change notification settings - Fork 73
Expand file tree
/
Copy pathclear.py
More file actions
59 lines (48 loc) · 1.79 KB
/
clear.py
File metadata and controls
59 lines (48 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# -*- encoding: utf-8 -*-
"""
KERI
keri.kli.commands.escrow module
"""
import argparse
from hio.base import doing
from keri import help
from keri.app.cli.common import existing
from keri.vdr import viring
logger = help.ogler.getLogger()
parser = argparse.ArgumentParser(description='Clear escrows')
parser.set_defaults(handler=lambda args: handler(args),
transferable=True)
parser.add_argument('--name', '-n', help='keystore name and file location of KERI keystore', required=True)
parser.add_argument('--base', '-b', help='additional optional prefix to file location of KERI keystore',
required=False, default="")
parser.add_argument('--passcode', '-p', help='21 character encryption passcode for keystore (is not saved)',
dest="bran", default=None) # passcode => bran
parser.add_argument('--force', action="store_true", required=False,
help='True means perform clear without prompting the user')
def handler(args):
if not args.force:
print()
print("This command will clear all escrows and is not reversible.")
print()
yn = input("Are you sure you want to continue? [y|N]: ")
if yn not in ("y", "Y"):
print("...exiting")
return []
kwa = dict(args=args)
return [doing.doify(clear, **kwa)]
def clear(tymth, tock=0.0, **opts):
""" Command line clear handler
"""
_ = (yield tock)
args = opts["args"]
name = args.name
base = args.base
bran = args.bran
logger.setLevel("INFO")
with existing.existingHby(name=name, base=base, bran=bran) as hby:
hby.db.clearEscrows()
reger = viring.Reger(name=hby.name, db=hby.db, temp=False)
try:
reger.clearEscrows()
finally:
reger.close()