Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Does this already exists?: A module that checks if the used platformis supported

Reply
Thread Tools

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

 
 
Martin P. Hellwig
Guest
Posts: n/a
 
      03-10-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')
 
Reply With Quote
 
 
 
 
Gabriel Genellina
Guest
Posts: n/a
 
      03-11-2010
En Wed, 10 Mar 2010 10:54:27 -0300, Martin P. Hellwig
<(E-Mail Removed)> escribió:

> 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.


In case you were not aware of it: see the platform module. But you'll have
to do the checks yourself (based on the info it returns).

--
Gabriel Genellina

 
Reply With Quote
 
 
 
 
Martin P. Hellwig
Guest
Posts: n/a
 
      03-11-2010
On 03/11/10 01:37, Gabriel Genellina wrote:
> En Wed, 10 Mar 2010 10:54:27 -0300, Martin P. Hellwig
> <(E-Mail Removed)> escribió:
>
>> 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.

>
> In case you were not aware of it: see the platform module. But you'll have
> to do the checks yourself (based on the info it returns).
>

Thanks for the reminder, it indeed slipped my mind.

As Python features are luckily mostly platform independent, I am not
sure if a convenient 'platform requirement check' module would be worth
the energy creating it, any thoughts on that?

For clarity purpose I re'added (and adapted) in what lines I was thinking:
-
test = RequirePlatform(do_not_raise=True)
# If do_not_raise is not set or False, an error will be raised
# after a failed require line, otherwise just continue.

test.require(key='test1', platform='freebsd', version_min='2.2')
# If the platform is anything else but FreeBSD 2.2 onwards return False
# and store the result of the test.
# Result of the require (and any additional tests
# can be accessed using the index operators;

if test['test1']:
print('supported')
-
Other requirements like architecture, python vm type/version, cpu
features, etc. Might also be nice to have.


--
mph
 
Reply With Quote
 
MRAB
Guest
Posts: n/a
 
      03-11-2010
Martin P. Hellwig wrote:
> On 03/11/10 01:37, Gabriel Genellina wrote:
>> En Wed, 10 Mar 2010 10:54:27 -0300, Martin P. Hellwig
>> <(E-Mail Removed)> escribió:
>>
>>> 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.

>>
>> In case you were not aware of it: see the platform module. But you'll
>> have
>> to do the checks yourself (based on the info it returns).
>>

> Thanks for the reminder, it indeed slipped my mind.
>
> As Python features are luckily mostly platform independent, I am not
> sure if a convenient 'platform requirement check' module would be worth
> the energy creating it, any thoughts on that?
>
> For clarity purpose I re'added (and adapted) in what lines I was thinking:
> -
> test = RequirePlatform(do_not_raise=True)
> # If do_not_raise is not set or False, an error will be raised
> # after a failed require line, otherwise just continue.
>
> test.require(key='test1', platform='freebsd', version_min='2.2')
> # If the platform is anything else but FreeBSD 2.2 onwards return False
> # and store the result of the test.
> # Result of the require (and any additional tests
> # can be accessed using the index operators;
>
> if test['test1']:
> print('supported')
> -
> Other requirements like architecture, python vm type/version, cpu
> features, etc. Might also be nice to have.
>

It might be useful for up-front checking in those platform-specific
scripts, although the platform module might already be fulfilling that
need.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
problem in running a basic code in python 3.3.0 that includes HTML file Satabdi Mukherjee Python 1 04-04-2013 07:48 PM
Static array defined in one module, but used in another module pozzugno@gmail.com C Programming 6 10-24-2012 07:30 PM
IllegalStateException : Writer being already used by this servlet Kim Ray Java 3 02-19-2004 10:13 PM
Writer being already used by this servlet : IllegalStateException Kim Ray Java 1 02-18-2004 12:50 PM
This file is already open or being used Scooby Dooby Doo Computer Support 5 08-25-2003 11:42 AM



Advertisments