def _main(argv): ec = 0 options, args = _check_options(argv) if options == None: ec = 2 else: audience = options.get('audience', None) jti = options.get('jti', None) issuer = options.get('issuer', None) lifetime = options.get('lifetime', None) principle = options.get('principle', None) if lifetime != None: try: lifetime = int(lifetime) except ValueError: print >>sys.stderr, "Bad value given for lifetime" ec = 2 if ec == 0: claims = Claims(audience=audience, jti=jti, issuer=issuer, lifetime=lifetime, principle=principle) print claims.get_encoded() if ec == 2: _usage() return ec
def _main(argv): ec = 0 options, args = _check_options(argv) if options == None: ec = 2 else: if not 'cmdline' in options: ec = 2 else: if options['cmdline'] == True: if len(args) != 1: ec = 2 else: encoded_line = args[0] else: if len(args) != 1: ec = 2 else: if args[0] == '-': lines = sys.stdin.readlines() else: f = open(args[0]) lines = f.readlines() f.close() encoded_line = ''.join(lines) if ec == 0: claims = Claims(encoded_line) if not 'field' in options: print claims.get_json() else: field = options['field'] if not claims.exists(field): print >>sys.stderr, 'Field \'%s\' not found' % field ec = 1 else: print claims.get_field(field) if ec == 2: _usage() return ec