mirror of
				https://bitbucket.org/chromiumembedded/cef
				synced 2025-06-05 21:39:12 +02:00 
			
		
		
		
	Parse svn info output using XML format.
git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@1389 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
		| @@ -12,6 +12,7 @@ import subprocess | ||||
| import sys | ||||
| import tempfile | ||||
| import urllib | ||||
| import xml.etree.ElementTree as ET | ||||
| import zipfile | ||||
|  | ||||
| # default URL values | ||||
| @@ -40,19 +41,18 @@ def check_url(url): | ||||
|       return url | ||||
|   sys.stderr.write('Invalid URL: '+url+"\n") | ||||
|   raise Exception('Invalid URL: '+url) | ||||
|                                 | ||||
|  | ||||
| def get_svn_info(path): | ||||
|   """ Retrieves the URL and revision from svn info. """ | ||||
|   url = 'None' | ||||
|   rev = 'None' | ||||
|   if path[0:4] == 'http' or os.path.exists(path): | ||||
|     try: | ||||
|       stream = os.popen('svn info '+path) | ||||
|       for line in stream: | ||||
|         if line[0:4] == "URL:": | ||||
|           url = check_url(line[5:-1]) | ||||
|         elif line[0:9] == "Revision:": | ||||
|           rev = str(int(line[10:-1])) | ||||
|       stream = os.popen('svn info --xml '+path) | ||||
|       tree = ET.ElementTree(ET.fromstring(stream.read())) | ||||
|       entry = tree.getroot().find('entry') | ||||
|       url = entry.find('url').text | ||||
|       rev = entry.attrib['revision'] | ||||
|     except IOError, (errno, strerror): | ||||
|       sys.stderr.write('Failed to read svn info: '+strerror+"\n") | ||||
|       raise | ||||
|   | ||||
| @@ -5,6 +5,7 @@ | ||||
| import os | ||||
| import sys | ||||
| import urllib | ||||
| import xml.etree.ElementTree as ET | ||||
|  | ||||
| def check_url(url): | ||||
|   """ Check the URL and raise an exception if invalid. """ | ||||
| @@ -22,12 +23,11 @@ def get_svn_info(path): | ||||
|   rev = 'None' | ||||
|   if path[0:4] == 'http' or os.path.exists(path): | ||||
|     try: | ||||
|       stream = os.popen('svn info '+path) | ||||
|       for line in stream: | ||||
|         if line[0:4] == "URL:": | ||||
|           url = check_url(line[5:-1]) | ||||
|         elif line[0:9] == "Revision:": | ||||
|           rev = str(int(line[10:-1])) | ||||
|       stream = os.popen('svn info --xml '+path) | ||||
|       tree = ET.ElementTree(ET.fromstring(stream.read())) | ||||
|       entry = tree.getroot().find('entry') | ||||
|       url = entry.find('url').text | ||||
|       rev = entry.attrib['revision'] | ||||
|     except IOError, (errno, strerror): | ||||
|       sys.stderr.write('Failed to read svn info: '+strerror+"\n") | ||||
|       raise | ||||
|   | ||||
		Reference in New Issue
	
	Block a user