jenkins-bot has submitted this change and it was merged.
Change subject: Fix socket errors: buffer Apertium stdout
......................................................................
Fix socket errors: buffer Apertium stdout
Change-Id: I53bbc76df0099e092b92fee5a186a370f2dbe744
---
M mt/Apertium.js
A mt/apertium.py
2 files changed, 17 insertions(+), 1 deletion(-)
Approvals:
Santhosh: Looks good to me, approved
jenkins-bot: Verified
diff --git a/mt/Apertium.js b/mt/Apertium.js
index ced3afb..602e11a 100644
--- a/mt/Apertium.js
+++ b/mt/Apertium.js
@@ -90,7 +90,7 @@
deferred = Q.defer();
rangedSourceText = getRangedText( sourceText );
apertium = spawn(
- 'apertium', [ sourceLang + '-' + targetLang, '-u', '-f', 'html'
], {
+ 'python', [ 'mt/apertium.py', sourceLang + '-' + targetLang,
'-u', '-f', 'html' ], {
stdio: 'pipe',
env: {
PATH: process.env.PATH,
diff --git a/mt/apertium.py b/mt/apertium.py
new file mode 100644
index 0000000..bbc53cf
--- /dev/null
+++ b/mt/apertium.py
@@ -0,0 +1,16 @@
+#!/usr/bin/env python
+
+# Apertium 3.2 fails when spawned from nodejs, because it is a shell script
+# running a unix pipeline, and nodejs stdout is a socket rather than a pipe.
+# This wrapper script just provides an intermediate buffer around stdout.
+# It is written in python rather than shell as there are fewer security issues
+# and security restriction problems.
+
+import sys
+import subprocess
+
+args = ['apertium']
+args += sys.argv[1:]
+process = subprocess.Popen(args, stdin=sys.stdin, stdout=subprocess.PIPE)
+for line in process.stdout:
+ sys.stdout.write(line)
--
To view, visit https://gerrit.wikimedia.org/r/148968
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I53bbc76df0099e092b92fee5a186a370f2dbe744
Gerrit-PatchSet: 5
Gerrit-Project: mediawiki/services/cxserver
Gerrit-Branch: master
Gerrit-Owner: Divec <[email protected]>
Gerrit-Reviewer: KartikMistry <[email protected]>
Gerrit-Reviewer: Santhosh <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits