I should have mentioned this also, it's not good to catch ``Exception`` since it will act on exceptions like ``KeyboardInterrupt`` if they happen to come in.  How about ``except (OSError, IOError, AttributeError, KeyError, aexpect.ExpectError, aexpect.ShellError, error.CmdError), detail:``?   I think that should cover most of the expected ones, and any others probably should be allowed to propagate normally.