Yuvipanda has submitted this change and it was merged.
Change subject: pep8 fixes + another commit rolled in because jenkins
......................................................................
pep8 fixes + another commit rolled in because jenkins
- Ignore everything after first newline (or \r)
Change-Id: I69266857d2600fa69f569addc9a1dd02098ba28b
---
M ircyall/redis2irc.py
M ircyall/web2redis.py
M tox.ini
3 files changed, 16 insertions(+), 8 deletions(-)
Approvals:
Yuvipanda: Looks good to me, approved
jenkins-bot: Verified
diff --git a/ircyall/redis2irc.py b/ircyall/redis2irc.py
index 610aadb..dc20991 100644
--- a/ircyall/redis2irc.py
+++ b/ircyall/redis2irc.py
@@ -33,7 +33,6 @@
self.log.info("...restarting Redis listener in a few seconds.")
yield from asyncio.sleep(5)
-
@asyncio.coroutine
def process_message(self):
# Create connection
diff --git a/ircyall/web2redis.py b/ircyall/web2redis.py
index e6e256b..b5c738e 100644
--- a/ircyall/web2redis.py
+++ b/ircyall/web2redis.py
@@ -1,28 +1,34 @@
import json
-import sqlite3
from flask import Flask, request
from redis import StrictRedis
app = Flask(__name__)
redis = StrictRedis()
+
@app.route('/v1/send', methods=['POST'])
def send():
# Validate, validate, validate!
- if not 'message' in request.form:
+ if 'message' not in request.form:
return 'No message found', 400
- if not 'channels' in request.form:
+ if 'channels' not in request.form:
return 'No channels found', 400
- if not 'token' in request.form:
+ if 'token' not in request.form:
return 'No token found', 400
+ message = request.form['message']
if message.startswith('/'):
return 'Message starts with /, not going to process', 400
+ if '\n' in message:
+ message = message.split('\n')[0] # Ignore everything after newline
+ if '\r' in message:
+ message = message.split('\r')[0] # Because I'm too lazy to use a
regex here >_>
+
data = {
- 'message': request.form['message'],
+ 'message': message,
'channels': request.form.getlist('channels')
}
redis.rpush('ircnotifier', json.dumps(data))
return repr(data)
if __name__ == '__main__':
- app.run(debug=True)
\ No newline at end of file
+ app.run(debug=True)
diff --git a/tox.ini b/tox.ini
index 27b068e..5d66156 100644
--- a/tox.ini
+++ b/tox.ini
@@ -2,4 +2,7 @@
commands = flake8
deps = flake8
basepython = python3
-max-line-length = 120
+
+[flake8]
+exclude = .tox
+max_line_length = 120
--
To view, visit https://gerrit.wikimedia.org/r/180334
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I69266857d2600fa69f569addc9a1dd02098ba28b
Gerrit-PatchSet: 6
Gerrit-Project: operations/software/ircyall
Gerrit-Branch: master
Gerrit-Owner: Yuvipanda <[email protected]>
Gerrit-Reviewer: Hashar <[email protected]>
Gerrit-Reviewer: Yuvipanda <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits