aboutsummaryrefslogtreecommitdiff
path: root/rpkid/portal-gui/scripts/load_csv.py
diff options
context:
space:
mode:
authorRob Austein <sra@hactrn.net>2011-10-05 17:45:34 +0000
committerRob Austein <sra@hactrn.net>2011-10-05 17:45:34 +0000
commitf7c79af8743b7142e438e5db0af960cf91938b23 (patch)
treece7c8521f681db0d45800f0231c0de596b27499a /rpkid/portal-gui/scripts/load_csv.py
parent72e42a6508ff19a315a0257dda4a710bc195dffa (diff)
Stop abusing RuntimeError. This closes #52.
svn path=/rpkid/portal-gui/scripts/load_csv.py; revision=4015
Diffstat (limited to 'rpkid/portal-gui/scripts/load_csv.py')
-rwxr-xr-xrpkid/portal-gui/scripts/load_csv.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/rpkid/portal-gui/scripts/load_csv.py b/rpkid/portal-gui/scripts/load_csv.py
index ebb995b6..44d08829 100755
--- a/rpkid/portal-gui/scripts/load_csv.py
+++ b/rpkid/portal-gui/scripts/load_csv.py
@@ -44,6 +44,11 @@ print 'processing csv files for resource handle', handle
conf = models.Conf.objects.get(handle=handle)
+class RangeError(Exception):
+ """
+ Problem with ASN range or address range.
+ """
+
# every parent has a favorite
def best_child(address_range, parent, parent_range):
'''Return the child address range that is the closest match, or
@@ -56,7 +61,7 @@ def best_child(address_range, parent, parent_range):
return best_child(address_range, q, t)
# check for overlap
if t.min <= address_range.min <= t.max or t.min <= address_range.max <= t.max:
- raise RuntimeError, \
+ raise RangeError, \
'can not handle overlapping ranges: %s and %s' % (address_range, t)
return parent, parent_range
@@ -79,7 +84,7 @@ def get_or_create_prefix(address_range):
# there should only ever be a single matching prefix
break
else:
- raise RuntimeError, '%s does not match any received address range.' % (
+ raise RangeError, '%s does not match any received address range.' % (
address_range,)
# find the best match among the children + grandchildren
@@ -97,7 +102,7 @@ def get_or_create_asn(asn):
asn_set = models.Asn.objects.filter(lo__lte=asn.min, hi__gte=asn.max,
from_cert__parent__in=conf.parents.all())
if not asn_set:
- raise RuntimeError, '%s does not match any received AS range' % (asn,)
+ raise RangeError, '%s does not match any received AS range' % (asn,)
best = best_child(asn, asn_set[0], asn_set[0].as_resource_range())[0]
print 'best match for %s is %s' % (asn, best)
if best.lo != asn.min or best.hi != asn.max: