Changeset e83f2f2 for fedd/federation/client_lib.py
- Timestamp:
- Dec 14, 2010 6:58:28 PM (13 years ago)
- Branches:
- axis_example, compt_changes, info-ops, master
- Children:
- c092b7f
- Parents:
- 2627eb3
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
fedd/federation/client_lib.py
r2627eb3 re83f2f2 7 7 8 8 from string import join 9 from datetime import datetime 9 10 10 11 … … 31 32 callback=self.expand_file, 32 33 type="string", help="my certificate file") 34 self.add_option("--auth_log", action="callback", dest="auth_log", 35 callback=self.expand_file, default=None, 36 type="string", help="Log authentication decisions to this file") 33 37 self.add_option("--abac", action="callback", dest="abac_dir", 34 38 callback=self.expand_file, … … 53 57 const=sys.stderr, help="Print SOAP exchange to stderr") 54 58 55 def exit_with_fault(exc, out=sys.stderr): 59 def log_authentication(fn, action, outcome, proof): 60 f = open(fn, 'a') 61 print >>f, '%s %s at %s' % (action, outcome, datetime.now()) 62 if isinstance(proof, list): 63 for p in proof: 64 print >>f, p.to_xml() 65 else: 66 print >>f, proof.to_xml() 67 f.close() 68 69 70 def exit_with_fault(exc, action, opts, out=sys.stderr): 56 71 """ 57 72 Print an error message and exit. exc is the RPCException that caused the … … 72 87 code = -1 73 88 89 if exc.code == service_error.access and opts.auth_log: 90 try: 91 log_authentication(opts.auth_log, action, 'failed', exc.proof) 92 except EnvironmentError, e: 93 print >>sys.stderr, "Failed to log to %s: %s" % \ 94 (e.filename, e.strerror) 95 74 96 print>>out, codestr 75 97 print>>out, "Description: %s" % exc.desc … … 81 103 XMLPRC calls. 82 104 """ 83 def __init__(self, desc=None, code=None, errstr=None ):105 def __init__(self, desc=None, code=None, errstr=None, proof=None): 84 106 RuntimeError.__init__(self) 85 107 self.desc = desc … … 87 109 else: self.code = -1 88 110 self.errstr = errstr 111 self.proof = proof 89 112 90 113 class CertificateMismatchError(RuntimeError): pass … … 208 231 except service_error, e: 209 232 raise RPCException(desc=e.desc, code=e.code, 210 errstr=e.code_string() )233 errstr=e.code_string(), proof=e.proof) 211 234 elif transport == "xmlrpc": 212 235 if serialize_only:
Note: See TracChangeset
for help on using the changeset viewer.