当前位置: 首页>>代码示例>>Python>>正文


Python Server.loadState方法代码示例

本文整理汇总了Python中kademlia.network.Server.loadState方法的典型用法代码示例。如果您正苦于以下问题:Python Server.loadState方法的具体用法?Python Server.loadState怎么用?Python Server.loadState使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在kademlia.network.Server的用法示例。


在下文中一共展示了Server.loadState方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from kademlia.network import Server [as 别名]
# 或者: from kademlia.network.Server import loadState [as 别名]
 def __init__(self, config, bootstrapNeighbors):
     if os.path.isfile(config['dht.state.cache']):
         self.kserver = Server.loadState(config['dht.state.cache'])
     else:
         self.kserver = Server()
         self.kserver.bootstrap(bootstrapNeighbors)
         self.kserver.saveStateRegularly(config['dht.state.cache'], 60)
开发者ID:krahimian,项目名称:tint,代码行数:9,代码来源:resolution.py

示例2: connect

# 需要导入模块: from kademlia.network import Server [as 别名]
# 或者: from kademlia.network.Server import loadState [as 别名]
    def connect(self, port):
        
        if(self._app_deployer):
            from twisted.application import service, internet
            from twisted.python.log import ILogObserver
            from twisted.internet import reactor, task

            import sys, os
            sys.path.append(os.path.dirname(__file__))
            from kademlia.network import Server
            from kademlia import log

            application = service.Application("kademlia")
            application.setComponent(ILogObserver, log.FileLogObserver(sys.stdout, log.INFO).emit)

            if os.path.isfile('cache.pickle'):
                kserver = Server.loadState('cache.pickle')
            else:
                kserver = Server()
                kserver.bootstrap([("127.0.0.1", port)])
                kserver.saveStateRegularly('cache.pickle', 10)
                
            server = internet.UDPServer(8468, kserver.protocol)
            server.setServiceParent(application)    
        else:
            self._node.listen(port)
            self._node.bootstrap([("127.0.0.1",port)]).addCallback(self.bootStrapDone)
开发者ID:dwils098,项目名称:Masters,代码行数:29,代码来源:.#networkInterface.py

示例3: FileServer

# 需要导入模块: from kademlia.network import Server [as 别名]
# 或者: from kademlia.network.Server import loadState [as 别名]
import sys
sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
import tornado.platform.twisted
tornado.platform.twisted.install()
import tornado.ioloop
import tornado.web
import hashlib
from os.path import join, getsize, exists
import mutagen
import pickle
import time
from twisted.internet import reactor
from kademlia.network import Server

if os.path.isfile('self.cache.pickle'):
    kserver = Server.loadState('self.cache.pickle')
else:
    kserver = Server()
    kserver.bootstrap([("185.97.32.250", 8468)])
kserver.saveStateRegularly('self.cache.pickle', 10)
kserver.listen(8468)

class FileServer(tornado.web.RequestHandler):
    def initialize(self, cache):
        self.cache=cache

    def get(self, arg):
        filename = self.cache[arg]
        with open(filename,"rb") as fp:
            self.set_header("Content-Type", "audio/mpeg")
            self.set_header('content-length',os.stat(fp.fileno()).st_size)
开发者ID:mikaelfrykholm,项目名称:uniqueshare,代码行数:33,代码来源:server.py

示例4: setDone

# 需要导入模块: from kademlia.network import Server [as 别名]
# 或者: from kademlia.network.Server import loadState [as 别名]
    print "Key result:", result
    reactor.stop()

def setDone(result, server):
    server.get("110").addCallback(done)

def bootstrapDone(found, server):
    print "*** Putting a value"
    server.set("110", fileread()).addCallback(setDone, server)
 
#resourceDiscovery()

if os.path.isfile('cache.pickle'):
    print "*** @ if block"
    #kserver = Server()
    kserver = Server.loadState('cache.pickle')
    kserver.bootstrap([("10.0.0.1", 8468)]).addCallback(bootstrapDone, kserver)
else:
    print "*** @ else block"
    kserver = Server()
    kserver.bootstrap([("10.0.0.1", 8468)]).addCallback(bootstrapDone, kserver)
kserver.saveStateRegularly('cache.pickle', 10)

server = internet.UDPServer(8468, kserver.protocol)
server.setServiceParent(application)





开发者ID:Venkatraman9214,项目名称:ServerSetup,代码行数:27,代码来源:server.py

示例5: Server

# 需要导入模块: from kademlia.network import Server [as 别名]
# 或者: from kademlia.network.Server import loadState [as 别名]
from twisted.application import service, internet
from twisted.python.log import ILogObserver
from twisted.internet import reactor, task

import sys, os
#sys.path.append(os.path.dirname(__file__))
from kademlia.network import Server
from kademlia import log

application = service.Application("tau")
application.setComponent(ILogObserver, log.FileLogObserver(sys.stdout, log.INFO).emit)

kad_cache = 'cache.pickle'
if os.path.isfile(kad_cache):
    kserver = Server.loadState(kad_cache)
else:
    kserver = Server()
    kserver.bootstrap([("1.2.3.4", 8468)])
kserver.saveStateRegularly(kad_cache, 10)

server = internet.UDPServer(8468, kserver.protocol)
server.setServiceParent(application)


reactor.run()
开发者ID:koo5,项目名称:hackery,代码行数:27,代码来源:node.py

示例6: Server

# 需要导入模块: from kademlia.network import Server [as 别名]
# 或者: from kademlia.network.Server import loadState [as 别名]
import os
import sys

sys.path.append(os.path.join(os.path.dirname(__file__), ".."))
from twisted.internet import reactor
from kademlia.network import Server

if os.path.isfile("cache.pickle"):
    kserver = Server.loadState("cache.pickle")
else:
    kserver = Server()
    kserver.bootstrap([("1.2.3.4", 8468)])
kserver.saveStateRegularly("cache.pickle", 10)
kserver.listen(8468)
reactor.run()
开发者ID:F483,项目名称:kademlia,代码行数:17,代码来源:server.py


注:本文中的kademlia.network.Server.loadState方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。