我有一个程序,它通过一个文件路径进行解析,得到以某个结尾结束的所有文件。然后我必须使用subaccess来创建这些列表,以运行msbuild并打印结果。你知道吗
MSprompt = 'C:\Windows\Microsoft.NET\Framework64\\v4.0.30319\\MSBuild.exe' #MSPrompt is the string that is used w/ the subprocess function to open up MSBuild and run it correctly
MSfilename= "C:\\Users\\bgbesase\\Documents\\Brent\\Code\\Visual Studio\\"
def getUnitTest(path):
foundFiles = []
foundPathUpToUnitTests = []
for r,d,f in os.walk(path):
for files in f:
if files.endswith('.UnitTests.vbproj'):
path2 = os.path.split(files)
#print path2
foundFiles.append(path2)
for lines in path2:
if lines.endswith('.vbproj'):
s = lines.strip('vbproj')
print s
foundPathUpToUnitTests.append(s)
foundFiles= [str(value[1]) for value in foundFiles]
return foundFiles
foundFiles2 = [ str(value for value in file if value) for file in foundFiles]
print foundFiles2
return foundPathUpToUnitTests
FoundFiles是一个列表,由以'结尾的文件名元组组成。单元测试.vbproj'
foundFiles = [
bb.APDS.UnitTests.vbproj
bb.DatabaseAPI.UnitTests.vbproj
bb.DataManagement.UnitTests.vbproj
bb.FormControls.UnitTests.vbproj
bb.Geometry.UnitTests.vbproj ]
foundPathUpToUnitTests是一个列表,它与foundFiles中的值相同,只是没有vb.proj程序部分。你知道吗
foundPathUpToUnitTests = [
bb.APDS.UnitTests.
bb.DatabaseAPI.UnitTests.
bb.DataManagement.UnitTests.
bb.FormControls.UnitTests. ]
子进程的功能如下:
def runMSBuild(foundFiles2, foundPathUpToUnitTests):
p = subprocess.Popen([msprompt, MSfilename + foundFiles2 + "\\" + foundPathUpToUnitTests], shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
for line in p.stdout.readlines():
print line,
retval = p.wait()
当我用MSpromt和MSFilename正常运行它时,我需要做的是创建一个循环,从foundFiles中获取第一个值,foundpathuptunittests并使用连接来获取正确的文件路径,这样MSBuild就可以正常运行了,我不知道怎么做。任何帮助都将不胜感激我已经坚持了一段时间了,提前谢谢!你知道吗
目前没有回答
相关问题 更多 >
编程相关推荐