diff options
author | http://j3h.us/ <http://j3h.us/@lillialexis.local> | 2007-11-15 15:46:21 +0000 |
---|---|---|
committer | http://j3h.us/ <http://j3h.us/@lillialexis.local> | 2007-11-15 15:46:21 +0000 |
commit | d3db4a6205091db2ba435363e722bb1ce5af9283 (patch) | |
tree | 5c18109bd90b7e65408e6536aafe4ef1463a88c8 /examples | |
parent | 64be544894c1280b0e5c735c931e21749ac0de4e (diff) | |
download | openid-d3db4a6205091db2ba435363e722bb1ce5af9283.tar.gz |
[project @ Make discover example script prettier]
Diffstat (limited to 'examples')
-rw-r--r-- | examples/discover | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/examples/discover b/examples/discover index 8490aef..9b74e8a 100644 --- a/examples/discover +++ b/examples/discover @@ -1,5 +1,6 @@ #!/usr/bin/env python from openid.consumer.discover import discover, DiscoveryFailure +from openid.fetchers import HTTPFetchingError names = [["server_url", "Server URL "], ["local_id", "Local ID "], @@ -8,18 +9,23 @@ names = [["server_url", "Server URL "], def show_services(user_input, normalized, services): print " Claimed identifier:", normalized - print " Discovered services:" - for n, service in enumerate(services): - print " %s." % (n,) - for attr, name in names: - val = getattr(service, attr, None) - if val is not None: - print " %s: %s" % (name, val) + if services: + print " Discovered OpenID services:" + for n, service in enumerate(services): + print " %s." % (n,) + for attr, name in names: + val = getattr(service, attr, None) + if val is not None: + print " %s: %s" % (name, val) - print " Type URIs:" - for type_uri in service.type_uris: - print " *", type_uri + print " Type URIs:" + for type_uri in service.type_uris: + print " *", type_uri + print + + else: + print " No OpenID services found" print if __name__ == "__main__": @@ -31,6 +37,10 @@ if __name__ == "__main__": try: normalized, services = discover(user_input) except DiscoveryFailure, why: - print "Discovery failed:", str(why) + print "Discovery failed:", why + print + except HTTPFetchingError, why: + print "HTTP request failed:", why + print else: show_services(user_input, normalized, services) |