mirror of
https://github.com/wassname/catalyst.git
synced 2026-07-02 03:48:58 +08:00
Added interp to core.
This commit is contained in:
+8
-1
@@ -128,7 +128,14 @@ options(
|
||||
'Topic :: System :: Distributed Computing',
|
||||
],
|
||||
ext_modules = cext,
|
||||
cmdclass = {'build_ext': build_ext},
|
||||
cmdclass = {
|
||||
'build_ext': build_ext
|
||||
},
|
||||
entry_points = {
|
||||
'console_scripts': [
|
||||
'zipline = zipline.core.interpreter:main',
|
||||
]
|
||||
},
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import socket
|
||||
import logging
|
||||
import traceback
|
||||
import humanhash
|
||||
from setproctitle import setproctitle
|
||||
|
||||
# pyzmq
|
||||
import zmq
|
||||
@@ -167,6 +168,8 @@ class Component(object):
|
||||
self.zmq = zmq
|
||||
self.context = self.zmq.Context()
|
||||
self.zmq_poller = self.zmq.Poller
|
||||
# The the process title so you can watch it in top
|
||||
setproctitle(self.__class__.__name__)
|
||||
return
|
||||
if flavor == 'thread':
|
||||
self.zmq = zmq
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
import sys
|
||||
import yaml
|
||||
import argparse
|
||||
import fileinput
|
||||
from cStringIO import StringIO
|
||||
|
||||
def interpret(args):
|
||||
print 'Reading {ifile}'.format(ifile=args.file)
|
||||
|
||||
metastart = False
|
||||
metadone = False
|
||||
|
||||
metadata = StringIO()
|
||||
algorithm = StringIO()
|
||||
|
||||
for line in fileinput.input(sys.argv[1]):
|
||||
if line.startswith('---'):
|
||||
if metastart:
|
||||
metastart = False
|
||||
metadone = False
|
||||
else:
|
||||
metastart = True
|
||||
metadone = False
|
||||
metadata.write(line)
|
||||
|
||||
elif metastart:
|
||||
metadata.write(line)
|
||||
else:
|
||||
algorithm.write(line)
|
||||
|
||||
#print 'Metadata:'
|
||||
#print metadata.getvalue()
|
||||
|
||||
#print 'Algorithm:'
|
||||
#print algorithm.getvalue()
|
||||
|
||||
try:
|
||||
meta = yaml.load_all(metadata.getvalue())
|
||||
except yaml.error.YAMLError, e:
|
||||
print e
|
||||
sys.exit(0)
|
||||
|
||||
try:
|
||||
meta = meta.next()
|
||||
except StopIteration:
|
||||
raise RuntimeError("No metadata in file.")
|
||||
|
||||
start = meta['start']
|
||||
end = meta['end']
|
||||
|
||||
print end - start
|
||||
|
||||
ns = {}
|
||||
exec(algorithm.getvalue()) in ns
|
||||
|
||||
assert ns['initialize']
|
||||
assert ns['get_sid_filter']
|
||||
assert ns['handle_data']
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('file', metavar='file', help='Algorithm file.')
|
||||
args = parser.parse_args()
|
||||
|
||||
if not args.file:
|
||||
print parser.print_help()
|
||||
sys.exit(0)
|
||||
interpret(args)
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
Reference in New Issue
Block a user