From 82cca242e35a35624d6da4313745a3372685344b Mon Sep 17 00:00:00 2001 From: Michael DeHaan Date: Tue, 24 Jul 2012 20:16:35 -0400 Subject: [PATCH] use AnsibleError so that if there is an error it does not print a traceback --- lib/ansible/inventory/expand_hosts.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/ansible/inventory/expand_hosts.py b/lib/ansible/inventory/expand_hosts.py index ecccc1985f..061abd9e10 100644 --- a/lib/ansible/inventory/expand_hosts.py +++ b/lib/ansible/inventory/expand_hosts.py @@ -31,6 +31,8 @@ Note that when beg is specified with left zero padding, then the length of end must be the same as that of beg, else a exception is raised. ''' +from ansible import errors + def detect_range(line = None): ''' A helper function that checks a given host line to see if it contains @@ -70,19 +72,19 @@ def expand_hostname_range(line = None): (head, nrange, tail) = line.replace('[','|').replace(']','|').split('|') bounds = nrange.split(":") if len(bounds) != 2: - raise ValueError("host range incorrectly specified") + raise errors.AnsibleError("host range incorrectly specified") beg = bounds[0] end = bounds[1] if not beg: beg = "0" if not end: - raise ValueError("host range end value missing") + raise errors.AnsibleError("host range end value missing") if beg[0] == '0' and len(beg) > 1: rlen = len(beg) # range length formatting hint else: rlen = None if rlen > 1 and rlen != len(end): - raise ValueError("host range format incorrectly specified!") + raise errors.AnsibleError("host range format incorrectly specified!") for _ in range(int(beg), int(end)+1): if rlen: