Detecting OS and Window Manager

Daniel Fackrell dfackrell at DELETETHIS.linuxmail.org
Fri Jun 7 11:33:25 EDT 2002


"Darren Winsper" <dw133 at cs.york.ac.uk.go.away> wrote in message
news:ug1h5q29aulga9 at corp.supernews.com...
> In <3d00bfb5$1_2 at hpb10302.boi.hp.com>, Daniel Fackrell wrote:
>
> > Correct me if I'm wrong, but isn't this exactly the pythonic way of
handling
> > dynamic loading of modules?
> >
> > try:
> >     import kdecore
> > except ImportError:
> >     # do something else
>
> OK, fair enough.  I did only read and write my first line of Python a
> few days ago :)

Welcome to the group, then.  We're all newbies here, for various values of
new.  <wink>

> > Of course, this will probably not do what you want in this case, as
kdecore
> > will probably load if it is installed, without regard to whether the
current
> > user is running KDE.  I don't have much experience with this particular
> > topic yet.
>
> Well, I could attempt to see if something like "kdesktop" is running,
> since if it is, the chances of running KDE are very high.  It's kludgy,
> but I can't really think of anything else, since KDEINIT would be running
> if a single kde application is running IIRC.

If you're thinking of scanning the currently running processes for the
existence of a particular process, then you won't get the results you want
there, either.  The reason for this is that there can be multiple logins for
a single user or multiple users, and KDE-related processes will exist if any
one of those logins is running KDE, but not necessarily the current one.

Maybe import your kde module(s), and then try to do something KDE specific
without KDE running and see what kind of error this causes so you will know
what to trap for?  Hopefully some other newbie (for a much less significant
value of new, AKA expert) is still following this thread to give you a
better answer.

Daniel Fackrell





More information about the Python-list mailing list