From d91d0c5fd96a36bae43ecf2aa0460f663655c0fd Mon Sep 17 00:00:00 2001 From: Stephen Gran Date: Sat, 9 May 2009 12:23:19 +0100 Subject: [PATCH] Moving away from string exceptions --- ud-generate | 9 +++++---- userdir_exceptions.py | 1 + 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/ud-generate b/ud-generate index 953be7f..8001012 100755 --- a/ud-generate +++ b/ud-generate @@ -28,6 +28,7 @@ import string, re, time, ldap, getopt, sys, os, pwd, posix, socket, base64, sha, shutil, errno, tarfile, grp from userdir_ldap import *; +from userdir_exceptions import * global Allowed; global CurrentHost; @@ -809,7 +810,7 @@ def GenSSHFP(l,File,HomePrefix): # Fetch all the hosts global HostAttrs if HostAttrs == None: - raise "No Hosts" + raise UDEmptyList, "No Hosts" for x in HostAttrs: if x[1].has_key("hostname") == 0 or \ @@ -905,7 +906,7 @@ def GenSSHKnown(l,File,mode=None): global HostAttrs if HostAttrs == None: - raise "No Hosts"; + raise UDEmptyList, "No Hosts" for x in HostAttrs: if x[1].has_key("hostname") == 0 or \ @@ -962,7 +963,7 @@ def GenHosts(l,File): ["hostname"]) if hostnames == None: - raise "No Hosts" + raise UDEmptyList, "No Hosts" seen = set() for x in hostnames: @@ -1027,7 +1028,7 @@ PasswdAttrs = l.search_s(BaseDn,ldap.SCOPE_ONELEVEL,"uid=*",\ "mailWhitelist", "sudoPassword", "objectClass", "accountStatus"]) if PasswdAttrs is None: - raise "No Users" + raise UDEmptyList, "No Users" # Fetch all the hosts HostAttrs = l.search_s(HostBaseDn,ldap.SCOPE_ONELEVEL,"sshRSAHostKey=*",\ diff --git a/userdir_exceptions.py b/userdir_exceptions.py index a1d775e..4e32307 100644 --- a/userdir_exceptions.py +++ b/userdir_exceptions.py @@ -25,6 +25,7 @@ UDERRORS = { "UDFormatError": """Exception raised for data format errors.""", "UDExecuteError": """Exception raised for subprocess execution errors.""", "UDNotAllowedError": """Exception raised for attempts to modify off-limits or disabled entries.""", + "UDEmptyList": """Exception raised for empty list objects.""", } def construct_udld_exception(name, description): -- 2.20.1