Pārlūkot izejas kodu

set "shell = True" when call subprocess.Popen

On unix, when "shell = False" (default), the args must be a list of
args. While on Windows, filling args with a list causes problems. As a
trade-off, set the this flag and using a string as the command, although
this might sacrifice some performance, but that's not the main concern
in this script.

Signed-off-by: Heikki Hokkanen <hoxu@users.sf.net>
Shixin Zeng 17 gadus atpakaļ
vecāks
revīzija
a7f0f5ea50
1 mainītis faili ar 4 papildinājumiem un 4 dzēšanām
  1. 4
    4
      gitstats

+ 4
- 4
gitstats Parādīt failu

@@ -29,10 +29,10 @@ def getpipeoutput(cmds, quiet = False):
29 29
 	if not quiet:
30 30
 		print '>> ', beautify_name(cmds)
31 31
 		sys.stdout.flush()
32
-	p0 = subprocess.Popen(cmds[0], stdout = subprocess.PIPE)
32
+	p0 = subprocess.Popen(cmds[0], stdout = subprocess.PIPE, shell = True)
33 33
 	p = p0
34 34
 	for x in cmds[1:]:
35
-		p = subprocess.Popen(x, stdin = p0.stdout, stdout = subprocess.PIPE)
35
+		p = subprocess.Popen(x, stdin = p0.stdout, stdout = subprocess.PIPE, shell = True)
36 36
 		p0 = p
37 37
 	output = p.communicate()[0]
38 38
 	end = time.time()
@@ -132,7 +132,7 @@ class GitDataCollector(DataCollector):
132 132
 
133 133
 		# tags
134 134
 		self.tags = {}
135
-		lines = getpipeoutput((('git-show-ref', '--tags'),)).split('\n')
135
+		lines = getpipeoutput((('git-show-ref --tags'),)).split('\n')
136 136
 		for line in lines:
137 137
 			if len(line) == 0:
138 138
 				continue
@@ -142,7 +142,7 @@ class GitDataCollector(DataCollector):
142 142
 			(hash, tag) = splitted_str
143 143
 
144 144
 			tag = tag.replace('refs/tags/', '')
145
-			output = getpipeoutput((('git-log', '"%s" --pretty=format:"%%at %%an" -n 1' % hash),))
145
+			output = getpipeoutput((('git-log "%s" --pretty=format:"%%at %%an" -n 1' % hash),))
146 146
 			if len(output) > 0:
147 147
 				parts = output.split(' ')
148 148
 				stamp = 0