Destring the error messages from the code.
1 parent 4ed879e commit 4ae8b5df137ebc1d58ebc601fcc3df7d2e22dc5c
@toor toor authored on 6 Apr 2005
Showing 1 changed file
View
34
mkapachepw.py
 
# Program Information
 
PROGNAME = "mkapachepw"
RCSID = "$Id: mkapachepw.py,v 1.114 2005/04/06 05:59:54 root Exp $"
RCSID = "$Id: mkapachepw.py,v 1.115 2005/04/06 06:18:21 toor Exp $"
VERSION = RCSID.split()[2]
 
# Copyright Information
 
 
CMDLINE = "# Command Line: %s\n" % " ".join(sys.argv)
TIMESTAMP = "# Created By %s %s On %s At %s\n" % (PROGNAME, VERSION, getfqdn(), time.asctime())
 
GID = 'GID'
GROUP = 'Group'
UID = 'UID'
USER = 'User'
 
 
#----------------------------------------------------------#
#####
# Error Messages
#####
 
eERROR = "ERROR"
eERROR = "ERROR"
 
eFILEOPEN = "Cannot Open File '%s'."
eINVALIDID = "'%s' Is An Invalid %s ID."
eINVALIDNAME = "'%s' Is An Invalid %s Name."
eINVALIDSTART = "Invalid Starting %s, '%s' - Must Be An Integer Value."
eNOPREFIX = "'%s' Must Be Prefixed With '+' or '-' To Indicate Desired Action."
 
 
#####
# Informational Messages
elif item[0] == '+':
additem = True
 
else:
ErrorMsg("'%s' Must Be Prefixed With '+' or '-' To Indicate Desired Action." % item)
ErrorMsg(eNOPREFIX % item)
sys.exit(2)
 
item = item[1:] # We just need the item Name/ID portion
 
try:
item = lookup(item)[0]
 
except:
ErrorMsg("'%s' Is An Invalid %s ID." % (orig[1:], name))
ErrorMsg(eINVALIDID % (orig[1:], name))
sys.exit(2)
 
# If not, assume it is a name and look it up
except ValueError:
 
# Make sure it even exists
 
if item not in master:
ErrorMsg("'%s' Is An Invalid %s Name." % (item, name))
ErrorMsg(eINVALIDNAME % (item, name))
sys.exit(2)
 
# Do the actual in/exclusion
 
temp.append([name, members])
f.close()
 
except:
ErrorMsg("Cannot Open File '%s'." % filename)
ErrorMsg(eFILEOPEN % filename)
sys.exit(1)
 
return temp
 
if opt == "-g":
try:
STARTGID=int(val)
except:
ErrorMsg("Invalid Starting GID, '%s' - Must Be An Integer Value." % val)
ErrorMsg(eINVALIDSTART % (GID, val))
sys.exit(1)
if opt == "-u":
try:
STARTUID=int(val)
except:
ErrorMsg("Invalid Starting UID '%s' - Must Be An Integer Value." % val)
ErrorMsg(eINVALIDSTART % (UID, val))
sys.exit(1)
if opt == "-I":
temp = ReadFile(val)
for entry in temp:
 
try:
grfile = open(GRFILE, "w")
except:
ErrorMsg("Cannot Open/Create File '%s'." % GRFILE)
ErrorMsg(eFILEOPEN % GRFILE)
sys.exit(3)
grfile.write(TIMESTAMP)
grfile.write(CMDLINE)
 
try:
pwfile = open(PWFILE, "w")
except:
ErrorMsg("Cannot Open/Create File '%s'." % PWFILE)
ErrorMsg(eFILEOPEN % PWFILE)
sys.exit(3)
pwfile.write(TIMESTAMP)
pwfile.write(CMDLINE)