Does this already exists?: A module that checks if the used platform is supported

Martin P. Hellwig martin.hellwig at dcuktec.org
Wed Mar 10 14:54:27 CET 2010


Hi all,

Before I start reinventing a squared wheel, I have the following question:
Is there already a (standard) module that wraps around the various 
os/sys information which checks if the platform + version is supported 
for what I want to do with it.

For example I am currently looking at making a wrapper around sysctl, 
for Freebsd only (2.2 onwards perhaps later I add Linux if I feel up to it.

So yes of course I can do a os.uname() but it struck me that there must 
be a better way. *

If you think I made a thought error along the line and there is a better 
solution, please do tell me too :-)

Thanks,

-- 
mph

* Something like:
test = RequirePlatform(do_not_raise=True)
test.require(platform='freebsd', version_min='2.2')
# If the platform is anything else but FreeBSD 2.2+
# raise an EnvironmentError. Otherwise, store the
# result of the test (True/False).
# Result of the require (and any additional tests
# can be accessed using the index operators

if test[0]:
     print('supported')



More information about the Python-list mailing list