Commit 0f1bbe6a authored by Mark Peek's avatar Mark Peek

pep8

parent 3c50e63b
...@@ -53,8 +53,8 @@ def default_exception_notifier(): ...@@ -53,8 +53,8 @@ def default_exception_notifier():
me.id, me.id,
me.name, me.name,
compact_traceback(), compact_traceback(),
)
) )
)
set_exception_notifier (default_exception_notifier) set_exception_notifier (default_exception_notifier)
...@@ -104,7 +104,7 @@ def in_parallel (fun_arg_list): ...@@ -104,7 +104,7 @@ def in_parallel (fun_arg_list):
# InParallelError, [(SUCCESS, result0), (FAILURE, exc_info1), ...] # InParallelError, [(SUCCESS, result0), (FAILURE, exc_info1), ...]
n = len(fun_arg_list) n = len(fun_arg_list)
if n==0: if n == 0:
return [] return []
result_list = [None] * n result_list = [None] * n
sem = inverted_semaphore(n) sem = inverted_semaphore(n)
...@@ -115,11 +115,11 @@ def in_parallel (fun_arg_list): ...@@ -115,11 +115,11 @@ def in_parallel (fun_arg_list):
i, i,
sem, sem,
fun_arg_list[i] fun_arg_list[i]
) )
sem.block_till_zero() sem.block_till_zero()
for i in xrange (n): for i in xrange (n):
if result_list[i][0] is FAILURE: if result_list[i][0] is FAILURE:
raise InParallelError, result_list raise InParallelError(result_list)
# no errors, convert to a simple result list # no errors, convert to a simple result list
return [x[1] for x in result_list] return [x[1] for x in result_list]
...@@ -230,7 +230,7 @@ def spawn (fun, *args, **kwargs): ...@@ -230,7 +230,7 @@ def spawn (fun, *args, **kwargs):
:returns: The new coroutine object. :returns: The new coroutine object.
""" """
if kwargs.has_key('thread_name'): if 'thread_name' in kwargs:
thread_name = kwargs['thread_name'] thread_name = kwargs['thread_name']
del kwargs['thread_name'] del kwargs['thread_name']
else: else:
...@@ -253,7 +253,7 @@ def new (fun, *args, **kwargs): ...@@ -253,7 +253,7 @@ def new (fun, *args, **kwargs):
:returns: The new coroutine object. :returns: The new coroutine object.
""" """
if kwargs.has_key('thread_name'): if 'thread_name' in kwargs:
thread_name = kwargs['thread_name'] thread_name = kwargs['thread_name']
del kwargs['thread_name'] del kwargs['thread_name']
else: else:
......
...@@ -59,9 +59,9 @@ class backdoor: ...@@ -59,9 +59,9 @@ class backdoor:
self.global_dict = global_dict self.global_dict = global_dict
# allow the user to change the prompts: # allow the user to change the prompts:
if not sys.__dict__.has_key('ps1'): if 'ps1' not in sys.__dict__:
sys.ps1 = '>>> ' sys.ps1 = '>>> '
if not sys.__dict__.has_key('ps2'): if 'ps2' not in sys.__dict__:
sys.ps2 = '... ' sys.ps2 = '... '
def send (self, data): def send (self, data):
...@@ -199,7 +199,7 @@ def serve (port=None, ip='', unix_path=None, welcome_message=None, global_dict=N ...@@ -199,7 +199,7 @@ def serve (port=None, ip='', unix_path=None, welcome_message=None, global_dict=N
try: try:
os.remove (unix_path) os.remove (unix_path)
except OSError, why: except OSError, why:
if why[0]==errno.ENOENT: if why[0] == errno.ENOENT:
pass pass
else: else:
raise raise
...@@ -223,9 +223,9 @@ def serve (port=None, ip='', unix_path=None, welcome_message=None, global_dict=N ...@@ -223,9 +223,9 @@ def serve (port=None, ip='', unix_path=None, welcome_message=None, global_dict=N
break break
except OSError, why: except OSError, why:
if why[0] != errno.EADDRINUSE: if why[0] != errno.EADDRINUSE:
raise OSError, why raise OSError(why)
else: else:
raise Exception, "couldn't bind a port (try not specifying a port)" raise Exception("couldn't bind a port (try not specifying a port)")
if client_class is None: if client_class is None:
client_class = client client_class = client
...@@ -268,15 +268,15 @@ class ssh_server: ...@@ -268,15 +268,15 @@ class ssh_server:
self.server_key = server_key self.server_key = server_key
self.authenticators = authenticators self.authenticators = authenticators
coro.spawn (self.serve) coro.spawn (self.serve)
def serve (self): def serve (self):
serve (self.port, self.addr, client_class=self.new_connection) serve (self.port, self.addr, client_class=self.new_connection)
def new_connection (self, conn, addr, welcome_message, global_dict): def new_connection (self, conn, addr, welcome_message, global_dict):
#debug = coro.ssh.util.debug.Debug() # debug = coro.ssh.util.debug.Debug()
#debug.level = coro.ssh.util.debug.DEBUG_3 # debug.level = coro.ssh.util.debug.DEBUG_3
transport = coro.ssh.l4_transport.coro_socket_transport.coro_socket_transport(sock=conn) transport = coro.ssh.l4_transport.coro_socket_transport.coro_socket_transport(sock=conn)
server = coro.ssh.transport.server.SSH_Server_Transport (self.server_key) #, debug=debug) server = coro.ssh.transport.server.SSH_Server_Transport (self.server_key) # , debug=debug)
authenticator = coro.ssh.auth.userauth.Authenticator (server, self.authenticators) authenticator = coro.ssh.auth.userauth.Authenticator (server, self.authenticators)
server.connect (transport, authenticator) server.connect (transport, authenticator)
service = coro.ssh.connection.connect.Connection_Service (server, ssh_repl) service = coro.ssh.connection.connect.Connection_Service (server, ssh_repl)
......
...@@ -41,21 +41,21 @@ class stdin (coro.sock): ...@@ -41,21 +41,21 @@ class stdin (coro.sock):
coro.sock.__init__ (self, fd=0) coro.sock.__init__ (self, fd=0)
self.fd = 0 self.fd = 0
self.old = termios.tcgetattr (self.fd) self.old = termios.tcgetattr (self.fd)
#print 'old=%r' % (self.old,) # print 'old=%r' % (self.old,)
self.new = termios.tcgetattr (self.fd) self.new = termios.tcgetattr (self.fd)
self.new[LFLAG] &= ~(termios.ICANON | termios.ECHO | termios.IEXTEN) self.new[LFLAG] &= ~(termios.ICANON | termios.ECHO | termios.IEXTEN)
self.new[IFLAG] &= ~(termios.IGNBRK | termios.IXOFF | termios.IXON) self.new[IFLAG] &= ~(termios.IGNBRK | termios.IXOFF | termios.IXON)
self.new[CC][termios.VMIN] = 1 self.new[CC][termios.VMIN] = 1
self.new[CC][termios.VTIME] = 0 self.new[CC][termios.VTIME] = 0
self.new[CC][termios.CINTR] = 254 # block ctrl-c? doesn't work. self.new[CC][termios.CINTR] = 254 # block ctrl-c? doesn't work.
#print 'new=%r' % (self.new,) # print 'new=%r' % (self.new,)
termios.tcsetattr (self.fd, termios.TCSANOW, self.new) termios.tcsetattr (self.fd, termios.TCSANOW, self.new)
def __dealloc__ (self): def __dealloc__ (self):
self.restore() self.restore()
def restore (self): def restore (self):
#print '[restoring stdin to %r]' % (self.old,) # print '[restoring stdin to %r]' % (self.old,)
termios.tcsetattr (self.fd, termios.TCSAFLUSH, self.old) termios.tcsetattr (self.fd, termios.TCSAFLUSH, self.old)
def read (self, size): def read (self, size):
......
...@@ -31,8 +31,6 @@ TODO ...@@ -31,8 +31,6 @@ TODO
""" """
import urllib import urllib
import cgi import cgi
import sys import sys
...@@ -137,9 +135,15 @@ function ts_resortTable(lnk,clid) { ...@@ -137,9 +135,15 @@ function ts_resortTable(lnk,clid) {
// We appendChild rows that already exist to the tbody, so it moves them rather than creating new ones // We appendChild rows that already exist to the tbody, so it moves them rather than creating new ones
// don't do sortbottom rows // don't do sortbottom rows
for (i=0;i<newRows.length;i++) { if (!newRows[i].className || (newRows[i].className && (newRows[i].className.indexOf('sortbottom') == -1))) table.tBodies[0].appendChild(newRows[i]);} for (i=0;i<newRows.length;i++) {
if (!newRows[i].className || (newRows[i].className && (newRows[i].className.indexOf('sortbottom') == -1)))
table.tBodies[0].appendChild(newRows[i]);
}
// do sortbottom rows only // do sortbottom rows only
for (i=0;i<newRows.length;i++) { if (newRows[i].className && (newRows[i].className.indexOf('sortbottom') != -1)) table.tBodies[0].appendChild(newRows[i]);} for (i=0;i<newRows.length;i++) {
if (newRows[i].className && (newRows[i].className.indexOf('sortbottom') != -1))
table.tBodies[0].appendChild(newRows[i]);
}
// Delete any other arrows there may be showing // Delete any other arrows there may be showing
var allspans = document.getElementsByTagName("span"); var allspans = document.getElementsByTagName("span");
...@@ -156,7 +160,8 @@ function ts_resortTable(lnk,clid) { ...@@ -156,7 +160,8 @@ function ts_resortTable(lnk,clid) {
function getParent(el, pTagName) { function getParent(el, pTagName) {
if (el == null) return null; if (el == null) return null;
else if (el.nodeType == 1 && el.tagName.toLowerCase() == pTagName.toLowerCase()) // Gecko bug, supposed to be uppercase else if (el.nodeType == 1 && el.tagName.toLowerCase() == pTagName.toLowerCase())
// Gecko bug, supposed to be uppercase
return el; return el;
else else
return getParent(el.parentNode, pTagName); return getParent(el.parentNode, pTagName);
...@@ -251,7 +256,7 @@ def _mapfuns(d1, d2): ...@@ -251,7 +256,7 @@ def _mapfuns(d1, d2):
m1 = [(_name(f), f) for f in d1] m1 = [(_name(f), f) for f in d1]
m2 = dict([(_name(f), f) for f in d2]) m2 = dict([(_name(f), f) for f in d2])
return dict([(v, m2[k]) for k,v in m1 if k in m2]) return dict([(v, m2[k]) for k, v in m1 if k in m2])
class profile_data: class profile_data:
...@@ -296,8 +301,8 @@ class profile_data: ...@@ -296,8 +301,8 @@ class profile_data:
# Find any columns that have all zeros and skip them. # Find any columns that have all zeros and skip them.
has_nonzero = {} has_nonzero = {}
# Also determine the sum for the column. # Also determine the sum for the column.
column_sums = [0]*len(self.headings) column_sums = [0] * len(self.headings)
empty_cols = [0]*len(self.headings) empty_cols = [0] * len(self.headings)
for heading in self.headings: for heading in self.headings:
has_nonzero[heading] = False has_nonzero[heading] = False
...@@ -332,21 +337,21 @@ class profile_data: ...@@ -332,21 +337,21 @@ class profile_data:
try: try:
calls2, data_tuple2, aggregate_data_tuple2 = other_profile[m[function_string]] calls2, data_tuple2, aggregate_data_tuple2 = other_profile[m[function_string]]
except KeyError: except KeyError:
calls2, data_tuple2, aggregate_data_tuple2 = 0,empty_cols, empty_cols calls2, data_tuple2, aggregate_data_tuple2 = 0, empty_cols, empty_cols
print ' <tr align=right>' print ' <tr align=right>'
print ' <td>%s</td>' % (calls-calls2,) print ' <td>%s</td>' % (calls - calls2, )
for i, heading in enumerate(self.headings): for i, heading in enumerate(self.headings):
if heading not in skip_headings: if heading not in skip_headings:
if aggregate: if aggregate:
data_item = aggregate_data_tuple[i]-aggregate_data_tuple2[i] data_item = aggregate_data_tuple[i] - aggregate_data_tuple2[i]
else: else:
data_item = data_tuple[i]-data_tuple2[i] data_item = data_tuple[i] - data_tuple2[i]
if isinstance(data_item, float): if isinstance(data_item, float):
value = '%.6f' % (data_item,) value = '%.6f' % (data_item,)
else: else:
value = data_item value = data_item
if data_item and function_string != '<wait>': if data_item and function_string != '<wait>':
pct = ' (%.2f%%)' % ((float(data_item)/column_sums[i])*100,) pct = ' (%.2f%%)' % ((float(data_item) / column_sums[i]) * 100,)
else: else:
pct = '' pct = ''
print ' <td>%s%s</td>' % (value, pct) print ' <td>%s%s</td>' % (value, pct)
...@@ -355,15 +360,15 @@ class profile_data: ...@@ -355,15 +360,15 @@ class profile_data:
per = data_item per = data_item
else: else:
if isinstance(data_item, float): if isinstance(data_item, float):
per = '%.6f' % (data_item/calls,) per = '%.6f' % (data_item / calls,)
else: else:
per = data_item/calls per = data_item / calls
print ' <td>%s</td>' % (per,) print ' <td>%s</td>' % (per, )
print ' <td align=left><a name="tt_%s"></a><a href="#cg_%s">%s</a></td>' % ( print ' <td align=left><a name="tt_%s"></a><a href="#cg_%s">%s</a></td>' % (
urllib.quote_plus(function_string), urllib.quote_plus(function_string),
urllib.quote_plus(function_string), urllib.quote_plus(function_string),
cgi.escape(function_string, quote=True) cgi.escape(function_string, quote=True)
) )
print ' </tr>' print ' </tr>'
print '</table>' print '</table>'
print '<p><tt>/call</tt> columns represent the time spent in that function per call <b>on average</b>.' print '<p><tt>/call</tt> columns represent the time spent in that function per call <b>on average</b>.'
...@@ -374,7 +379,7 @@ class profile_data: ...@@ -374,7 +379,7 @@ class profile_data:
rg = {} rg = {}
for caller_string, callees in self.call_data.iteritems(): for caller_string, callees in self.call_data.iteritems():
for callee_string, call_count in callees: for callee_string, call_count in callees:
if rg.has_key(callee_string): if callee_string in rg:
rg[callee_string].append((caller_string, call_count)) rg[callee_string].append((caller_string, call_count))
else: else:
rg[callee_string] = [(caller_string, call_count)] rg[callee_string] = [(caller_string, call_count)]
...@@ -394,23 +399,21 @@ class profile_data: ...@@ -394,23 +399,21 @@ class profile_data:
print '</tt>' print '</tt>'
print '<pre>' print '<pre>'
# Print callers. # Print callers.
if rg.has_key(function_string): if function_string in rg:
l = [] l = []
for caller, count in rg[function_string]: for caller, count in rg[function_string]:
l.append((caller, count)) l.append((caller, count))
l.sort(lambda a,b: cmp(a[1], b[1])) l.sort(lambda a, b: cmp(a[1], b[1]))
for caller, count in l: for caller, count in l:
print '%10i/%-10i (%04.1f%%) <a href="#tt_%s">%s</a>' % ( print '%10i/%-10i (%04.1f%%) <a href="#tt_%s">%s</a>' % (
count, count,
calls, calls,
(float(count)/calls) * 100, (float(count) / calls) * 100,
urllib.quote_plus(caller), urllib.quote_plus(caller),
cgi.escape(caller, quote=True) cgi.escape(caller, quote=True)
) )
print '%15i <b>%s</b>' % (calls, print '%15i <b>%s</b>' % (calls, function_string)
function_string
)
# Print callees. # Print callees.
callees2 = [] callees2 = []
...@@ -418,15 +421,15 @@ class profile_data: ...@@ -418,15 +421,15 @@ class profile_data:
for callee_string, call_count in callees: for callee_string, call_count in callees:
callee_calls = self.profile_data.get(callee_string, [1])[0] callee_calls = self.profile_data.get(callee_string, [1])[0]
callees2.append((callee_string, call_count, callee_calls)) callees2.append((callee_string, call_count, callee_calls))
callees2.sort(lambda a,b: cmp(a[1], b[1])) callees2.sort(lambda a, b: cmp(a[1], b[1]))
for callee_string, call_count, callee_calls in callees2: for callee_string, call_count, callee_calls in callees2:
print '%10i/%-10i (%04.1f%%) <a href="#tt_%s">%s</a>' % ( print '%10i/%-10i (%04.1f%%) <a href="#tt_%s">%s</a>' % (
call_count, call_count,
callee_calls, callee_calls,
(float(call_count)/callee_calls) * 100, (float(call_count) / callee_calls) * 100,
urllib.quote_plus(callee_string), urllib.quote_plus(callee_string),
cgi.escape(callee_string, quote=True) cgi.escape(callee_string, quote=True)
) )
print '</pre>' print '</pre>'
print '<hr>' print '<hr>'
...@@ -446,7 +449,6 @@ class profile_data: ...@@ -446,7 +449,6 @@ class profile_data:
print print
print 'Profile data values of 0 are not displayed.' print 'Profile data values of 0 are not displayed.'
def _print_header(self): def _print_header(self):
print '<html><head><title>Shrapnel Profile</title></head><body bgcolor="#ffffff">' print '<html><head><title>Shrapnel Profile</title></head><body bgcolor="#ffffff">'
print '<script type="text/javascript"><!--' print '<script type="text/javascript"><!--'
...@@ -493,4 +495,3 @@ if __name__ == '__main__': ...@@ -493,4 +495,3 @@ if __name__ == '__main__':
baseline = sys.argv[1] baseline = sys.argv[1]
otherfile = sys.argv[2] if len(sys.argv) == 3 else None otherfile = sys.argv[2] if len(sys.argv) == 3 else None
main(baseline, otherfile) main(baseline, otherfile)
...@@ -107,13 +107,13 @@ def go (fun, *args, **kwargs): ...@@ -107,13 +107,13 @@ def go (fun, *args, **kwargs):
:keyword profile_bench: The bench object type to use. Defaults to :keyword profile_bench: The bench object type to use. Defaults to
:class:`coro.rusage_bench`. :class:`coro.rusage_bench`.
""" """
if kwargs.has_key('profile_filename'): if 'profile_filename' in kwargs:
profile_filename = kwargs['profile_filename'] profile_filename = kwargs['profile_filename']
del kwargs['profile_filename'] del kwargs['profile_filename']
else: else:
profile_filename = '/tmp/coro_profile.bin' profile_filename = '/tmp/coro_profile.bin'
if kwargs.has_key('profile_bench'): if 'profile_bench' in kwargs:
profile_bench = kwargs['profile_bench'] profile_bench = kwargs['profile_bench']
del kwargs['profile_bench'] del kwargs['profile_bench']
else: else:
...@@ -146,25 +146,25 @@ def stop(filename='/tmp/coro_profile.bin'): ...@@ -146,25 +146,25 @@ def stop(filename='/tmp/coro_profile.bin'):
p.stop() p.stop()
_dump(p, filename) _dump(p, filename)
def tak1 (x,y,z): def tak1 (x, y, z):
if y >= x: if y >= x:
return z return z
else: else:
return tak1 ( return tak1 (
tak1 (x-1, y, z), tak1 (x - 1, y, z),
tak2 (y-1, z, x), tak2 (y - 1, z, x),
tak2 (z-1, x, y) tak2 (z - 1, x, y)
) )
def tak2 (x,y,z): def tak2 (x, y, z):
if y >= x: if y >= x:
return z return z
else: else:
return tak2 ( return tak2 (
tak2 (x-1, y, z), tak2 (x - 1, y, z),
tak1 (y-1, z, x), tak1 (y - 1, z, x),
tak1 (z-1, x, y) tak1 (z - 1, x, y)
) )
if __name__ == '__main__': if __name__ == '__main__':
go (tak2, 18, 12, 6) go (tak2, 18, 12, 6)
......
...@@ -4,6 +4,7 @@ class socket_producer: ...@@ -4,6 +4,7 @@ class socket_producer:
def __init__ (self, conn, buffer_size=8000): def __init__ (self, conn, buffer_size=8000):
self.conn = conn self.conn = conn
self.buffer_size = buffer_size self.buffer_size = buffer_size
def next (self): def next (self):
return self.conn.recv (self.buffer_size) return self.conn.recv (self.buffer_size)
...@@ -32,7 +33,7 @@ class buffered_stream: ...@@ -32,7 +33,7 @@ class buffered_stream:
if self.buffer[i] == delim[m]: if self.buffer[i] == delim[m]:
m += 1 m += 1
if m == ld: if m == ld:
result, self.buffer = self.buffer[:i+1], self.buffer[i+1:] result, self.buffer = self.buffer[:i + 1], self.buffer[i + 1:]
yield result yield result
return return
else: else:
...@@ -54,7 +55,7 @@ class buffered_stream: ...@@ -54,7 +55,7 @@ class buffered_stream:
i = 0 i = 0
while i < len (self.buffer): while i < len (self.buffer):
if dfa.consume (self.buffer[i]): if dfa.consume (self.buffer[i]):
result, self.buffer = self.buffer[:i+1], self.buffer[i+1:] result, self.buffer = self.buffer[:i + 1], self.buffer[i + 1:]
yield result yield result
return return
i += 1 i += 1
...@@ -80,7 +81,7 @@ class buffered_stream: ...@@ -80,7 +81,7 @@ class buffered_stream:
def read_until (self, delim, join=True): def read_until (self, delim, join=True):
"read until <delim>. return a list of parts unless <join> is True" "read until <delim>. return a list of parts unless <join> is True"
result = ( x for x in self.gen_read_until (delim) ) result = (x for x in self.gen_read_until (delim))
if join: if join:
return ''.join (result) return ''.join (result)
else: else:
...@@ -88,7 +89,7 @@ class buffered_stream: ...@@ -88,7 +89,7 @@ class buffered_stream:
def read_exact (self, size, join=True): def read_exact (self, size, join=True):
"read exactly <size> bytes. return a list of parts unless <join> is True" "read exactly <size> bytes. return a list of parts unless <join> is True"
result = ( x for x in self.gen_read_exact (size) ) result = (x for x in self.gen_read_exact (size))
if join: if join:
return ''.join (result) return ''.join (result)
else: else:
...@@ -113,4 +114,3 @@ class buffered_stream: ...@@ -113,4 +114,3 @@ class buffered_stream:
return return
else: else:
yield block yield block
...@@ -33,7 +33,7 @@ def _get_module_name(n): ...@@ -33,7 +33,7 @@ def _get_module_name(n):
try: try:
path, filename = os.path.split(n) path, filename = os.path.split(n)
path, directory = os.path.split(path) path, directory = os.path.split(path)
#name, ext = os.path.splitext(filename) # name, ext = os.path.splitext(filename)
if directory: if directory:
return '/'.join((directory, filename)) return '/'.join((directory, filename))
else: else:
...@@ -62,9 +62,9 @@ def stack_string(f=None): ...@@ -62,9 +62,9 @@ def stack_string(f=None):
_get_module_name(f.f_code.co_filename) + ' ' + _get_module_name(f.f_code.co_filename) + ' ' +
f.f_code.co_name + '|' + f.f_code.co_name + '|' +
str(f.f_lineno) str(f.f_lineno)
) )
f = f.f_back f = f.f_back
return '[' + ('] ['.join(stack))+ ']' return '[' + ('] ['.join(stack)) + ']'
def traceback_string(t=None, v=None, tb=None): def traceback_string(t=None, v=None, tb=None):
"""Returns a compact string representing the current exception. """Returns a compact string representing the current exception.
...@@ -81,7 +81,7 @@ def traceback_string(t=None, v=None, tb=None): ...@@ -81,7 +81,7 @@ def traceback_string(t=None, v=None, tb=None):
Returns a string of the current exception and stack trace. Returns a string of the current exception and stack trace.
""" """
if t is None: if t is None:
t,v,tb = sys.exc_info() t, v, tb = sys.exc_info()
tbinfo = [] tbinfo = []
if tb is None: if tb is None:
# this should never happen, but then again, lots of things # this should never happen, but then again, lots of things
...@@ -92,7 +92,7 @@ def traceback_string(t=None, v=None, tb=None): ...@@ -92,7 +92,7 @@ def traceback_string(t=None, v=None, tb=None):
_get_module_name (tb.tb_frame.f_code.co_filename) + ' ' + _get_module_name (tb.tb_frame.f_code.co_filename) + ' ' +
tb.tb_frame.f_code.co_name + '|' + tb.tb_frame.f_code.co_name + '|' +
str(tb.tb_lineno) str(tb.tb_lineno)
) )
tb = tb.tb_next tb = tb.tb_next
# just to be safe # just to be safe
......
# $Header: //prod/main/ap/shrapnel/setup.py#17 $
#!/usr/bin/env python #!/usr/bin/env python
import sys import sys
...@@ -17,7 +16,7 @@ except ImportError: ...@@ -17,7 +16,7 @@ except ImportError:
'\nThe Cython compiler is required to build Shrapnel.\n' '\nThe Cython compiler is required to build Shrapnel.\n'
' Try "pip install cython"\n' ' Try "pip install cython"\n'
' *or* "easy_install cython"\n' ' *or* "easy_install cython"\n'
) )
sys.exit (-1) sys.exit (-1)
include_dir = os.getcwd() include_dir = os.getcwd()
...@@ -59,15 +58,15 @@ USE_LINUX_AIO = check_linux_aio() ...@@ -59,15 +58,15 @@ USE_LINUX_AIO = check_linux_aio()
compile_time_env = { compile_time_env = {
'COMPILE_LIO': check_lio(), 'COMPILE_LIO': check_lio(),
'COMPILE_LINUX_AIO': USE_LINUX_AIO, 'COMPILE_LINUX_AIO': USE_LINUX_AIO,
'COMPILE_NETDEV' : False, 'COMPILE_NETDEV': False,
'COMPILE_LZO' : False, 'COMPILE_LZO': False,
'COMPILE_LZ4' : False, 'COMPILE_LZ4': False,
'CORO_DEBUG': False, 'CORO_DEBUG': False,
} }
#-------------------------------------------------------------------------------- # --------------------------------------------------------------------------
# OpenSSL support # OpenSSL support
#-------------------------------------------------------------------------------- # --------------------------------------------------------------------------
# If you need NPN support (for SPDY), you most likely will have to link against # If you need NPN support (for SPDY), you most likely will have to link against
# newer openssl than the one that came with your OS. (this is circa 2012). # newer openssl than the one that came with your OS. (this is circa 2012).
...@@ -78,7 +77,7 @@ compile_time_env = { ...@@ -78,7 +77,7 @@ compile_time_env = {
# statically link is a bit tricky # statically link is a bit tricky
# Note: be sure to remove coro/ssl/openssl.c if you change this, see NPN probe below. # Note: be sure to remove coro/ssl/openssl.c if you change this, see NPN probe below.
#ossl_base = '/Users/rushing/src/openssl-1.0.1c' # ossl_base = '/Users/rushing/src/openssl-1.0.1c'
# #
# OS X: as of 10.9, openssl seems to have been completely removed. You'll need # OS X: as of 10.9, openssl seems to have been completely removed. You'll need
# to install from the sources. Once this is done, use '/usr/local/ssl/' for ossl_base. # to install from the sources. Once this is done, use '/usr/local/ssl/' for ossl_base.
...@@ -101,15 +100,15 @@ OpenSSL_Extension = Extension ( ...@@ -101,15 +100,15 @@ OpenSSL_Extension = Extension (
['coro/ssl/openssl.pyx'], ['coro/ssl/openssl.pyx'],
depends=['coro/ssl/openssl.pxi'], depends=['coro/ssl/openssl.pxi'],
# manual static link # manual static link
#extra_link_args = [ O('libcrypto.a'), O('libssl.a') ], # extra_link_args = [O('libcrypto.a'), O('libssl.a')],
# link to an absolute location # link to an absolute location
#extra_link_args = [ '-L %s -lcrypto -lssl' % (ossl_base,) ] # extra_link_args = ['-L %s -lcrypto -lssl' % (ossl_base,)]
# 'normal' link # 'normal' link
libraries = ['crypto', 'ssl'], libraries=['crypto', 'ssl'],
include_dirs = [ O('include') ], include_dirs=[O('include')],
cython_compile_time_env = {'NPN' : USE_NPN}, cython_compile_time_env={'NPN': USE_NPN},
) )
#-------------------------------------------------------------------------------- # --------------------------------------------------------------------------
setup ( setup (
name='coro', name='coro',
...@@ -117,23 +116,23 @@ setup ( ...@@ -117,23 +116,23 @@ setup (
description='IronPort Coroutine/Threading Library', description='IronPort Coroutine/Threading Library',
author='Sam Rushing, Eric Huss, IronPort Engineering', author='Sam Rushing, Eric Huss, IronPort Engineering',
author_email='sam-coro@rushing.nightmare.com', author_email='sam-coro@rushing.nightmare.com',
license = "MIT", license="MIT",
url = "http://github.com/ironport/shrapnel", url="http://github.com/ironport/shrapnel",
ext_modules = [ ext_modules=[
Extension( Extension(
'coro.event_queue', 'coro.event_queue',
['coro/event_queue.pyx'], ['coro/event_queue.pyx'],
language='c++', language='c++',
depends=[os.path.join(include_dir, 'pyrex', 'python.pxi'),], depends=[os.path.join(include_dir, 'pyrex', 'python.pxi'), ],
pyrex_include_dirs=[ pyrex_include_dirs=[
os.path.join(include_dir, '.'), os.path.join(include_dir, '.'),
os.path.join(include_dir, 'pyrex'), os.path.join(include_dir, 'pyrex'),
],), ],),
Extension ( Extension (
'coro._coro', 'coro._coro',
['coro/_coro.pyx', 'coro/swap.c'], ['coro/_coro.pyx', 'coro/swap.c'],
extra_compile_args = ['-Wno-unused-function'], extra_compile_args=['-Wno-unused-function'],
depends = ( depends=(
glob.glob('coro/*.pyx') + glob.glob('coro/*.pyx') +
glob.glob('coro/*.pxi') + glob.glob('coro/*.pxi') +
glob.glob('coro/*.pxd') + [ glob.glob('coro/*.pxd') + [
...@@ -143,31 +142,32 @@ setup ( ...@@ -143,31 +142,32 @@ setup (
os.path.join(include_dir, 'pyrex', 'tsc_time_include.pyx'), os.path.join(include_dir, 'pyrex', 'tsc_time_include.pyx'),
os.path.join(include_dir, 'include', 'tsc_time.h'), os.path.join(include_dir, 'include', 'tsc_time.h'),
os.path.join(include_dir, 'pyrex', 'libc.pxd'), os.path.join(include_dir, 'pyrex', 'libc.pxd'),
] ]
), ),
pyrex_include_dirs=[ pyrex_include_dirs=[
os.path.join(include_dir, '.'), os.path.join(include_dir, '.'),
os.path.join(include_dir, 'pyrex'), os.path.join(include_dir, 'pyrex'),
], ],
include_dirs=[ include_dirs=[
os.path.join(include_dir, '.'), os.path.join(include_dir, '.'),
os.path.join(include_dir, 'include'), os.path.join(include_dir, 'include'),
], ],
pyrex_compile_time_env = compile_time_env, pyrex_compile_time_env=compile_time_env,
# to enable LZO|LZ4 for stack compression, set COMPILE_LZO|COMPILE_LZ4 above # to enable LZO|LZ4 for stack compression, set COMPILE_LZO|COMPILE_LZ4 above
# and uncomment one of the following: # and uncomment one of the following:
#libraries=['lzo2', 'z'] # libraries=['lzo2', 'z']
#libraries=['lz4', 'z'], # libraries=['lz4', 'z'],
libraries=['z'] + (['aio'] if USE_LINUX_AIO else []) libraries=['z'] + (['aio'] if USE_LINUX_AIO else [])
), ),
Extension ('coro.oserrors', ['coro/oserrors.pyx', ],), Extension ('coro.oserrors', ['coro/oserrors.pyx', ], ),
Extension ('coro.dns.packet', ['coro/dns/packet.pyx', ],), Extension ('coro.dns.packet', ['coro/dns/packet.pyx', ], ),
Extension ('coro.dns.surf', ['coro/dns/surf.pyx',],), Extension ('coro.dns.surf', ['coro/dns/surf.pyx', ], ),
Extension ('coro.lru', ['coro/lru.pyx'], ), Extension ('coro.lru', ['coro/lru.pyx'], ),
Extension ('coro.asn1.ber', ['coro/asn1/ber.pyx'],), Extension ('coro.asn1.ber', ['coro/asn1/ber.pyx'], ),
Extension ('coro.db.postgres.proto', ['coro/db/postgres/proto.pyx'],), Extension ('coro.db.postgres.proto', ['coro/db/postgres/proto.pyx'], ),
Extension ('coro.ldap.query', ['coro/ldap/query.pyx'],), Extension ('coro.ldap.query', ['coro/ldap/query.pyx'],),
Extension ('coro.http.zspdy', ['coro/http/zspdy.pyx'], include_dirs=['coro'], libraries=['z'], depends=['coro/zlib.pxd']), Extension ('coro.http.zspdy', ['coro/http/zspdy.pyx'],
include_dirs=['coro'], libraries=['z'], depends=['coro/zlib.pxd']),
Extension ( Extension (
'coro.clocks.tsc_time', 'coro.clocks.tsc_time',
['coro/clocks/tsc_time.pyx', ], ['coro/clocks/tsc_time.pyx', ],
...@@ -175,13 +175,13 @@ setup ( ...@@ -175,13 +175,13 @@ setup (
include_dirs=[ include_dirs=[
os.path.join(include_dir, '.'), os.path.join(include_dir, '.'),
os.path.join(include_dir, 'include'), os.path.join(include_dir, 'include'),
], ],
), ),
# the pre-computed openssl extension from above # the pre-computed openssl extension from above
OpenSSL_Extension, OpenSSL_Extension,
], ],
packages= find_packages(), packages= find_packages(),
py_modules = ['backdoor', 'coro.read_stream', 'coro_process', 'coro_unittest',], py_modules = ['backdoor', 'coro.read_stream', 'coro_process', 'coro_unittest', ],
download_url = 'http://github.com/ironport/shrapnel/tarball/master#egg=coro-1.0.2', download_url = 'http://github.com/ironport/shrapnel/tarball/master#egg=coro-1.0.2',
install_requires = ['cython>=0.12.1', 'distribute>=0.6.16', 'pycrypto'], install_requires = ['cython>=0.12.1', 'distribute>=0.6.16', 'pycrypto'],
cmdclass={'build_ext': build_ext}, cmdclass={'build_ext': build_ext},
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment