summaryrefslogtreecommitdiffstats
path: root/krebs/5pkgs/simple/Reaktor/scripts
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2018-04-03 23:20:32 +0200
committertv <tv@krebsco.de>2018-04-03 23:20:32 +0200
commiteb684c7618697b370cf69c175ef43e0ced361407 (patch)
tree2d81470fdf4063379270cfa32a2a3b6c4aa01008 /krebs/5pkgs/simple/Reaktor/scripts
parent3108c4323806eee9798a6ba42977ea8f16343731 (diff)
parent1604ecfc706d2921248d0c9ac7cef02274842272 (diff)
Merge remote-tracking branch 'prism/master'
Diffstat (limited to 'krebs/5pkgs/simple/Reaktor/scripts')
-rw-r--r--krebs/5pkgs/simple/Reaktor/scripts/sed-plugin.py17
1 files changed, 12 insertions, 5 deletions
diff --git a/krebs/5pkgs/simple/Reaktor/scripts/sed-plugin.py b/krebs/5pkgs/simple/Reaktor/scripts/sed-plugin.py
index da8e2f726..51ac7a071 100644
--- a/krebs/5pkgs/simple/Reaktor/scripts/sed-plugin.py
+++ b/krebs/5pkgs/simple/Reaktor/scripts/sed-plugin.py
@@ -18,20 +18,27 @@ def is_regex(line):
myre = re.compile(r'^s/(?:\\/|[^/])+/(?:\\/|[^/])*/[ig]?$')
return myre.match(line)
+
line = argv[1]
if is_regex(line):
last = d.get(usr, None)
if last:
from subprocess import Popen, PIPE
- p = Popen(['sed', line], stdin=PIPE, stdout=PIPE)
+ p = Popen(['sed', line], stdin=PIPE, stdout=PIPE, stderr=PIPE)
so, se = p.communicate(bytes("{}\n".format(last), "UTF-8"))
if p.returncode:
- print("something went wrong when trying to process your regex: {}".format(se.decode()))
+ print("something went wrong when trying to process your regex: {}".format(line.strip()))
ret = so.decode()
- print("\x1b[1m{}\x1b[0m meant: {}".format(usr, ret.strip()))
- if ret:
- d[usr] = ret
+ if len(ret) > 512:
+ print('message to long, skipped')
+ elif len(ret.split('\n')) > 5:
+ print('to many lines, skipped')
+ else:
+ if last.strip() != ret.strip():
+ print("\x1b[1m{}\x1b[0m meant: {}".format(usr, ret.strip()))
+ if ret:
+ d[usr] = ret
else:
print("no last message")