diff options
| -rw-r--r-- | python/client.py | 8 | ||||
| -rw-r--r-- | python/master.py | 29 |
2 files changed, 20 insertions, 17 deletions
diff --git a/python/client.py b/python/client.py index 6008765c..177ab1ed 100644 --- a/python/client.py +++ b/python/client.py @@ -1,8 +1,14 @@ import redis import tasks from pickle import loads, dumps +import socket + +hostname = socket.gethostname() +if hostname == 'debian': + q = redis.Redis(unix_socket_path='/var/run/redis/redis.sock') +elif hostname == 'gomez': + q = redis.Redis(host='debian') -q = redis.Redis() while True: f, args = loads(q.blpop("tasks")[1]) getattr(tasks, f)(*args) 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() |
