Small fixes to make the refactoring production ready

* the port for the logging is 6380
* use os.environ properly
* fix typos
This commit is contained in:
Raphaël Vinot 2014-08-22 17:35:40 +02:00
parent 4f2575723a
commit 3886d1b834
32 changed files with 40 additions and 13 deletions

View file

@ -38,6 +38,7 @@ def main():
port=cfg.getint("Redis_Queues", "port"), port=cfg.getint("Redis_Queues", "port"),
db=cfg.getint("Redis_Queues", "db")) db=cfg.getint("Redis_Queues", "db"))
publisher.port = 6380
publisher.channel = "Script" publisher.channel = "Script"
create_dirfile(r_serv, args.directory, args.ow) create_dirfile(r_serv, args.directory, args.ow)

View file

@ -20,7 +20,8 @@ import zmq
class Redis_Queues(object): class Redis_Queues(object):
def __init__(self, conf_section, conf_channel, subscriber_name): def __init__(self, conf_section, conf_channel, subscriber_name):
configfile = os.path.join(os.environ('AIL_BIN'), 'packages/config.cfg') configfile = os.path.join(os.environ['AIL_BIN'], 'packages/config.cfg')
print configfile
if not os.path.exists(configfile): if not os.path.exists(configfile):
raise Exception('Unable to find the configuration file. \ raise Exception('Unable to find the configuration file. \
Did you set environment variables? \ Did you set environment variables? \

View file

@ -33,6 +33,7 @@ def main():
db=cfg.getint("Redis_Queues", "db")) db=cfg.getint("Redis_Queues", "db"))
# LOGGING # # LOGGING #
publisher.port = 6380
publisher.channel = "Queuing" publisher.channel = "Queuing"
# ZMQ # # ZMQ #

View file

@ -34,6 +34,7 @@ def main():
db=cfg.getint("Redis_Level_DB_Hashs", "db")) db=cfg.getint("Redis_Level_DB_Hashs", "db"))
# LOGGING # # LOGGING #
publisher.port = 6380
publisher.channel = "Graph" publisher.channel = "Graph"
# FUNCTIONS # # FUNCTIONS #

View file

@ -24,7 +24,7 @@ import redis
import ConfigParser import ConfigParser
import os import os
configfile = os.path.join(os.environ('AIL_BIN'), './packages/config.cfg') configfile = os.path.join(os.environ['AIL_BIN'], './packages/config.cfg')
def main(): def main():

View file

@ -29,6 +29,7 @@ import Helper
if __name__ == "__main__": if __name__ == "__main__":
publisher.port = 6380
publisher.channel = "Script" publisher.channel = "Script"
config_section = 'Feed' config_section = 'Feed'
@ -67,7 +68,7 @@ if __name__ == "__main__":
time.sleep(10) time.sleep(10)
continue continue
# Creating the full filepath # Creating the full filepath
filename = os.path.join(os.environ('AIL_HOME'), filename = os.path.join(os.environ['AIL_HOME'],
h.config.get("Directories", "pastes"), paste) h.config.get("Directories", "pastes"), paste)
dirname = os.path.dirname(filename) dirname = os.path.dirname(filename)
if not os.path.exists(dirname): if not os.path.exists(dirname):

View file

@ -33,6 +33,6 @@ if __name__ == "__main__":
config_channel = 'topicfilter' config_channel = 'topicfilter'
subscriber_name = 'feed' subscriber_name = 'feed'
h = Helper.Redis_Queues(subscriber_name) h = Helper.Redis_Queues(config_section, config_channel, subscriber_name)
h.zmq_sub(config_section) h.zmq_sub(config_section)
h.redis_queue_subscribe(publisher) h.redis_queue_subscribe(publisher)

View file

@ -36,7 +36,6 @@ Requirements
*Need the ZMQ_PubSub_Tokenize_Q Module running to be able to work properly. *Need the ZMQ_PubSub_Tokenize_Q Module running to be able to work properly.
""" """
import glob
import os import os
import argparse import argparse
import time import time
@ -46,6 +45,7 @@ from packages import Paste
import Helper import Helper
if __name__ == "__main__": if __name__ == "__main__":
publisher.port = 6380
publisher.channel = "Script" publisher.channel = "Script"
config_section = 'PubSub_Words' config_section = 'PubSub_Words'
@ -75,10 +75,10 @@ if __name__ == "__main__":
"Script Categ subscribed to channel {}".format(h.sub_channel)) "Script Categ subscribed to channel {}".format(h.sub_channel))
tmp_dict = {} tmp_dict = {}
for filename in glob.glob(args.d): for filename in os.listdir(args.d):
bname = os.path.basename(filename) bname = os.path.basename(filename)
tmp_dict[bname] = [] tmp_dict[bname] = []
with open(filename, 'r') as f: with open(os.path.join(args.d, filename), 'r') as f:
for l in f: for l in f:
tmp_dict[bname].append(l.strip()) tmp_dict[bname].append(l.strip())

View file

@ -24,6 +24,7 @@ import Helper
if __name__ == "__main__": if __name__ == "__main__":
publisher.port = 6380
publisher.channel = 'Queuing' publisher.channel = 'Queuing'
config_section = 'PubSub_Words' config_section = 'PubSub_Words'

View file

@ -35,6 +35,7 @@ from pubsublogger import publisher
import Helper import Helper
if __name__ == "__main__": if __name__ == "__main__":
publisher.port = 6380
publisher.channel = "Script" publisher.channel = "Script"
config_section = 'PubSub_Global' config_section = 'PubSub_Global'

View file

@ -23,6 +23,7 @@ from pubsublogger import publisher
import Helper import Helper
if __name__ == "__main__": if __name__ == "__main__":
publisher.port = 6380
publisher.channel = "Queuing" publisher.channel = "Queuing"
config_section = "PubSub_Global" config_section = "PubSub_Global"

View file

@ -30,6 +30,7 @@ from pubsublogger import publisher
import Helper import Helper
if __name__ == "__main__": if __name__ == "__main__":
publisher.port = 6380
publisher.channel = "Script" publisher.channel = "Script"
config_section = 'PubSub_Longlines' config_section = 'PubSub_Longlines'

View file

@ -24,6 +24,7 @@ import Helper
if __name__ == "__main__": if __name__ == "__main__":
publisher.port = 6380
publisher.channel = "Queuing" publisher.channel = "Queuing"
config_section = 'PubSub_Longlines' config_section = 'PubSub_Longlines'

View file

@ -27,6 +27,7 @@ from pubsublogger import publisher
import Helper import Helper
if __name__ == "__main__": if __name__ == "__main__":
publisher.port = 6380
publisher.channel = "Global" publisher.channel = "Global"
config_section = 'PubSub_Global' config_section = 'PubSub_Global'

View file

@ -33,6 +33,7 @@ from pubsublogger import publisher
import Helper import Helper
if __name__ == "__main__": if __name__ == "__main__":
publisher.port = 6380
publisher.channel = "Script" publisher.channel = "Script"
config_section = 'PubSub_Global' config_section = 'PubSub_Global'

View file

@ -24,6 +24,7 @@ import Helper
if __name__ == "__main__": if __name__ == "__main__":
publisher.port = 6380
publisher.channel = "Queuing" publisher.channel = "Queuing"
config_section = 'PubSub_Global' config_section = 'PubSub_Global'

View file

@ -9,6 +9,7 @@ from pubsublogger import publisher
import Helper import Helper
if __name__ == "__main__": if __name__ == "__main__":
publisher.port = 6380
publisher.channel = "Script" publisher.channel = "Script"
config_section = 'PubSub_Categ' config_section = 'PubSub_Categ'

View file

@ -7,6 +7,7 @@ import Helper
if __name__ == "__main__": if __name__ == "__main__":
publisher.port = 6380
publisher.channel = "Queuing" publisher.channel = "Queuing"
config_section = 'PubSub_Categ' config_section = 'PubSub_Categ'

View file

@ -32,6 +32,7 @@ import os
import Helper import Helper
if __name__ == "__main__": if __name__ == "__main__":
publisher.port = 6380
publisher.channel = "Script" publisher.channel = "Script"
config_section = 'PubSub_Words' config_section = 'PubSub_Words'
@ -53,9 +54,9 @@ if __name__ == "__main__":
publisher.info("Script Curve subscribed to {}".format(h.sub_channel)) publisher.info("Script Curve subscribed to {}".format(h.sub_channel))
# FILE CURVE SECTION # # FILE CURVE SECTION #
csv_path = os.path.join(os.environ('AIL_HOME'), csv_path = os.path.join(os.environ['AIL_HOME'],
h.config.get("Directories", "wordtrending_csv")) h.config.get("Directories", "wordtrending_csv"))
wordfile_path = os.path.join(os.environ('AIL_HOME'), wordfile_path = os.path.join(os.environ['AIL_HOME'],
h.config.get("Directories", "wordsfile")) h.config.get("Directories", "wordsfile"))
message = h.redis_rpop() message = h.redis_rpop()

View file

@ -24,6 +24,7 @@ import Helper
if __name__ == "__main__": if __name__ == "__main__":
publisher.port = 6380
publisher.channel = "Queuing" publisher.channel = "Queuing"
config_section = 'PubSub_Words' config_section = 'PubSub_Words'

View file

@ -22,6 +22,7 @@ from pybloomfilter import BloomFilter
import Helper import Helper
if __name__ == "__main__": if __name__ == "__main__":
publisher.port = 6380
publisher.channel = "Script" publisher.channel = "Script"
config_section = 'PubSub_Global' config_section = 'PubSub_Global'
@ -48,7 +49,7 @@ if __name__ == "__main__":
h.config.get("PubSub_Global", "channel"))) h.config.get("PubSub_Global", "channel")))
set_limit = 100 set_limit = 100
bloompath = os.path.join(os.environ('AIL_HOME'), bloompath = os.path.join(os.environ['AIL_HOME'],
h.config.get("Directories", "bloomfilters")) h.config.get("Directories", "bloomfilters"))
bloop_path_set = set() bloop_path_set = set()

View file

@ -6,6 +6,7 @@ from pubsublogger import publisher
import Helper import Helper
if __name__ == "__main__": if __name__ == "__main__":
publisher.port = 6380
publisher.channel = 'Queuing' publisher.channel = 'Queuing'
config_section = 'PubSub_Global' config_section = 'PubSub_Global'

View file

@ -21,6 +21,7 @@ import Helper
if __name__ == "__main__": if __name__ == "__main__":
publisher.port = 6380
publisher.channel = "Script" publisher.channel = "Script"
# Subscriber # Subscriber

View file

@ -18,6 +18,7 @@ import Helper
if __name__ == "__main__": if __name__ == "__main__":
publisher.port = 6380
publisher.channel = "Queuing" publisher.channel = "Queuing"
config_section = 'PubSub_Global' config_section = 'PubSub_Global'

View file

@ -12,6 +12,7 @@ from pubsublogger import publisher
import Helper import Helper
if __name__ == "__main__": if __name__ == "__main__":
publisher.port = 6380
publisher.channel = "Script" publisher.channel = "Script"
config_section = 'PubSub_Categ' config_section = 'PubSub_Categ'

View file

@ -6,6 +6,7 @@ from pubsublogger import publisher
import Helper import Helper
if __name__ == "__main__": if __name__ == "__main__":
publisher.port = 6380
publisher.channel = "Queuing" publisher.channel = "Queuing"
config_section = 'PubSub_Categ' config_section = 'PubSub_Categ'

View file

@ -30,6 +30,7 @@ from pubsublogger import publisher
import Helper import Helper
if __name__ == "__main__": if __name__ == "__main__":
publisher.port = 6380
publisher.channel = "Script" publisher.channel = "Script"
config_section = 'PubSub_Categ' config_section = 'PubSub_Categ'

View file

@ -23,6 +23,7 @@ import Helper
if __name__ == "__main__": if __name__ == "__main__":
publisher.port = 6380
publisher.channel = "Queuing" publisher.channel = "Queuing"
config_section = 'PubSub_Categ' config_section = 'PubSub_Categ'

View file

@ -17,6 +17,7 @@ import ipaddress
import Helper import Helper
if __name__ == "__main__": if __name__ == "__main__":
publisher.port = 6380
publisher.channel = "Script" publisher.channel = "Script"
config_section = 'PubSub_Categ' config_section = 'PubSub_Categ'

View file

@ -7,6 +7,7 @@ import Helper
if __name__ == "__main__": if __name__ == "__main__":
publisher.port = 6380
publisher.channel = "Queuing" publisher.channel = "Queuing"
config_section = 'PubSub_Categ' config_section = 'PubSub_Categ'

View file

@ -22,12 +22,12 @@ def readdoc(path=None):
f = gzip.open(path, 'r') f = gzip.open(path, 'r')
return f.read() return f.read()
configfile = os.path.join(os.environ('AIL_BIN'), 'packages/config.cfg') configfile = os.path.join(os.environ['AIL_BIN'], 'packages/config.cfg')
cfg = ConfigParser.ConfigParser() cfg = ConfigParser.ConfigParser()
cfg.read(configfile) cfg.read(configfile)
# Indexer configuration - index dir and schema setup # Indexer configuration - index dir and schema setup
indexpath = os.path.join(os.environ('AIL_HOME'), cfg.get("Indexer", "path")) indexpath = os.path.join(os.environ['AIL_HOME'], cfg.get("Indexer", "path"))
indexertype = cfg.get("Indexer", "type") indexertype = cfg.get("Indexer", "type")
argParser = argparse.ArgumentParser(description='Fulltext search for AIL') argParser = argparse.ArgumentParser(description='Fulltext search for AIL')

View file

@ -56,7 +56,7 @@ class Paste(object):
def __init__(self, p_path): def __init__(self, p_path):
configfile = os.path.join(os.environ('AIL_BIN'), 'packages/config.cfg') configfile = os.path.join(os.environ['AIL_BIN'], 'packages/config.cfg')
if not os.path.exists(configfile): if not os.path.exists(configfile):
raise Exception('Unable to find the configuration file. \ raise Exception('Unable to find the configuration file. \
Did you set environment variables? \ Did you set environment variables? \