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

Discussion in 'Python' started by Martin P. Hellwig, Mar 10, 2010.

  1. 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')
     
    Martin P. Hellwig, Mar 10, 2010
    #1
    1. Advertising

  2. Re: Does this already exists?: A module that checks if the usedplatform is supported

    En Wed, 10 Mar 2010 10:54:27 -0300, Martin P. Hellwig
    <> 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
     
    Gabriel Genellina, Mar 11, 2010
    #2
    1. Advertising

  3. Platform Requirement Checker (was Does this already exists?: A modulethat checks if the used platform is supported)

    On 03/11/10 01:37, Gabriel Genellina wrote:
    > En Wed, 10 Mar 2010 10:54:27 -0300, Martin P. Hellwig
    > <> 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
     
    Martin P. Hellwig, Mar 11, 2010
    #3
  4. Martin P. Hellwig

    MRAB Guest

    Re: Platform Requirement Checker (was Does this already exists?:A module that checks if the used platform is supported)

    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
    >> <> 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.
     
    MRAB, Mar 11, 2010
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Chad Crowder
    Replies:
    7
    Views:
    21,609
    hemant.yadav
    Oct 24, 2009
  2. Alvin Bruney [MVP]

    Re: Class already exists ... help please!!

    Alvin Bruney [MVP], Apr 6, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    2,543
    Alvin Bruney [MVP]
    Apr 6, 2004
  3. George
    Replies:
    1
    Views:
    6,246
    Jamie
    Feb 25, 2005
  4. Alan Silver
    Replies:
    2
    Views:
    420
    Alan Silver
    Sep 29, 2005
  5. Ulf Meinhardt
    Replies:
    8
    Views:
    6,212
Loading...

Share This Page