Python 项目没有修订属性时出错
输入:- 错误:-Python 项目没有修订属性时出错,python,Python,输入:- 错误:- CODE:- import shlex import os import sys import json import fileinput import pwd import itertools import subprocess import shutil from subprocess import Popen, PIPE, STDOUT import xml.etree.ElementTree as ET import re def manifest_data (n
CODE:-
import shlex
import os
import sys
import json
import fileinput
import pwd
import itertools
import subprocess
import shutil
from subprocess import Popen, PIPE, STDOUT
import xml.etree.ElementTree as ET
import re
def manifest_data (name):
print name
pattern = re.compile('refs/heads/(.*)')
tree = ET.parse('.repo/manifests/test.xml')
root = tree.getroot()
project = root.find("./project[@name='%s']" % name)
print project
if project != None:
revision = project.get('revision')
res = pattern.match(revision)
return res.group(1)
else:
default = root.find("./default")
return default.attrib.get('revision')
def main ():
branch_name = "jb_mr2"
print "branch_name"
print branch_name
projects = ['platform/vendor/google/proprietary/widevine','platform/external/bus','platform/test/code']
#if os.path.isdir('.repo') :
#print "Deleting .repo"
#shutil.rmtree('.repo')
RepoInitCmd = 'repo init -u git://git.quicinc.com/platform/manifest.git -b ' + branch_name
proc = subprocess.Popen(shlex.split(RepoInitCmd), stderr=subprocess.PIPE)
out, error = proc.communicate()
for project in projects :
branch = manifest_data(project)
print branch
if __name__ == '__main__':
main()
回溯(最近一次呼叫最后一次):
文件“branch_manifest.py”,第45行,在
main()
文件“branch_manifest.py”,第41行,主目录
分支=清单数据(项目)
清单数据中第23行的文件“branch_manifest.py”
res=模式匹配(修订版)
TypeError:应为字符串或缓冲区
您需要更改manifest\u data
如下:
Traceback (most recent call last):
File "branch_manifest.py", line 45, in <module>
main()
File "branch_manifest.py", line 41, in main
branch = manifest_data(project)
File "branch_manifest.py", line 23, in manifest_data
res = pattern.match(revision)
TypeError: expected string or buffer
Traceback (most recent call last):
File "branch_manifest.py", line 45, in <module>
main()
File "branch_manifest.py", line 41, in main
branch = manifest_data(project)
File "branch_manifest.py", line 23, in manifest_data
res = pattern.match(revision)
TypeError: expected string or buffer
def manifest_data (name):
....
if project != None:
revision = project.get('revision')
if revision:
res = pattern.match(revision)
return res.group(1)
default = root.find("./default")
return default.attrib.get('revision')