From a68f5b6a0e7bffda8cdffdd8206fed3f5c1f294e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Vinot?= Date: Wed, 20 Aug 2014 15:54:21 +0200 Subject: [PATCH] fix subscriber names, update default config --- bin/Helper.py | 4 ++-- bin/ZMQ_PubSub_Categ.py | 3 +-- bin/ZMQ_Sub_CreditCards_Q.py | 2 +- bin/ZMQ_Sub_Mails_Q.py | 2 +- bin/ZMQ_Sub_Onion_Q.py | 2 +- bin/ZMQ_Sub_Urls_Q.py | 2 +- bin/packages/config.cfg.sample | 5 ++++- 7 files changed, 11 insertions(+), 9 deletions(-) diff --git a/bin/Helper.py b/bin/Helper.py index 8e3bade2..d04b8675 100755 --- a/bin/Helper.py +++ b/bin/Helper.py @@ -30,6 +30,7 @@ class Redis_Queues(object): self.subscriber_name = subscriber_name self.sub_channel = self.config.get(conf_section, conf_channel) + self.redis_channel = self.sub_channel + self.subscriber_name # Redis Queue config_section = "Redis_Queues" @@ -61,7 +62,7 @@ class Redis_Queues(object): self.pub_socket.send('{} {}'.format(self.pub_channel, msg)) def redis_rpop(self): - return self.r_queues.rpop(self.sub_channel + self.subscriber_name) + return self.r_queues.rpop(self.redis_channel) def redis_queue_shutdown(self, is_queue=False): if is_queue: @@ -72,7 +73,6 @@ class Redis_Queues(object): return self.r_queues.srem('SHUTDOWN_FLAGS', flag) def redis_queue_subscribe(self, publisher): - self.redis_channel = self.sub_channel + self.subscriber_name publisher.info("Suscribed to channel {}".format(self.sub_channel)) while True: msg = self.sub_socket.recv() diff --git a/bin/ZMQ_PubSub_Categ.py b/bin/ZMQ_PubSub_Categ.py index fa0ef533..8a8d91c1 100755 --- a/bin/ZMQ_PubSub_Categ.py +++ b/bin/ZMQ_PubSub_Categ.py @@ -50,13 +50,12 @@ if __name__ == "__main__": config_section = 'PubSub_Words' config_channel = 'channel_0' - subscriber_name = 'pubcateg' + subscriber_name = 'categ' h = Helper.Redis_Queues(config_section, config_channel, subscriber_name) # Publisher pub_config_section = 'PubSub_Categ' - h.zmq_pub(pub_config_section, None) # SCRIPT PARSER # diff --git a/bin/ZMQ_Sub_CreditCards_Q.py b/bin/ZMQ_Sub_CreditCards_Q.py index 46bc33e9..cec6f421 100755 --- a/bin/ZMQ_Sub_CreditCards_Q.py +++ b/bin/ZMQ_Sub_CreditCards_Q.py @@ -11,7 +11,7 @@ if __name__ == "__main__": config_section = 'PubSub_Categ' config_channel = 'channel_0' - subscriber_name = 'creditcard_categ' + subscriber_name = 'cards' h = Helper.Redis_Queues(config_section, config_channel, subscriber_name) h.zmq_sub(config_section) diff --git a/bin/ZMQ_Sub_Mails_Q.py b/bin/ZMQ_Sub_Mails_Q.py index 4fe630b5..0f58fb7d 100755 --- a/bin/ZMQ_Sub_Mails_Q.py +++ b/bin/ZMQ_Sub_Mails_Q.py @@ -10,7 +10,7 @@ if __name__ == "__main__": config_section = 'PubSub_Categ' config_channel = 'channel_1' - subscriber_name = 'mails_categ' + subscriber_name = 'emails' h = Helper.Redis_Queues(config_section, config_channel, subscriber_name) h.zmq_sub(config_section) diff --git a/bin/ZMQ_Sub_Onion_Q.py b/bin/ZMQ_Sub_Onion_Q.py index 6d239203..c979e104 100755 --- a/bin/ZMQ_Sub_Onion_Q.py +++ b/bin/ZMQ_Sub_Onion_Q.py @@ -27,7 +27,7 @@ if __name__ == "__main__": config_section = 'PubSub_Categ' config_channel = 'channel_2' - subscriber_name = 'onion_categ' + subscriber_name = 'tor' h = Helper.Redis_Queues(config_section, config_channel, subscriber_name) h.zmq_sub(config_section) diff --git a/bin/ZMQ_Sub_Urls_Q.py b/bin/ZMQ_Sub_Urls_Q.py index b083090e..4f264d9a 100755 --- a/bin/ZMQ_Sub_Urls_Q.py +++ b/bin/ZMQ_Sub_Urls_Q.py @@ -11,7 +11,7 @@ if __name__ == "__main__": config_section = 'PubSub_Categ' config_channel = 'channel_3' - subscriber_name = 'web_categ' + subscriber_name = 'urls' h = Helper.Redis_Queues(config_section, config_channel, subscriber_name) h.zmq_sub(config_section) diff --git a/bin/packages/config.cfg.sample b/bin/packages/config.cfg.sample index daeabd83..c14477d3 100644 --- a/bin/packages/config.cfg.sample +++ b/bin/packages/config.cfg.sample @@ -56,7 +56,10 @@ channel_0 = words [PubSub_Categ] adress = tcp://127.0.0.1:5003 -#Channels are dynamic (1 channel per categ) +channel_0 = creditcard_categ +channel_1 = mails_categ +channel_2 = onion_categ +channel_3 = web_categ [PubSub_Url] adress = tcp://127.0.0.1:5004