Skip to content

rooprob/pyacter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pyacter - reductive labs 'facter' interface for python

LICENSE
    Copyright (c) 2012, Robert Fielding <rf@tamasi.org> 
    All rights reserved.

    Redistribution and use in source and binary forms, with or without
    modification, are permitted provided that the following conditions are met:

     * Redistributions of source code must retain the above copyright notice, this
       list of conditions and the following disclaimer.  
     * Redistributions in binary form must reproduce the above copyright notice,
       this list of conditions and the following disclaimer in the documentation
       and/or other materials provided with the distribution.  

    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
    ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
    WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
    DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
    FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
    DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
    SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
    CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
    OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


INTRODUCTION

    This is a very simple abstraction for accessing facter facts. Facter is a
    simple key=value interface to many system facts. The value is currently
    only a string type.

    Facter was 1.16 at the time of writing.

    Gathers the facts into a singleton (to avoid multiple lengthy calls to
    facter). Adds support for filtering. Returns a dictionary containing keys.


        from pyacter.facter import Facter
        import pprint
        import re

        class MyFacter(Facter):
            def facts(self):
                return super(MyFacter, self).facts(key_filter=self.my_filter)

        class ThingFacts(MyFacter):
            my_filter=[
                re.compile(r"^kernel"),
                re.compile(r"^inter"),
                re.compile(r"someprefix_"),
                re.compile(r"someotherprefix_"),
            ]


        if __name__ == "__main__":

            thing_facter = ThingFacts()

            pprint.pprint(thing_facter.facts())

        $ PYTHONPATH=. python example/example.py 
        {'interfaces': 'lo0,gif0,stf0,en0,p2p0',
         'kernel': 'Darwin',
         'kernelmajversion': '11.4',
         'kernelrelease': '11.4.0',
         'kernelversion': '11.4.0'}

        also see the (sparse) testing directory.



ABOUT THIS RELEASE

    This is pyacter 0.1

New since 0.1

    Basic subprocess call to facter.

Bugs fixed since 0.1

    Nothing.


REQUIREMENTS

Python 2.4 or later.


INSTALLATION

To build and install pyacter, type

    python setup.py install

HOME PAGE

    ...

DOCUMENTATION

Documentation is sparse at the moment.

BUG REPORTS

Bug reports may be sent to the author.

MAILING LISTS

None.

About

pyacter - facter interface for python

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages