diff options
Diffstat (limited to 'python/master.py')
| -rw-r--r-- | python/master.py | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/python/master.py b/python/master.py index bc89a8aa..982eb3ee 100644 --- a/python/master.py +++ b/python/master.py @@ -2,25 +2,22 @@ import redis from pickle import dumps import datetime import os -import common import time -import pdb -cusipsfile = os.path.join(common.root, "scripts", "cusips_to_price.txt") -q = redis.Redis() +if os.name =='nt': + root = "//WDsentinel/share/CorpCDOs" +elif os.name == 'posix': + root = '/home/share/CorpCDOs' + +dealsfile = os.path.join(root, "scripts", "deals_to_price.txt") +q = redis.Redis(unix_socket_path='/var/run/redis/redis.sock') workdate = str(datetime.date.today()) while True: - if os.path.exists(cusipsfile): - with open(cusipsfile) as fh: - cusip, reinvflag = zip(*[line.rstrip().split("\t") for line in fh]) - c = common.conn.cursor() - sqlstr = "select * from dealname_from_cusip({0})".format(",",join(["%s"]*len(cusip))) - c.execute(sqlstr, params = cusip) - dealnames = [d[0] for d in c.fetchall()] - - q.rpush("tasks", dumps(("build_portfolio", [workdate, dealname, reinvflag]))) - os.unlink(cusipsfile) + if os.path.exists(dealsfile): + with open(dealsfile) as fh: + for line in fh: + dealname, reinvflag = line.rstrip().split("\t") + q.rpush("tasks", dumps(("build_portfolio", [workdate, dealname, reinvflag]))) + os.unlink(dealsfile) time.sleep(3) - -common.conn.close() |
