Changeset 64 for trunk


Ignore:
Timestamp:
01/16/06 10:04:06 (18 years ago)
Author:
walter
Message:

use readlink, very practical hehehe

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/pxeconfig/hexls

    r63 r64  
    4242        regexp = re.compile('[' + string.hexdigits + ']{8}' )
    4343        for f in os.listdir(path):
     44                fullpath = os.path.join(path, f)
     45                if os.path.islink(fullpath):
     46                        symlink_dest = os.readlink(fullpath)
     47                else:
     48                        symlink_dest = None
     49
    4450                if regexp.match(f) and len(f) == 8:
    4551                        digit1 = string.atoi(f[:2], 16)
     
    5561
    5662                        if hostname:
    57                                 print '%s => %s => %s' % (f, ipaddr, hostname[0])
     63                                output = '%s => %s => %s' % (f, ipaddr, hostname[0])
    5864                        else:
    59                                 print '%s => %s' % (f, ipaddr)
     65                                output = '%s => %s' % (f, ipaddr)
     66
     67                        if symlink_dest:
     68                                output = '%s -> %s' % (output, symlink_dest)
     69
     70                        print output
    6071                else:
    6172                        if f[0] != '.':
Note: See TracChangeset for help on using the changeset viewer.