On 8/11/11 11:55 AM, John Fischer wrote:
usr/src/tools/tests/slim_regression_test.py
--------------------------------------------------------------------------------------------
1. Would it be better to put these tests within the main function?
38 try:
39 SRC = os.environ["SRC"]
40 except KeyError:
41 print "unable to find $SRC in environment. Please add SRC to "
42 print "/etc/sudoers file under the 'Defaults env_keep=...' section"
43
44 # check permissions
45 if os.geteuid() != 0:
46 raise SystemExit("Error: Root privileges are required")
47
I have to leave the SRC check in the global scope so that optparse can set up
the usage correctly. I could move the permissions check into main(), but if
I'm going to bomb out of the script for a missing environment variable, I might
as well do the same for invalid permissions.
Are you bombing out if SRC is not in the environment? The way that I
parse the code here is that you are printing the messages and then continuing
to the permissions check.
I was ... I'm now raising SystemExit:
try:
SRC = os.environ["SRC"]
except KeyError:
raise SystemExist("unable to find $SRC in environment. Please add
SRC to "
"/etc/sudoers file under the 'Defaults env_keep=...' section")
# check permissions
if os.geteuid() != 0:
raise SystemExit("Error: Root privileges are required")
-Drew
_______________________________________________
caiman-discuss mailing list
[email protected]
http://mail.opensolaris.org/mailman/listinfo/caiman-discuss