git://git.onelab.eu
/
sfa.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
open() instead of file()
[sfa.git]
/
flashpolicy
/
sfa_flashpolicy.py
diff --git
a/flashpolicy/sfa_flashpolicy.py
b/flashpolicy/sfa_flashpolicy.py
index
de98be1
..
f4d3f16
100644
(file)
--- 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):
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',
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())
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])
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,))
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]))
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
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()
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:
print >> sys.stderr, e
sys.exit(1)
except KeyboardInterrupt: