#!/bin/env python
import nmb
from twisted.internet import reactor, defer
import sys

def disaster(failure):
    print 'FAILED. Reason: ',failure
    reactor.stop()

def finish(results):
    print results
    reactor.stop()

def main(name, nameServer, port=137):
    d = defer.gatherResults([nmb.lookup(name, nameServer),
                             nmb.queryNode(name, nameServer)])
    d.addCallback(finish)
    d.addErrback(disaster)
    
    reactor.run()

if __name__ == '__main__':
    main(sys.argv[1], sys.argv[2])
