Danek Duvall wrote:
Saurabh Vyas wrote:

So I need to handle the TypeError in both trans_import() &
trans_generate() (and nothing in gen_action()), is my understanding
right ?

That's the way I'd handle it, yes.  I think it'll be more straightforward
that way to distinguish between the two error conditions (bundle not found
and unknown bundle type).
Thanks Danek for clarification.

We can handle the 2 errors differently, like :

def trans_generate(args):
@@ -459,11 +464,18 @@
                usage(_("No arguments specified for subcommand."),
                    cmd="generate")

-        for action, err in gen_actions(pargs, timestamp_files):
-                if "path" in action.attrs and hasattr(action, "hash") \
-                    and action.hash == "NOHASH":
-                        action.hash = action.attrs["path"]
-                print action
+       try:
+               for action, err in gen_actions(pargs, timestamp_files):
+ if "path" in action.attrs and hasattr(action, "hash") and \
+                           action.hash == "NOHASH":
+                               action.hash = action.attrs["path"]
+                       print action
+       except TypeError:
+               error("Unknown bundle type %s" % pargs, cmd="generate")
+               return 1
+       except IOError:
+               error("Bundle not found %s" % pargs, cmd="generate")
+               return 1

        return 0

But the call to make_bundle (from gen_actions()) result in TypeError only,
thus we still will end-up having TypeErrror in this case (and not the bundle not found !!!)
Is this correct behavior?

~Saurabh
Danek

_______________________________________________
pkg-discuss mailing list
[email protected]
http://mail.opensolaris.org/mailman/listinfo/pkg-discuss

Reply via email to