Comment 3 for bug 394757

Revision history for this message
Kenneth Loafman (kenneth-loafman) wrote : Re: [Bug 394757] Re: Backend imports should be made optional

Peter Schuller wrote:
> I have some reservations about silently ignore import failures of entire
> backends. I think I would prefer the backends themselves to do any
> 'tricks' they might want to do with respect to not importing modules
> that we consider to be optional.
>
> The intent is to avoid making it easier to introduce problems that don't
> show up during development because code was not even imported.
>
> But I definitely like the concept of listing backends and whether or not
> they "think" they are available, along with how to use them.

I agree with the 'silent' part. If a backend fails to load, it should
be noted, but I don't think a traceback is appropriate, maybe just more
detail somehow.

As to listing backends, maybe 3 columns, Name, Proto, Avail, and
possibly a 4th to list what's missing (executable, python module).

On the detail part, we could add 2 routines to the backend.py file,

1) try_import - try to import the foreign module, anything not in the
base Python distribution and notify if that fails.

2) try_exec - try to execute a utility, like ncftp, and notify if that
fails.

The backend could then execute these prior to registering. If one or
both fail, register as 'not-available'.

Thoughts?