summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Tauber <asciimoo@gmail.com>2017-07-26 15:10:52 +0200
committerGitHub <noreply@github.com>2017-07-26 15:10:52 +0200
commit081f51db4ef057e34fc1b9934d0c0cc19427f512 (patch)
tree268611c14990d7ae399e8134af1cee6213dc051a
parent077d8efed85e468d863a52e8a32feb88ba158c11 (diff)
parentcda9f8593f97b9e9cfb22fd2953635d0c2b901ad (diff)
Merge pull request #980 from nikaiw/master
Avoid UnicodeEncodeError when redirecting standalone output
-rwxr-xr-xutils/standalone_searx.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/utils/standalone_searx.py b/utils/standalone_searx.py
index b19df4bae..223163639 100755
--- a/utils/standalone_searx.py
+++ b/utils/standalone_searx.py
@@ -25,6 +25,8 @@ path.append(realpath(dirname(realpath(__file__)) + '/../'))
# initialization
from json import dumps
from searx import settings
+import sys
+import codecs
import searx.query
import searx.search
import searx.engines
@@ -97,5 +99,6 @@ result_container_json = {
"paging": result_container.paging,
"results_number": result_container.results_number()
}
+sys.stdout = codecs.getwriter("UTF-8")(sys.stdout)
+sys.stdout.write(dumps(result_container_json, sort_keys=True, indent=4, ensure_ascii=False, encoding="utf-8", default=json_serial))
-print(dumps(result_container_json, sort_keys=True, indent=4, ensure_ascii=False, encoding="utf-8", default=json_serial))