Getting the default revision value when there is no revision attribute for
project
INPUT:-
<?xml version="1.0" encoding="UTF-8"?>
<manifest>
<default revision="jb_2.5.4" remote="quic"/>
<project name="platform/vendor/google/proprietary/widevine"
path="vendor/widevine"
revision="refs/heads/jb_2.6"
x-grease-customer="none"
x-quic-dist="none"
x-ship="none" />
<project path="external/dbus" name="platform/external/bus"
revision="refs/heads/jb_2.5" x-ship="oss" x-quic-dist="la"
x-grease-customer="none"/>
<project path="external/connectivity" name="platform/test/code"
x-ship="oss" x-quic-dist="la" x-grease-customer="none"/>
</manifest>
Hi,
I have the following code which gets the revision value if it is present
for the input shown above,if there is not "revision=" field it bails out
with the error shown below..when there is no "revision=" tag I want to get
the "default revsion" tag in the input..any inputs on how to do this
withouth changing the existing functionality?
CODE:-
import shlex
import os
import sys
import json
import fileinput
import pwd
import itertools
import subprocess
from subprocess import Popen, PIPE, STDOUT
import xml.etree.ElementTree as ET
import re
def manifest_data (name):
pattern = re.compile('refs/heads/(.*)')
tree = ET.parse('.repo/manifests/test.xml')
root = tree.getroot()
project = root.find("./project[@name='%s']" % name)
revision = project.get('revision')
res = pattern.match(revision)
return res.group(1)
def main ():
branch_name = "jb_mr2"
print "branch_name"
print branch_name
projects =
['platform/vendor/google/proprietary/widevine','platform/external/bus','platform/test/code']
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()
ERROR:-
Traceback (most recent call last):
File "branch_manifest.py", line 35, in <module>
main()
File "branch_manifest.py", line 31, in main
branch = manifest_data(project)
File "branch_manifest.py", line 18, in manifest_data
revision = project.get('revision')
AttributeError: 'NoneType' object has no attribute 'get
No comments:
Post a Comment