Index: trunk/source/hes/hes =================================================================== --- trunk/source/hes/hes (revision 119) +++ trunk/source/hes/hes (revision 119) @@ -0,0 +1,51 @@ +#!/usr/bin/env python + +"""hes does Hesiod lookups for the most common types of Hesiod entries.""" + +import os +import sys + +keys = ["passwd", "filsys", "pobox", "gid", "uid", "grplist", "sloc", "cluster", +"group", "pcap", "service", "lpralias", "printinfo", "palladium", "tloc"] + +usage = """ +Usage: hes thing_you_want_info_about [next_thing ...] [type] + +Where 'type' is: %s +""" % ", ".join(keys) + +def query(thing, type): + input, output, err = os.popen3(('hesinfo', thing, type)) + # hesinfo prints errors (like queries not existing) to stderr, so if it's + # empty, we're probably good + if err.read() == '': + return output.read().strip() + +def printQuery(thing, type): + """printQuery takes the output of a Hesiod query, formats it, and prints it + out""" + info = query(thing, type) + if info != None: + print "%s: %s" % (type.upper().rjust(10), info) + +def main(): + # Print the usage information if there were no arguments + if len(sys.argv) <= 1: + print usage + return + + # If a specific type of query was asked for, do that for each thing + if sys.argv[-1] in keys: + type = sys.argv[-1] + for thing in sys.argv[1:-1]: + printQuery(thing, type) + # Otherwise LOOKUP EVERYTHING! + else: + for thing in sys.argv[1:]: + for type in keys: + printQuery(thing, type) + # ...with a blank line between each thing being looked up + print "" + +if __name__ == "__main__": + main() Index: trunk/source/hes/setup.py =================================================================== --- trunk/source/hes/setup.py (revision 119) +++ trunk/source/hes/setup.py (revision 119) @@ -0,0 +1,6 @@ +from distutils.core import setup +setup(name='macathena-hes', + version='1.0', + author='SIPB MacAthena Project', + author_email='sipb-macathena@mit.edu', + scripts=['hes']) Index: trunk/source/hes/copyright =================================================================== --- trunk/source/hes/copyright (revision 119) +++ trunk/source/hes/copyright (revision 119) @@ -0,0 +1,20 @@ +Copyright © 2007 Evan Broder + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.