diff options
author | José Padilla <jpadilla@webapplicate.com> | 2015-04-15 16:37:20 -0400 |
---|---|---|
committer | José Padilla <jpadilla@webapplicate.com> | 2015-04-15 16:37:20 -0400 |
commit | 60ee6f23b30f766620266aae90c751ac2d544f03 (patch) | |
tree | f9c024c38adacb0f33afb64da46243fecddf678e | |
parent | 5ecc66d71a47cf714be5984ecefd2d81058b033f (diff) | |
parent | 7d15be7fa28324ad7ac34390c3d724fa2e728385 (diff) | |
download | pyjwt-60ee6f23b30f766620266aae90c751ac2d544f03.tar.gz |
Merge pull request #128 from nielsdraaisma/master
Fixed command line encoding
-rwxr-xr-x | bin/jwt | 27 |
1 files changed, 14 insertions, 13 deletions
@@ -71,21 +71,22 @@ The exp key is special and can take an offset to current Unix time. options, arguments = p.parse_args() if len(arguments) > 0 or not sys.stdin.isatty(): - # Try to decode - try: - if not sys.stdin.isatty(): - token = sys.stdin.read() - else: - token = arguments[0] + if len(arguments) == 1 and ( options.verify is False or options.key is not None ): + # Try to decode + try: + if not sys.stdin.isatty(): + token = sys.stdin.read() + else: + token = arguments[0] - token = token.encode('utf-8') - data = jwt.decode(token, key=options.key, verify=options.verify) + token = token.encode('utf-8') + data = jwt.decode(token, key=options.key, verify=options.verify) - print(json.dumps(data)) - sys.exit(0) - except jwt.DecodeError as e: - print(e) - sys.exit(1) + print(json.dumps(data)) + sys.exit(0) + except jwt.DecodeError as e: + print(e) + sys.exit(1) # Try to encode if options.key is None: |