Changeset 158 for trunk/source
- Timestamp:
- 11/11/08 14:16:09 (16 years ago)
- Files:
-
- trunk/source/hes/hes (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/source/hes/hes
r119 r158 5 5 import os 6 6 import sys 7 import hesiod 7 8 8 9 keys = ["passwd", "filsys", "pobox", "gid", "uid", "grplist", "sloc", "cluster", … … 10 11 11 12 usage = """ 12 Usage: hes thing_you_want_info_about [next_thing ...] 13 Usage: hes thing_you_want_info_about [next_thing ...] [type] 13 14 14 15 Where 'type' is: %s 15 16 """ % ", ".join(keys) 16 17 17 def query(thing, type):18 input, output, err = os.popen3(('hesinfo', thing, type))19 # hesinfo prints errors (like queries not existing) to stderr, so if it's20 # empty, we're probably good21 if err.read() == '':22 return output.read().strip()23 24 18 def printQuery(thing, type): 25 19 """printQuery takes the output of a Hesiod query, formats it, and prints it 26 20 out""" 27 info = query(thing, type) 28 if info != None: 29 print "%s: %s" % (type.upper().rjust(10), info) 21 try: 22 info = hesiod.resolve(thing, type) 23 for ent in info: 24 print "%s: %s" % (type.upper().rjust(10), ent) 25 except IOError, e: 26 if e.errno != 2: 27 raise 30 28 31 29 def main():