> True however it is caught in the exception after the failed attempt to > do a lg.beList() and processing continues without error.
You're right, the code will catch a NameError. The exception handling you've chosen is a bit of a dragnet. If possible, I'd encourage you to catch the exceptions that you actually expect to see. At least that way, people reading the code have some idea about what might possibly go wrong. > Each function call into BootEnv returns right away when libbe isn't > imported. I chose this style instead of checking before each call is > made in client.py. Keeps client.py cleaner. It took me a minute to figure this out. The way this is implemented is kindof sneaky. I had to notice that every function starts with a call to get_env() and get_env() checks is_BEenv. It might just be easier to check is_BEenv directly inside the methods. There are a couple of other possible approaches too: 1. Create an abstract BootEnv class, define BootEnvZFS and BootEnvNull classes. When we can import libbe, use the BootEnvZFS class, otherwise use the BootEnvNull class. Presumably, the null class has methods that don't actually do any work. You could also just make the parent class have null methods, and then have BootEnvZFS do work. There are a few different ways you could go with this general idea. Stephen/Danek may want to say more about this, too. 2. Override the __new__() of BootEnv to not create an object when libbe cannot be imported. Of course, this means that you'll have to check that your constructor returned an object. This, in turn, will push some of the checking into client.py. Approach 1 may be easier. -j _______________________________________________ pkg-discuss mailing list [email protected] http://mail.opensolaris.org/mailman/listinfo/pkg-discuss
