1
1
import subprocess
2
- import sys , imp , codecs , shlex
2
+ import sys , imp , codecs
3
3
import node_variables
4
4
5
5
class NodeJS (object ):
@@ -8,40 +8,40 @@ def eval(self, js, eval_type="eval", strict_mode=False):
8
8
js = ("'use strict'; " if strict_mode else "" ) + js
9
9
eval_type = "--eval" if eval_type == "eval" else "--print"
10
10
11
- p = subprocess .Popen (shlex . quote ( node_variables .NODE_JS_PATH_EXECUTABLE ) + " " + shlex . quote ( eval_type ) + " " + shlex . quote ( js ), shell = True , stdout = subprocess .PIPE , stderr = subprocess .PIPE )
11
+ p = subprocess .Popen ([ node_variables .NODE_JS_PATH_EXECUTABLE , eval_type , js ], shell = True , stdout = subprocess .PIPE , stderr = subprocess .PIPE )
12
12
lines = ""
13
13
14
14
# check for errors
15
15
for line in p .stderr .readlines ():
16
- lines += codecs .decode (line )
16
+ lines += codecs .decode (line , "utf-8" , "ignore" )
17
17
18
18
if len (lines ) > 0 :
19
19
p .terminate ()
20
20
raise Exception (lines )
21
21
22
22
lines = ""
23
23
for line in p .stdout .readlines ():
24
- lines += codecs .decode (line )
24
+ lines += codecs .decode (line , "utf-8" , "ignore" )
25
25
p .terminate ()
26
26
27
27
return lines
28
28
29
29
def getCurrentNodeJSVersion (self ) :
30
30
31
- p = subprocess .Popen (shlex . quote ( node_variables .NODE_JS_PATH_EXECUTABLE ) + " -v" , shell = True , stdout = subprocess .PIPE , stderr = subprocess .PIPE )
31
+ p = subprocess .Popen ([ node_variables .NODE_JS_PATH_EXECUTABLE , '-v' ] , shell = True , stdout = subprocess .PIPE , stderr = subprocess .PIPE )
32
32
lines = ""
33
33
34
34
# check for errors
35
35
for line in p .stderr .readlines ():
36
- lines += codecs .decode (line )
36
+ lines += codecs .decode (line , "utf-8" , "ignore" )
37
37
38
38
if len (lines ) > 0 :
39
39
p .terminate ()
40
40
raise Exception (lines )
41
41
42
42
lines = ""
43
43
for line in p .stdout .readlines ():
44
- lines += codecs .decode (line )
44
+ lines += codecs .decode (line , "utf-8" , "ignore" )
45
45
p .terminate ()
46
-
47
- return lines .strip ()
46
+
47
+ return lines .strip ()
0 commit comments