From b3ca32a4f9e78929dd32ca78a12c76930288e346 Mon Sep 17 00:00:00 2001 From: Christian Eisenkopf Date: Tue, 11 Jun 2024 09:46:55 +0200 Subject: [PATCH] Fixed parsing bug when roadtx is run inside docker --- roadtx/roadtools/roadtx/main.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/roadtx/roadtools/roadtx/main.py b/roadtx/roadtools/roadtx/main.py index 3ac4978..97f63e9 100644 --- a/roadtx/roadtools/roadtx/main.py +++ b/roadtx/roadtools/roadtx/main.py @@ -1115,13 +1115,16 @@ def main(): if args.verbose: print("[debug] Reading token value from stdin.") tokendata = sys.stdin.read() - # Describing saved token file args.tokenfile - elif os.path.exists(args.tokenfile): - if args.verbose: - print("[debug] Reading token value from file '%s'." % (args.tokenfile)) - f = open(args.tokenfile, "r") - tokendata = f.read() - f.close() + # Maybe some of the above had already tokendata set. But in Docker isatty is false.. so check if tokendata is None at this point + # Otherwise read it from default file + if not tokendata or tokendata == "": + # Describing saved token file args.tokenfile + if os.path.exists(args.tokenfile): + if args.verbose: + print("[debug] Reading token value from file '%s'." % (args.tokenfile)) + f = open(args.tokenfile, "r") + tokendata = f.read() + f.close() if tokendata[0] == '{': # assume json object tokenobject = json.loads(tokendata)