Browse files

Merge branch 'master' of github.com:pkwarren/zenoss-dev

  • Loading branch information...
2 parents 2e96934 + 33698df commit b8f68f30fbda0e1db725556f499bcaf99cfbb3f3 Philip K. Warren committed Apr 11, 2012
Showing with 28 additions and 12 deletions.
  1. +21 −12 lib/python/zenossdev/sandbox.py
  2. +7 −0 zenossrc
View
33 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'
@@ -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):
@@ -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
@@ -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):
View
7 zenossrc
@@ -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

0 comments on commit b8f68f3

Please sign in to comment.