[MediaWiki-commits] [Gerrit] wikimedia...tools[master]: Make PayPal audit mirror to Redis
jenkins-bot has submitted this change and it was merged. Change subject: Make PayPal audit mirror to Redis .. Make PayPal audit mirror to Redis Add a new wrapper for talking to redis, and have the paypal parser push to redis as well as stomp. Bug: T130308 Change-Id: I6f16814234ac1a492d8cbdbe236d8d936f8122e3 --- M audit/paypal/SarFile.py M audit/paypal/TrrFile.py M audit/paypal/config.yaml.example A queue/redis_wrap.py A queue/requirements.txt 5 files changed, 47 insertions(+), 0 deletions(-) Approvals: Ejegg: Looks good to me, approved jenkins-bot: Verified diff --git a/audit/paypal/SarFile.py b/audit/paypal/SarFile.py index f5f77ef..0c97753 100644 --- a/audit/paypal/SarFile.py +++ b/audit/paypal/SarFile.py @@ -6,6 +6,7 @@ from process.logging import Logger as log from process.globals import config from queue.stomp_wrap import Stomp +from queue.redis_wrap import Redis import ppreport from civicrm.civicrm import Civicrm @@ -116,3 +117,8 @@ self.stomp = Stomp() self.stomp.send('recurring', msg) + +if not self.redis: +self.redis = Redis() + +self.redis.send('recurring', msg) diff --git a/audit/paypal/TrrFile.py b/audit/paypal/TrrFile.py index 42db7f8..8527116 100644 --- a/audit/paypal/TrrFile.py +++ b/audit/paypal/TrrFile.py @@ -8,6 +8,7 @@ from process.logging import Logger as log from process.globals import config from queue.stomp_wrap import Stomp +from queue.redis_wrap import Redis import ppreport from civicrm.civicrm import Civicrm @@ -16,6 +17,7 @@ class TrrFile(object): VERSION = [4, 8] stomp = None +redis = None # FIXME: these are version 8 headers, we would fail on multi-part v4 files... column_headers = [ "Column Type", @@ -193,6 +195,11 @@ self.stomp.send(queue, msg) +if not self.redis: +self.redis = Redis() + +self.redis.send(queue, msg) + def normalize_recurring(self, msg): 'Synthesize a raw PayPal message' diff --git a/audit/paypal/config.yaml.example b/audit/paypal/config.yaml.example index b842172..100275d 100644 --- a/audit/paypal/config.yaml.example +++ b/audit/paypal/config.yaml.example @@ -28,6 +28,15 @@ donations: /queue/donations recurring: /queue/recurring +redis: +server: localhost +port: 6379 +password: pass +queues: +refund: refund +donations: donations +recurring: recurring + api: # url: "https://api-3t.paypal.com/nvp"; url: "https://api-3t.sandbox.paypal.com/nvp"; diff --git a/queue/redis_wrap.py b/queue/redis_wrap.py new file mode 100644 index 000..570788b --- /dev/null +++ b/queue/redis_wrap.py @@ -0,0 +1,24 @@ +from process.globals import config +from process.logging import Logger as log + +import json +import redis + +class Redis(object): + +conn = None + +def __init__(self): +if not config.no_effect: +self.conn = redis.Redis(host=config.redis.server, port=config.redis.port, password=config.redis.password) + +def send(self, queue, msg): + +if config.no_effect: +log.info("not queueing message. " + json.dumps(msg)) +return + +if config.redis.queues[queue]: +self.conn.rpush(config.redis.queues[queue], msg) +else: +self.conn.rpush(queue, msg) diff --git a/queue/requirements.txt b/queue/requirements.txt new file mode 100644 index 000..74b362f --- /dev/null +++ b/queue/requirements.txt @@ -0,0 +1 @@ +redis \ No newline at end of file -- To view, visit https://gerrit.wikimedia.org/r/307433 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I6f16814234ac1a492d8cbdbe236d8d936f8122e3 Gerrit-PatchSet: 5 Gerrit-Project: wikimedia/fundraising/tools Gerrit-Branch: master Gerrit-Owner: XenoRyet Gerrit-Reviewer: Awight Gerrit-Reviewer: Ejegg Gerrit-Reviewer: XenoRyet Gerrit-Reviewer: jenkins-bot <> ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] wikimedia...tools[master]: Make PayPal audit mirror to Redis
XenoRyet has uploaded a new change for review. https://gerrit.wikimedia.org/r/307632 Change subject: Make PayPal audit mirror to Redis .. Make PayPal audit mirror to Redis Add a new wrapper for talking to redis, and have the paypal parser push to redis as well as stomp. Bug: T130308 Change-Id: Ie51f237ee0c8d034fb47ea328ca9ea3312e78f87 --- M audit/paypal/SarFile.py M audit/paypal/TrrFile.py A queue/redis_wrap.py A requirements.txt 4 files changed, 36 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/wikimedia/fundraising/tools refs/changes/32/307632/1 diff --git a/audit/paypal/SarFile.py b/audit/paypal/SarFile.py index f5f77ef..0c97753 100644 --- a/audit/paypal/SarFile.py +++ b/audit/paypal/SarFile.py @@ -6,6 +6,7 @@ from process.logging import Logger as log from process.globals import config from queue.stomp_wrap import Stomp +from queue.redis_wrap import Redis import ppreport from civicrm.civicrm import Civicrm @@ -116,3 +117,8 @@ self.stomp = Stomp() self.stomp.send('recurring', msg) + +if not self.redis: +self.redis = Redis() + +self.redis.send('recurring', msg) diff --git a/audit/paypal/TrrFile.py b/audit/paypal/TrrFile.py index 42db7f8..8527116 100644 --- a/audit/paypal/TrrFile.py +++ b/audit/paypal/TrrFile.py @@ -8,6 +8,7 @@ from process.logging import Logger as log from process.globals import config from queue.stomp_wrap import Stomp +from queue.redis_wrap import Redis import ppreport from civicrm.civicrm import Civicrm @@ -16,6 +17,7 @@ class TrrFile(object): VERSION = [4, 8] stomp = None +redis = None # FIXME: these are version 8 headers, we would fail on multi-part v4 files... column_headers = [ "Column Type", @@ -193,6 +195,11 @@ self.stomp.send(queue, msg) +if not self.redis: +self.redis = Redis() + +self.redis.send(queue, msg) + def normalize_recurring(self, msg): 'Synthesize a raw PayPal message' diff --git a/queue/redis_wrap.py b/queue/redis_wrap.py new file mode 100644 index 000..1ff63f1 --- /dev/null +++ b/queue/redis_wrap.py @@ -0,0 +1,22 @@ +from process.globals import config +from process.logging import Logger as log +import process.version_stamp + +import json +import redis + +class Redis(object): + +conn = None + +def __init__(self): +if not config.no_effect: +self.conn = redis.Redis(config.redis.server, config.redis.password, config.redis.port) + +def send(self, queue, msg): + +if config.no_effect: +log.info("not queueing message. " + json.dumps(msg)) +return + +self.conn.rpush(config.redis.queues[queue], msg) diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 000..74b362f --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +redis \ No newline at end of file -- To view, visit https://gerrit.wikimedia.org/r/307632 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ie51f237ee0c8d034fb47ea328ca9ea3312e78f87 Gerrit-PatchSet: 1 Gerrit-Project: wikimedia/fundraising/tools Gerrit-Branch: master Gerrit-Owner: XenoRyet ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] wikimedia...tools[master]: Make Paypal audit mirror to Redis
XenoRyet has uploaded a new change for review. https://gerrit.wikimedia.org/r/307433 Change subject: Make Paypal audit mirror to Redis .. Make Paypal audit mirror to Redis Add a new wrapper for talking to redis, and have the paypal parser push to redis as well as stomp. Bug: T130308 Change-Id: I6f16814234ac1a492d8cbdbe236d8d936f8122e3 --- M audit/paypal/SarFile.py M audit/paypal/TrrFile.py A queue/redis_wrap.py 3 files changed, 36 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/wikimedia/fundraising/tools refs/changes/33/307433/1 diff --git a/audit/paypal/SarFile.py b/audit/paypal/SarFile.py index f5f77ef..0c97753 100644 --- a/audit/paypal/SarFile.py +++ b/audit/paypal/SarFile.py @@ -6,6 +6,7 @@ from process.logging import Logger as log from process.globals import config from queue.stomp_wrap import Stomp +from queue.redis_wrap import Redis import ppreport from civicrm.civicrm import Civicrm @@ -116,3 +117,8 @@ self.stomp = Stomp() self.stomp.send('recurring', msg) + +if not self.redis: +self.redis = Redis() + +self.redis.send('recurring', msg) diff --git a/audit/paypal/TrrFile.py b/audit/paypal/TrrFile.py index 42db7f8..8527116 100644 --- a/audit/paypal/TrrFile.py +++ b/audit/paypal/TrrFile.py @@ -8,6 +8,7 @@ from process.logging import Logger as log from process.globals import config from queue.stomp_wrap import Stomp +from queue.redis_wrap import Redis import ppreport from civicrm.civicrm import Civicrm @@ -16,6 +17,7 @@ class TrrFile(object): VERSION = [4, 8] stomp = None +redis = None # FIXME: these are version 8 headers, we would fail on multi-part v4 files... column_headers = [ "Column Type", @@ -193,6 +195,11 @@ self.stomp.send(queue, msg) +if not self.redis: +self.redis = Redis() + +self.redis.send(queue, msg) + def normalize_recurring(self, msg): 'Synthesize a raw PayPal message' diff --git a/queue/redis_wrap.py b/queue/redis_wrap.py new file mode 100644 index 000..319851c --- /dev/null +++ b/queue/redis_wrap.py @@ -0,0 +1,23 @@ +from process.globals import config +from process.logging import Logger as log +import process.version_stamp + +import json +import redis + +class Redis(object): + +conn = None + +def __init__(self): +if not config.no_effect: +self.conn = redis.Redis(config.redis.server, config.redis.port) + + +def send(self, queue, msg): + +if config.no_effect: +log.info("not queueing message. " + json.dumps(msg)) +return + +self.conn.rpush(queue, msg) \ No newline at end of file -- To view, visit https://gerrit.wikimedia.org/r/307433 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I6f16814234ac1a492d8cbdbe236d8d936f8122e3 Gerrit-PatchSet: 1 Gerrit-Project: wikimedia/fundraising/tools Gerrit-Branch: master Gerrit-Owner: XenoRyet ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits