mirror of
https://github.com/chubin/cheat.sh.git
synced 2025-01-07 13:47:44 +03:00
lib/beautifier.py: start subprocess using gevent
This commit is contained in:
parent
7a0feb5dcd
commit
3646d517a5
@ -15,10 +15,14 @@ Exported functions:
|
|||||||
normalize(text, mode)
|
normalize(text, mode)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
from gevent.monkey import patch_all
|
||||||
|
from gevent.subprocess import Popen
|
||||||
|
patch_all()
|
||||||
|
|
||||||
|
# pylint: disable=wrong-import-position,wrong-import-order
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
import textwrap
|
import textwrap
|
||||||
import subprocess
|
|
||||||
import hashlib
|
import hashlib
|
||||||
import re
|
import re
|
||||||
|
|
||||||
@ -27,7 +31,6 @@ from tempfile import NamedTemporaryFile
|
|||||||
|
|
||||||
import redis
|
import redis
|
||||||
|
|
||||||
# pylint: disable=wrong-import-position,wrong-import-order
|
|
||||||
MYDIR = os.path.abspath(os.path.dirname(os.path.dirname('__file__')))
|
MYDIR = os.path.abspath(os.path.dirname(os.path.dirname('__file__')))
|
||||||
sys.path.append("%s/lib/" % MYDIR)
|
sys.path.append("%s/lib/" % MYDIR)
|
||||||
from languages_data import VIM_NAME
|
from languages_data import VIM_NAME
|
||||||
@ -196,7 +199,7 @@ def _run_vim_script(script_lines, text_lines):
|
|||||||
|
|
||||||
cmd = ["script", "-q", "-c",
|
cmd = ["script", "-q", "-c",
|
||||||
"vim -S %s %s" % (script_vim.name, textfile.name)]
|
"vim -S %s %s" % (script_vim.name, textfile.name)]
|
||||||
subprocess.Popen(cmd, shell=False, stdout=FNULL, stderr=FNULL, env=my_env).communicate()
|
Popen(cmd, shell=False, stdout=FNULL, stderr=FNULL, env=my_env).communicate()
|
||||||
|
|
||||||
return open(textfile.name, "r").read()
|
return open(textfile.name, "r").read()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user