Skip to content
This repository has been archived by the owner on Jun 1, 2022. It is now read-only.

Commit

Permalink
Fix using under SVN 1.7.
Browse files Browse the repository at this point in the history
  • Loading branch information
Philip K. Warren committed Apr 7, 2012
1 parent 2bf8c72 commit 33698df
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 12 deletions.
33 changes: 21 additions & 12 deletions lib/python/zenossdev/sandbox.py
@@ -1,8 +1,10 @@
import os
from os.path import isdir, abspath, join, dirname
import re
import subprocess
from subprocess import check_output, CalledProcessError
import ConfigParser
from cStringIO import StringIO
import xml.etree.cElementTree as ET

CONFIG_FILE = os.path.expanduser('~/.zenossdev')
_CONFIG_SECTION = 'zenossdev'
Expand All @@ -17,6 +19,13 @@ def __getattr__(self, attr):
except ConfigParser.NoOptionError:
pass

def _svn_info_xml_parser(basedir):
xml_output = check_output(['svn','info','--xml',basedir])
sio = StringIO(xml_output)
et = ET.parse(sio)
sio.close()
return et

def load_config(filename=CONFIG_FILE):
parser = ConfigParser.SafeConfigParser()
if os.path.exists(filename):
Expand All @@ -41,6 +50,11 @@ def find_root_checkout(basedir=os.getcwd()):
directory. Returns the top-level path for the Zenoss Core or Zenoss
Enterprise checkout, or raises an exception if it isn't found.
"""
et = _svn_info_xml_parser(basedir)
if et:
for element in et.iter('wcroot-abspath'):
return abspath(element.text)

if not isdir(join(basedir, '.svn')):
raise Exception('Not in SVN repository')
prevdir = None
Expand All @@ -52,22 +66,17 @@ def find_root_checkout(basedir=os.getcwd()):
return curdir
prevdir = curdir
curdir = abspath(dirname(curdir))

raise Exception('Unable to find root directory in: %s', basedir)
raise Exception('Unable to find root directory in: %s' % basedir)

def find_base_url(svndir):
"""
Returns the root of the repository found in the given directory.
"""
cmd = ['svn', 'info', svndir]
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout, stderr = p.communicate()
if p.returncode:
raise Exception('Failed to run svn info: %s' % stderr)
for line in stdout.splitlines():
if line.startswith('Repository Root: '):
return line.split(': ', 1)[1]

et = _svn_info_xml_parser(svndir)
if et:
for element in et.iter('repository'):
for root_element in element.iterfind('root'):
return root_element.text
raise Exception('Unable to determine base url')

def is_toplevel(root_dir):
Expand Down
7 changes: 7 additions & 0 deletions zenossrc
Expand Up @@ -79,6 +79,13 @@ if [ ! -d "$ZENSRC" ]; then
echo -n "Zenoss Core Release [$zenoss_core_default]: "
read zenoss_core
zenoss_core=${zenoss_core:-"$zenoss_core_default"}
svn --non-interactive info "$ZENOSS_SVN_ROOT" > /dev/null
if [ $? -ne 0 ]; then
echo "Unable to authenticate to $ZENOSS_SVN_ROOT"
echo "Run this command to authenticate:"
echo " svn info $ZENOSS_SVN_ROOT --username <your_username>"
exit 1
fi
svn --non-interactive info "$ZENOSS_SVN_ROOT/$zenoss_core/inst" > /dev/null
if [ $? -ne 0 ]; then
echo "Invalid SVN url: $ZENOSS_SVN_ROOT/$zenoss_core" >&2
Expand Down

0 comments on commit 33698df

Please sign in to comment.