diff --git a/tools/automate/automate.py b/tools/automate/automate.py index ca36a310f..9b3fed8f0 100644 --- a/tools/automate/automate.py +++ b/tools/automate/automate.py @@ -48,14 +48,25 @@ def get_svn_info(path): rev = 'None' if path[0:4] == 'http' or os.path.exists(path): try: - 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'] + if sys.platform == 'win32': + # Force use of the SVN version bundled with depot_tools. + svn = 'svn.bat' + else: + svn = 'svn' + (stream_in, stream_out, stream_err) = os.popen3(svn+' info --xml '+path) + err = stream_err.read() + if err == '': + tree = ET.ElementTree(ET.fromstring(stream_out.read())) + entry = tree.getroot().find('entry') + url = entry.find('url').text + rev = entry.attrib['revision'] + else: + raise Exception("Failed to execute svn info:\n"+err+"\n") except IOError, (errno, strerror): sys.stderr.write('Failed to read svn info: '+strerror+"\n") raise + except: + raise return {'url': url, 'revision': rev} def download_and_extract(src, target, contents_prefix): @@ -299,6 +310,9 @@ if not os.path.exists(depot_tools_dir): # checkout depot_tools run('svn checkout '+depot_tools_url+' '+depot_tools_dir, download_dir) +# Add depot_tools to the system path +sys.path.insert(1, depot_tools_dir) + # check if the "chromium" directory exists chromium_dir = os.path.join(download_dir, 'chromium') if not os.path.exists(chromium_dir): diff --git a/tools/svn_util.py b/tools/svn_util.py index 159d7ed7e..e98dce2f0 100644 --- a/tools/svn_util.py +++ b/tools/svn_util.py @@ -23,14 +23,25 @@ def get_svn_info(path): rev = 'None' if path[0:4] == 'http' or os.path.exists(path): try: - 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'] + if sys.platform == 'win32': + # Force use of the SVN version bundled with depot_tools. + svn = 'svn.bat' + else: + svn = 'svn' + (stream_in, stream_out, stream_err) = os.popen3(svn+' info --xml '+path) + err = stream_err.read() + if err == '': + tree = ET.ElementTree(ET.fromstring(stream_out.read())) + entry = tree.getroot().find('entry') + url = entry.find('url').text + rev = entry.attrib['revision'] + else: + raise Exception("Failed to execute svn info:\n"+err+"\n") except IOError, (errno, strerror): sys.stderr.write('Failed to read svn info: '+strerror+"\n") raise + except: + raise return {'url': url, 'revision': rev} def get_revision(path = '.'):