X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=flashpolicy%2Fsfa_flashpolicy.py;h=f4d3f1656f6ca1ab7815646c3977b7248f5fcf49;hb=5a6cbf4fa6837c81354b616d4cfa0352ec5367be;hp=de98be1edc34feb55e1085ef8033a1aa9c310589;hpb=91189e393c6221127379357d0928d29146993aa6;p=sfa.git diff --git a/flashpolicy/sfa_flashpolicy.py b/flashpolicy/sfa_flashpolicy.py index de98be1e..f4d3f165 100644 --- a/flashpolicy/sfa_flashpolicy.py +++ b/flashpolicy/sfa_flashpolicy.py @@ -50,7 +50,7 @@ class policy_server(object): self.sock.bind(('', port)) self.sock.listen(5) def read_policy(self, path): - with file(path, 'rb') as f: + with open(path, 'rb') as f: policy = f.read(10001) if len(policy) > 10000: raise exceptions.RuntimeError('File probably too large to be a policy file', @@ -63,7 +63,7 @@ class policy_server(object): try: while True: thread.start_new_thread(self.handle, self.sock.accept()) - except socket.error, e: + except socket.error as e: self.log('Error accepting connection: %s' % (e[1],)) def handle(self, conn, addr): addrstr = '%s:%s' % (addr[0],addr[1]) @@ -79,9 +79,9 @@ class policy_server(object): self.log('Valid request received from %s' % (addrstr,)) conn.sendall(self.policy) self.log('Sent policy file to %s' % (addrstr,)) - except socket.error, e: + except socket.error as e: self.log('Error handling connection from %s: %s' % (addrstr, e[1])) - except Exception, e: + except Exception as e: self.log('Error handling connection from %s: %s' % (addrstr, e[1])) def log(self, str): print >>sys.stderr, str @@ -105,7 +105,7 @@ def main(): if opts.daemon: daemon() policy_server(opts.port, opts.path).run() - except Exception, e: + except Exception as e: print >> sys.stderr, e sys.exit(1) except KeyboardInterrupt: