Changeset - 3e09cfb12e3a
[Not reviewed]
default
0 1 0
Laman - 4 years ago 2020-04-13 12:13:23

redirected errors to stderr
1 file changed with 2 insertions and 2 deletions:
0 comments (0 inline, 0 general)
src/cli.py
Show inline comments
 
@@ -51,40 +51,40 @@ def _generate(args):
 
	if args.secret:  # provided as a positional argument
 
		secret = args.secret
 
	elif sys.stdin.isatty():  # input from terminal
 
		secret = input("Enter your secret:\n")
 
	else:  # redirected from other source
 
		secret = sys.stdin.read()
 

	
 
	try:
 
		shares = generate(secret, args.k, args.n, encoding)
 
		for s in shares:
 
			print(s)
 
	except SException as e:
 
		print(e)
 
		print(e, file=sys.stderr)
 

	
 

	
 
def _reconstruct(args):
 
	encoding = get_encoding(args)
 

	
 
	if args.share:  # provided as a positional argument
 
		shares = args.share
 
	elif sys.stdin.isatty():  # input from terminal
 
		print("Enter the shares, each on separate line, end with an empty line:")
 
		shares = []
 
		while not shares or shares[-1]:
 
			shares.append(input())
 
		shares.pop()
 
	else:  # redirected from other source
 
		shares = sys.stdin.read().split()
 

	
 
	try:
 
		print(reconstruct(*shares, encoding=encoding, raw=args.raw))
 
	except SException as e:
 
		print(e)
 
		print(e, file=sys.stderr)
 

	
 

	
 
def get_encoding(args):
 
	if args.hex: return "hex"
 
	elif args.b32: return "b32"
 
	elif args.b64: return "b64"
 
	else: return ""
0 comments (0 inline, 0 general)