Example #1
0
def main():
    """
    Run the test - use command line to pass a location.
    """
    def _done(path, sz, arg):
        print path, sz
        reactor.stop()
    dhnio.init()
    ask(sys.argv[1], _done)
    reactor.run()
Example #2
0
def test7():
    import dhnio
    dhnio.init()
    def _ok(x):
        print x
        reactor.stop()
    def _fail(x):
        print x
        reactor.stop()
    TestInternetConnection().addCallbacks(_ok, _fail)
    reactor.run()
Example #3
0
def update():
    """
    A good way to check all things - load and sign again.
    """
    dhnio.init()
    settings.init()
    src = dhnio.ReadTextFile(settings.LocalIdentityFilename())
    misc.setLocalIdentity(identity(xmlsrc=src))
    misc.getLocalIdentity().sign()
    misc.saveLocalIdentity()
    print misc.getLocalIdentity().serialize()    
Example #4
0
def main():
    global _BaseDir
    global _Debug
    options, args = parseCommandLine()
    _BaseDir = options.basedir 
    _Debug = options.debug
    dhnio.init()
    dhnio.SetDebug(18)
    settings.init()
    import identitycache
    identitycache.init()
    reactor.addSystemEventTrigger('before', 'shutdown', shutdown_final)
#    from transport_control import _InitDone
#    _InitDone = True
    def initDone(state, options, args):
        if state != 'online':
            print 'state is %s, exit' % state
            reactor.stop()
            return
        if options.send:
#            def _random_sending(count):
#                import random
#                if count > 10:
#                    return
#                print 'sending file %s to %s' % (args[0], args[1])
#                reactor.callLater(random.randint(0, 2), _random_sending, count+1)
#                send(args[0], args[1])
#                count += 1
#            reactor.callLater(0.5, _random_sending, 0)
            send(args[0], args[1])
            return
        if options.receive:
            print 'state is %s, receiving...' % state
            return
        print 'ONLINE !!!'
    init().addCallback(initDone, options, args)
    # reactor.callLater(20, A, 'shutdown')
    reactor.run() 
Example #5
0
def _my_monitor():
#    import transport_control
#    src = ''
#    for address in transport_control._LiveTransfers.keys():
#        for obj in transport_control._LiveTransfers[address]['send']:
#            src += '%d to %s, ' % (obj.sentBytes, str(address))
#        for obj in transport_control._LiveTransfers[address]['receive']:
#            src += '%d from %s, ' % (obj.receivedBytes, str(address))
#    print '>>>', src
    print _OpenedConnections, _StartedConnections
    reactor.callLater(5, _my_monitor)

if __name__ == "__main__":
    #import datahaven.p2p.memdebug as memdebug
    #memdebug.start(8080)
    dhnio.init()
    dhnio.SetDebug(16)
    dhnio.LifeBegins()

    from twisted.internet.defer import setDebugging
    setDebugging(True)

    _my_monitor()

    def _test_cancel():
        import transport_control as tc
        for t in tc.current_transfers():
            cancel(t.transfer_id)

    if len(sys.argv) < 2:
        usage()
Example #6
0
def test6():
    import dhnio
    dhnio.init()
    print getNetworkInterfaces()