{"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/server\/globalobject.py","language":"python","identifier":"masterserviceHandle","parameters":"(target)","argument_list":"","return_statement":"","docstring":"\u4f9bmaster\u8c03\u7528\u7684\u63a5\u53e3\u63cf\u8ff0\u7b26","docstring_summary":"\u4f9bmaster\u8c03\u7528\u7684\u63a5\u53e3\u63cf\u8ff0\u7b26","docstring_tokens":["\u4f9bmaster\u8c03\u7528\u7684\u63a5\u53e3\u63cf\u8ff0\u7b26"],"function":"def masterserviceHandle(target):\n \"\"\"\u4f9bmaster\u8c03\u7528\u7684\u63a5\u53e3\u63cf\u8ff0\u7b26\n \"\"\"\n GlobalObject().masterremote._reference._service.mapTarget(target)","function_tokens":["def","masterserviceHandle","(","target",")",":","GlobalObject","(",")",".","masterremote",".","_reference",".","_service",".","mapTarget","(","target",")"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/server\/globalobject.py#L36-L39"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/server\/globalobject.py","language":"python","identifier":"netserviceHandle","parameters":"(target)","argument_list":"","return_statement":"","docstring":"\u4f9b\u5ba2\u6237\u7aef\u8fde\u63a5\u8c03\u7528\u7684\u63a5\u53e3\u63cf\u8ff0\u7b26","docstring_summary":"\u4f9b\u5ba2\u6237\u7aef\u8fde\u63a5\u8c03\u7528\u7684\u63a5\u53e3\u63cf\u8ff0\u7b26","docstring_tokens":["\u4f9b\u5ba2\u6237\u7aef\u8fde\u63a5\u8c03\u7528\u7684\u63a5\u53e3\u63cf\u8ff0\u7b26"],"function":"def netserviceHandle(target):\n \"\"\"\u4f9b\u5ba2\u6237\u7aef\u8fde\u63a5\u8c03\u7528\u7684\u63a5\u53e3\u63cf\u8ff0\u7b26\n \"\"\"\n GlobalObject().netfactory.service.mapTarget(target)","function_tokens":["def","netserviceHandle","(","target",")",":","GlobalObject","(",")",".","netfactory",".","service",".","mapTarget","(","target",")"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/server\/globalobject.py#L41-L44"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/server\/globalobject.py","language":"python","identifier":"rootserviceHandle","parameters":"(target)","argument_list":"","return_statement":"","docstring":"\u4f5c\u4e3aroot\u8282\u70b9\uff0c\u4f9bremote\u8282\u70b9\u8c03\u7528\u7684\u63a5\u53e3\u63cf\u8ff0\u7b26","docstring_summary":"\u4f5c\u4e3aroot\u8282\u70b9\uff0c\u4f9bremote\u8282\u70b9\u8c03\u7528\u7684\u63a5\u53e3\u63cf\u8ff0\u7b26","docstring_tokens":["\u4f5c\u4e3aroot\u8282\u70b9\uff0c\u4f9bremote\u8282\u70b9\u8c03\u7528\u7684\u63a5\u53e3\u63cf\u8ff0\u7b26"],"function":"def rootserviceHandle(target):\n \"\"\"\u4f5c\u4e3aroot\u8282\u70b9\uff0c\u4f9bremote\u8282\u70b9\u8c03\u7528\u7684\u63a5\u53e3\u63cf\u8ff0\u7b26\n \"\"\"\n GlobalObject().root.service.mapTarget(target)","function_tokens":["def","rootserviceHandle","(","target",")",":","GlobalObject","(",")",".","root",".","service",".","mapTarget","(","target",")"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/server\/globalobject.py#L46-L49"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/server\/globalobject.py","language":"python","identifier":"GlobalObject.config","parameters":"(self,netfactory=None,root = None,remote=None,db=None)","argument_list":"","return_statement":"","docstring":"\u914d\u7f6e\u5b58\u653e\u7684\u5bf9\u8c61\u5b9e\u4f8b","docstring_summary":"\u914d\u7f6e\u5b58\u653e\u7684\u5bf9\u8c61\u5b9e\u4f8b","docstring_tokens":["\u914d\u7f6e\u5b58\u653e\u7684\u5bf9\u8c61\u5b9e\u4f8b"],"function":"def config(self,netfactory=None,root = None,remote=None,db=None):\n \"\"\"\u914d\u7f6e\u5b58\u653e\u7684\u5bf9\u8c61\u5b9e\u4f8b\n \"\"\"\n self.netfactory = netfactory\n self.root = root\n self.remote = remote\n self.db = db","function_tokens":["def","config","(","self",",","netfactory","=","None",",","root","=","None",",","remote","=","None",",","db","=","None",")",":","self",".","netfactory","=","netfactory","self",".","root","=","root","self",".","remote","=","remote","self",".","db","=","db"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/server\/globalobject.py#L28-L34"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/server\/globalobject.py","language":"python","identifier":"webserviceHandle.__init__","parameters":"(self,url,**kw)","argument_list":"","return_statement":"","docstring":"@param url: str http \u8bbf\u95ee\u7684\u8def\u5f84","docstring_summary":"","docstring_tokens":[],"function":"def __init__(self,url,**kw):\n \"\"\"\n @param url: str http \u8bbf\u95ee\u7684\u8def\u5f84\n \"\"\"\n self._url = url\n self.kw = kw","function_tokens":["def","__init__","(","self",",","url",",","*","*","kw",")",":","self",".","_url","=","url","self",".","kw","=","kw"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/server\/globalobject.py#L55-L60"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/server\/logobj.py","language":"python","identifier":"loogoo.__init__","parameters":"(self,logpath)","argument_list":"","return_statement":"","docstring":"\u914d\u7f6e\u65e5\u5fd7\u8def\u5f84","docstring_summary":"\u914d\u7f6e\u65e5\u5fd7\u8def\u5f84","docstring_tokens":["\u914d\u7f6e\u65e5\u5fd7\u8def\u5f84"],"function":"def __init__(self,logpath):\n '''\u914d\u7f6e\u65e5\u5fd7\u8def\u5f84\n '''\n self.file = file(logpath, 'w')","function_tokens":["def","__init__","(","self",",","logpath",")",":","self",".","file","=","file","(","logpath",",","'w'",")"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/server\/logobj.py#L17-L20"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/server\/logobj.py","language":"python","identifier":"loogoo.__call__","parameters":"(self, eventDict)","argument_list":"","return_statement":"","docstring":"\u65e5\u5fd7\u5904\u7406","docstring_summary":"\u65e5\u5fd7\u5904\u7406","docstring_tokens":["\u65e5\u5fd7\u5904\u7406"],"function":"def __call__(self, eventDict):\n '''\u65e5\u5fd7\u5904\u7406\n '''\n if 'logLevel' in eventDict:\n level = eventDict['logLevel']\n elif eventDict['isError']:\n level = 'ERROR'\n else:\n level = 'INFO'\n text = log.textFromEventDict(eventDict)\n if text is None or level != 'ERROR':\n return\n nowdate = datetime.datetime.now()\n self.file.write('['+str(nowdate)+']\\n'+str(level)+ '\\n\\t' + text + '\\r\\n')\n self.file.flush()","function_tokens":["def","__call__","(","self",",","eventDict",")",":","if","'logLevel'","in","eventDict",":","level","=","eventDict","[","'logLevel'","]","elif","eventDict","[","'isError'","]",":","level","=","'ERROR'","else",":","level","=","'INFO'","text","=","log",".","textFromEventDict","(","eventDict",")","if","text","is","None","or","level","!=","'ERROR'",":","return","nowdate","=","datetime",".","datetime",".","now","(",")","self",".","file",".","write","(","'['","+","str","(","nowdate",")","+","']\\n'","+","str","(","level",")","+","'\\n\\t'","+","text","+","'\\r\\n'",")","self",".","file",".","flush","(",")"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/server\/logobj.py#L22-L36"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/server\/server.py","language":"python","identifier":"serverStop","parameters":"()","argument_list":"","return_statement":"return True","docstring":"\u505c\u6b62\u670d\u52a1\u8fdb\u7a0b","docstring_summary":"\u505c\u6b62\u670d\u52a1\u8fdb\u7a0b","docstring_tokens":["\u505c\u6b62\u670d\u52a1\u8fdb\u7a0b"],"function":"def serverStop():\n \"\"\"\u505c\u6b62\u670d\u52a1\u8fdb\u7a0b\n \"\"\"\n log.msg('stop')\n if GlobalObject().stophandler:\n GlobalObject().stophandler()\n reactor.callLater(0.5,reactor.stop)\n return True","function_tokens":["def","serverStop","(",")",":","log",".","msg","(","'stop'",")","if","GlobalObject","(",")",".","stophandler",":","GlobalObject","(",")",".","stophandler","(",")","reactor",".","callLater","(","0.5",",","reactor",".","stop",")","return","True"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/server\/server.py#L22-L29"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/server\/server.py","language":"python","identifier":"FFServer.config","parameters":"(self, config, servername=None, dbconfig=None,\n memconfig=None, masterconf=None)","argument_list":"","return_statement":"","docstring":"\u914d\u7f6e\u670d\u52a1\u5668","docstring_summary":"\u914d\u7f6e\u670d\u52a1\u5668","docstring_tokens":["\u914d\u7f6e\u670d\u52a1\u5668"],"function":"def config(self, config, servername=None, dbconfig=None,\n memconfig=None, masterconf=None):\n '''\u914d\u7f6e\u670d\u52a1\u5668\n '''\n GlobalObject().json_config = config\n GlobalObject().remote_connect = self.remote_connect\n netport = config.get('netport')#\u5ba2\u6237\u7aef\u8fde\u63a5\n webport = config.get('webport')#http\u8fde\u63a5\n rootport = config.get('rootport')#root\u8282\u70b9\u914d\u7f6e\n self.remoteportlist = config.get('remoteport',[])#remote\u8282\u70b9\u914d\u7f6e\u5217\u8868\n if not servername:\n servername = config.get('name')#\u670d\u52a1\u5668\u540d\u79f0\n logpath = config.get('log')#\u65e5\u5fd7\n hasdb = config.get('db')#\u6570\u636e\u5e93\u8fde\u63a5\n hasmem = config.get('mem')#memcached\u8fde\u63a5\n app = config.get('app')#\u5165\u53e3\u6a21\u5757\u540d\u79f0\n cpuid = config.get('cpu')#\u7ed1\u5b9acpu\n mreload = config.get('reload')#\u91cd\u65b0\u52a0\u8f7d\u6a21\u5757\u540d\u79f0\n self.servername = servername\n \n if netport:\n self.netfactory = LiberateFactory()\n netservice = services.CommandService(\"netservice\")\n self.netfactory.addServiceChannel(netservice)\n reactor.listenTCP(netport,self.netfactory)\n \n if webport:\n self.webroot = Flask(\"servername\")\n GlobalObject().webroot = self.webroot\n reactor.listenWSGI(webport, self.webroot)\n \n if rootport:\n self.root = PBRoot()\n rootservice = services.Service(\"rootservice\")\n self.root.addServiceChannel(rootservice)\n reactor.listenTCP(rootport, BilateralFactory(self.root))\n \n for cnf in self.remoteportlist:\n rname = cnf.get('rootname')\n self.remote[rname] = RemoteObject(self.servername)\n \n if hasdb and dbconfig:\n if dbconfig.has_key(\"user\") and dbconfig.has_key(\"host\") and dbconfig.has_key(\"host\"):\n dbpool.initPool({\"default\":dbconfig})\n else:\n dbpool.initPool(dbconfig)\n \n if hasmem and memconfig:\n urls = memconfig.get('urls')\n# hostname = str(memconfig.get('hostname'))\n memcached_connect(urls)\n from gfirefly.dbentrust.util import M2DB_PORT,M2DB_HOST,ToDBAddress\n ToDBAddress().setToDBHost(memconfig.get(\"pubhost\",M2DB_HOST))\n ToDBAddress().setToDBPort(memconfig.get(\"pubport\",M2DB_PORT))\n \n if logpath:\n log.addObserver(loogoo(logpath))#\u65e5\u5fd7\u5904\u7406\n log.startLogging(sys.stdout)\n \n if cpuid:\n affinity.set_process_affinity_mask(os.getpid(), cpuid)\n GlobalObject().config(netfactory = self.netfactory, root=self.root,\n remote = self.remote)\n \n if app:\n __import__(app)\n if mreload:\n _path_list = mreload.split(\".\")\n GlobalObject().reloadmodule = __import__(mreload,fromlist=_path_list[:1])\n \n if masterconf:\n masterport = masterconf.get('rootport')\n masterhost = masterconf.get('roothost')\n self.master_remote = RemoteObject(servername)\n GlobalObject().masterremote = self.master_remote\n import admin\n addr = ('localhost',masterport) if not masterhost else (masterhost,masterport)\n self.master_remote.connect(addr)","function_tokens":["def","config","(","self",",","config",",","servername","=","None",",","dbconfig","=","None",",","memconfig","=","None",",","masterconf","=","None",")",":","GlobalObject","(",")",".","json_config","=","config","GlobalObject","(",")",".","remote_connect","=","self",".","remote_connect","netport","=","config",".","get","(","'netport'",")","#\u5ba2\u6237\u7aef\u8fde\u63a5","webport","=","config",".","get","(","'webport'",")","#http\u8fde\u63a5","rootport","=","config",".","get","(","'rootport'",")","#root\u8282\u70b9\u914d\u7f6e","self",".","remoteportlist","=","config",".","get","(","'remoteport'",",","[","]",")","#remote\u8282\u70b9\u914d\u7f6e\u5217\u8868","if","not","servername",":","servername","=","config",".","get","(","'name'",")","#\u670d\u52a1\u5668\u540d\u79f0","logpath","=","config",".","get","(","'log'",")","#\u65e5\u5fd7","hasdb","=","config",".","get","(","'db'",")","#\u6570\u636e\u5e93\u8fde\u63a5","hasmem","=","config",".","get","(","'mem'",")","#memcached\u8fde\u63a5","app","=","config",".","get","(","'app'",")","#\u5165\u53e3\u6a21\u5757\u540d\u79f0","cpuid","=","config",".","get","(","'cpu'",")","#\u7ed1\u5b9acpu","mreload","=","config",".","get","(","'reload'",")","#\u91cd\u65b0\u52a0\u8f7d\u6a21\u5757\u540d\u79f0","self",".","servername","=","servername","if","netport",":","self",".","netfactory","=","LiberateFactory","(",")","netservice","=","services",".","CommandService","(","\"netservice\"",")","self",".","netfactory",".","addServiceChannel","(","netservice",")","reactor",".","listenTCP","(","netport",",","self",".","netfactory",")","if","webport",":","self",".","webroot","=","Flask","(","\"servername\"",")","GlobalObject","(",")",".","webroot","=","self",".","webroot","reactor",".","listenWSGI","(","webport",",","self",".","webroot",")","if","rootport",":","self",".","root","=","PBRoot","(",")","rootservice","=","services",".","Service","(","\"rootservice\"",")","self",".","root",".","addServiceChannel","(","rootservice",")","reactor",".","listenTCP","(","rootport",",","BilateralFactory","(","self",".","root",")",")","for","cnf","in","self",".","remoteportlist",":","rname","=","cnf",".","get","(","'rootname'",")","self",".","remote","[","rname","]","=","RemoteObject","(","self",".","servername",")","if","hasdb","and","dbconfig",":","if","dbconfig",".","has_key","(","\"user\"",")","and","dbconfig",".","has_key","(","\"host\"",")","and","dbconfig",".","has_key","(","\"host\"",")",":","dbpool",".","initPool","(","{","\"default\"",":","dbconfig","}",")","else",":","dbpool",".","initPool","(","dbconfig",")","if","hasmem","and","memconfig",":","urls","=","memconfig",".","get","(","'urls'",")","# hostname = str(memconfig.get('hostname'))","memcached_connect","(","urls",")","from","gfirefly",".","dbentrust",".","util","import","M2DB_PORT",",","M2DB_HOST",",","ToDBAddress","ToDBAddress","(",")",".","setToDBHost","(","memconfig",".","get","(","\"pubhost\"",",","M2DB_HOST",")",")","ToDBAddress","(",")",".","setToDBPort","(","memconfig",".","get","(","\"pubport\"",",","M2DB_PORT",")",")","if","logpath",":","log",".","addObserver","(","loogoo","(","logpath",")",")","#\u65e5\u5fd7\u5904\u7406","log",".","startLogging","(","sys",".","stdout",")","if","cpuid",":","affinity",".","set_process_affinity_mask","(","os",".","getpid","(",")",",","cpuid",")","GlobalObject","(",")",".","config","(","netfactory","=","self",".","netfactory",",","root","=","self",".","root",",","remote","=","self",".","remote",")","if","app",":","__import__","(","app",")","if","mreload",":","_path_list","=","mreload",".","split","(","\".\"",")","GlobalObject","(",")",".","reloadmodule","=","__import__","(","mreload",",","fromlist","=","_path_list","[",":","1","]",")","if","masterconf",":","masterport","=","masterconf",".","get","(","'rootport'",")","masterhost","=","masterconf",".","get","(","'roothost'",")","self",".","master_remote","=","RemoteObject","(","servername",")","GlobalObject","(",")",".","masterremote","=","self",".","master_remote","import","admin","addr","=","(","'localhost'",",","masterport",")","if","not","masterhost","else","(","masterhost",",","masterport",")","self",".","master_remote",".","connect","(","addr",")"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/server\/server.py#L48-L125"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/server\/server.py","language":"python","identifier":"FFServer.remote_connect","parameters":"(self, rname, rhost)","argument_list":"","return_statement":"","docstring":"\u8fdb\u884crpc\u7684\u8fde\u63a5","docstring_summary":"\u8fdb\u884crpc\u7684\u8fde\u63a5","docstring_tokens":["\u8fdb\u884crpc\u7684\u8fde\u63a5"],"function":"def remote_connect(self, rname, rhost):\n \"\"\"\u8fdb\u884crpc\u7684\u8fde\u63a5\n \"\"\"\n for cnf in self.remoteportlist:\n _rname = cnf.get('rootname')\n if rname == _rname:\n rport = cnf.get('rootport')\n if not rhost:\n addr = ('localhost',rport)\n else:\n addr = (rhost,rport)\n self.remote[rname].connect(addr)\n break","function_tokens":["def","remote_connect","(","self",",","rname",",","rhost",")",":","for","cnf","in","self",".","remoteportlist",":","_rname","=","cnf",".","get","(","'rootname'",")","if","rname","==","_rname",":","rport","=","cnf",".","get","(","'rootport'",")","if","not","rhost",":","addr","=","(","'localhost'",",","rport",")","else",":","addr","=","(","rhost",",","rport",")","self",".","remote","[","rname","]",".","connect","(","addr",")","break"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/server\/server.py#L127-L139"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/server\/server.py","language":"python","identifier":"FFServer.start","parameters":"(self)","argument_list":"","return_statement":"","docstring":"\u542f\u52a8\u670d\u52a1\u5668","docstring_summary":"\u542f\u52a8\u670d\u52a1\u5668","docstring_tokens":["\u542f\u52a8\u670d\u52a1\u5668"],"function":"def start(self):\n '''\u542f\u52a8\u670d\u52a1\u5668\n '''\n log.msg('[%s] started...'%self.servername)\n log.msg('[%s] pid: %s'%(self.servername,os.getpid()))\n reactor.run()","function_tokens":["def","start","(","self",")",":","log",".","msg","(","'[%s] started...'","%","self",".","servername",")","log",".","msg","(","'[%s] pid: %s'","%","(","self",".","servername",",","os",".","getpid","(",")",")",")","reactor",".","run","(",")"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/server\/server.py#L141-L146"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/server\/admin.py","language":"python","identifier":"serverStop","parameters":"()","argument_list":"","return_statement":"return True","docstring":"\u4f9bmaster\u8c03\u7528\u7684\u63a5\u53e3\uff1a\u5173\u95ed\u670d\u52a1\u5668","docstring_summary":"\u4f9bmaster\u8c03\u7528\u7684\u63a5\u53e3\uff1a\u5173\u95ed\u670d\u52a1\u5668","docstring_tokens":["\u4f9bmaster\u8c03\u7528\u7684\u63a5\u53e3\uff1a\u5173\u95ed\u670d\u52a1\u5668"],"function":"def serverStop():\n \"\"\"\u4f9bmaster\u8c03\u7528\u7684\u63a5\u53e3\uff1a\u5173\u95ed\u670d\u52a1\u5668\n \"\"\"\n log.msg('stop')\n if GlobalObject().stophandler:\n GlobalObject().stophandler()\n reactor.callLater(0.5,reactor.stop)\n return True","function_tokens":["def","serverStop","(",")",":","log",".","msg","(","'stop'",")","if","GlobalObject","(",")",".","stophandler",":","GlobalObject","(",")",".","stophandler","(",")","reactor",".","callLater","(","0.5",",","reactor",".","stop",")","return","True"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/server\/admin.py#L15-L22"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/server\/admin.py","language":"python","identifier":"sreload","parameters":"()","argument_list":"","return_statement":"return True","docstring":"\u4f9bmaster\u8c03\u7528\u7684\u63a5\u53e3\uff1a\u70ed\u66f4\u65b0\u6a21\u5757","docstring_summary":"\u4f9bmaster\u8c03\u7528\u7684\u63a5\u53e3\uff1a\u70ed\u66f4\u65b0\u6a21\u5757","docstring_tokens":["\u4f9bmaster\u8c03\u7528\u7684\u63a5\u53e3\uff1a\u70ed\u66f4\u65b0\u6a21\u5757"],"function":"def sreload():\n \"\"\"\u4f9bmaster\u8c03\u7528\u7684\u63a5\u53e3\uff1a\u70ed\u66f4\u65b0\u6a21\u5757\n \"\"\"\n log.msg('reload')\n if GlobalObject().reloadmodule:\n reload(GlobalObject().reloadmodule)\n return True","function_tokens":["def","sreload","(",")",":","log",".","msg","(","'reload'",")","if","GlobalObject","(",")",".","reloadmodule",":","reload","(","GlobalObject","(",")",".","reloadmodule",")","return","True"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/server\/admin.py#L25-L31"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/server\/admin.py","language":"python","identifier":"remote_connect","parameters":"(rname, rhost)","argument_list":"","return_statement":"","docstring":"\u4f9bmaster\u8c03\u7528\u7684\u63a5\u53e3\uff1a\u8fdb\u884c\u8fdc\u7a0b\u7684rpc\u8fde\u63a5","docstring_summary":"\u4f9bmaster\u8c03\u7528\u7684\u63a5\u53e3\uff1a\u8fdb\u884c\u8fdc\u7a0b\u7684rpc\u8fde\u63a5","docstring_tokens":["\u4f9bmaster\u8c03\u7528\u7684\u63a5\u53e3\uff1a\u8fdb\u884c\u8fdc\u7a0b\u7684rpc\u8fde\u63a5"],"function":"def remote_connect(rname, rhost):\n \"\"\"\u4f9bmaster\u8c03\u7528\u7684\u63a5\u53e3\uff1a\u8fdb\u884c\u8fdc\u7a0b\u7684rpc\u8fde\u63a5\n \"\"\"\n GlobalObject().remote_connect(rname, rhost)","function_tokens":["def","remote_connect","(","rname",",","rhost",")",":","GlobalObject","(",")",".","remote_connect","(","rname",",","rhost",")"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/server\/admin.py#L34-L37"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/utils\/interfaces.py","language":"python","identifier":"IDataPackProtoc.getHeadlength","parameters":"()","argument_list":"","return_statement":"","docstring":"\u83b7\u53d6\u6570\u636e\u5305\u7684\u957f\u5ea6","docstring_summary":"\u83b7\u53d6\u6570\u636e\u5305\u7684\u957f\u5ea6","docstring_tokens":["\u83b7\u53d6\u6570\u636e\u5305\u7684\u957f\u5ea6"],"function":"def getHeadlength():\n \"\"\"\u83b7\u53d6\u6570\u636e\u5305\u7684\u957f\u5ea6\n \"\"\"\n pass","function_tokens":["def","getHeadlength","(",")",":","pass"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/utils\/interfaces.py#L13-L16"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/utils\/interfaces.py","language":"python","identifier":"IDataPackProtoc.unpack","parameters":"()","argument_list":"","return_statement":"","docstring":"\u89e3\u5305","docstring_summary":"\u89e3\u5305","docstring_tokens":["\u89e3\u5305"],"function":"def unpack():\n '''\u89e3\u5305\n '''","function_tokens":["def","unpack","(",")",":"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/utils\/interfaces.py#L18-L20"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/utils\/interfaces.py","language":"python","identifier":"IDataPackProtoc.pack","parameters":"()","argument_list":"","return_statement":"","docstring":"\u6253\u5305\u6570\u636e\u5305","docstring_summary":"\u6253\u5305\u6570\u636e\u5305","docstring_tokens":["\u6253\u5305\u6570\u636e\u5305"],"function":"def pack():\n '''\u6253\u5305\u6570\u636e\u5305\n '''","function_tokens":["def","pack","(",")",":"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/utils\/interfaces.py#L22-L24"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/utils\/services.py","language":"python","identifier":"Service.addUnDisplayTarget","parameters":"(self,command)","argument_list":"","return_statement":"","docstring":"Add a target unDisplay when client call it.","docstring_summary":"Add a target unDisplay when client call it.","docstring_tokens":["Add","a","target","unDisplay","when","client","call","it","."],"function":"def addUnDisplayTarget(self,command):\n '''Add a target unDisplay when client call it.'''\n self.unDisplay.add(command)","function_tokens":["def","addUnDisplayTarget","(","self",",","command",")",":","self",".","unDisplay",".","add","(","command",")"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/utils\/services.py#L27-L29"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/utils\/services.py","language":"python","identifier":"Service.mapTarget","parameters":"(self, target)","argument_list":"","return_statement":"","docstring":"Add a target to the service.","docstring_summary":"Add a target to the service.","docstring_tokens":["Add","a","target","to","the","service","."],"function":"def mapTarget(self, target):\n \"\"\"Add a target to the service.\"\"\"\n key = target.__name__\n if self._targets.has_key(key):\n exist_target = self._targets.get(key)\n raise \"target [%d] Already exists,\\\n Conflict between the %s and %s\"%(key,exist_target.__name__,target.__name__)\n self._targets[key] = target","function_tokens":["def","mapTarget","(","self",",","target",")",":","key","=","target",".","__name__","if","self",".","_targets",".","has_key","(","key",")",":","exist_target","=","self",".","_targets",".","get","(","key",")","raise","\"target [%d] Already exists,\\\n Conflict between the %s and %s\"","%","(","key",",","exist_target",".","__name__",",","target",".","__name__",")","self",".","_targets","[","key","]","=","target"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/utils\/services.py#L31-L38"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/utils\/services.py","language":"python","identifier":"Service.unMapTarget","parameters":"(self, target)","argument_list":"","return_statement":"","docstring":"Remove a target from the service.","docstring_summary":"Remove a target from the service.","docstring_tokens":["Remove","a","target","from","the","service","."],"function":"def unMapTarget(self, target):\n \"\"\"Remove a target from the service.\"\"\"\n key = target.__name__\n if key in self._targets:\n del self._targets[key]","function_tokens":["def","unMapTarget","(","self",",","target",")",":","key","=","target",".","__name__","if","key","in","self",".","_targets",":","del","self",".","_targets","[","key","]"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/utils\/services.py#L40-L44"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/utils\/services.py","language":"python","identifier":"Service.unMapTargetByKey","parameters":"(self,targetKey)","argument_list":"","return_statement":"","docstring":"Remove a target from the service.","docstring_summary":"Remove a target from the service.","docstring_tokens":["Remove","a","target","from","the","service","."],"function":"def unMapTargetByKey(self,targetKey):\n \"\"\"Remove a target from the service.\"\"\"\n del self._targets[targetKey]","function_tokens":["def","unMapTargetByKey","(","self",",","targetKey",")",":","del","self",".","_targets","[","targetKey","]"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/utils\/services.py#L46-L48"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/utils\/services.py","language":"python","identifier":"Service.getTarget","parameters":"(self, targetKey)","argument_list":"","return_statement":"return target","docstring":"Get a target from the service by name.","docstring_summary":"Get a target from the service by name.","docstring_tokens":["Get","a","target","from","the","service","by","name","."],"function":"def getTarget(self, targetKey):\n \"\"\"Get a target from the service by name.\"\"\"\n target = self._targets.get(targetKey, None)\n return target","function_tokens":["def","getTarget","(","self",",","targetKey",")",":","target","=","self",".","_targets",".","get","(","targetKey",",","None",")","return","target"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/utils\/services.py#L50-L53"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/utils\/services.py","language":"python","identifier":"Service.callTarget","parameters":"(self,targetKey,*args,**kw)","argument_list":"","return_statement":"return response","docstring":"call Target\n @param conn: client connection\n @param targetKey: target ID\n @param data: client data","docstring_summary":"call Target","docstring_tokens":["call","Target"],"function":"def callTarget(self,targetKey,*args,**kw):\n '''call Target\n @param conn: client connection\n @param targetKey: target ID\n @param data: client data\n '''\n target = self.getTarget(targetKey)\n if not target:\n log.err('the command '+str(targetKey)+' not Found on service')\n return None\n if targetKey not in self.unDisplay:\n log.msg(\"call method %s on service[single]\"%target.__name__)\n response = target(*args,**kw)\n return response","function_tokens":["def","callTarget","(","self",",","targetKey",",","*","args",",","*","*","kw",")",":","target","=","self",".","getTarget","(","targetKey",")","if","not","target",":","log",".","err","(","'the command '","+","str","(","targetKey",")","+","' not Found on service'",")","return","None","if","targetKey","not","in","self",".","unDisplay",":","log",".","msg","(","\"call method %s on service[single]\"","%","target",".","__name__",")","response","=","target","(","*","args",",","*","*","kw",")","return","response"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/utils\/services.py#L55-L68"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/utils\/services.py","language":"python","identifier":"CommandService.mapTarget","parameters":"(self, target)","argument_list":"","return_statement":"","docstring":"Add a target to the service.","docstring_summary":"Add a target to the service.","docstring_tokens":["Add","a","target","to","the","service","."],"function":"def mapTarget(self, target):\n \"\"\"Add a target to the service.\n \"\"\"\n key = int((target.__name__).split('_')[-1])\n if self._targets.has_key(key):\n exist_target = self._targets.get(key)\n raise \"target [%d] Already exists,\\\n Conflict between the %s and %s\"%(key,exist_target.__name__,target.__name__)\n self._targets[key] = target","function_tokens":["def","mapTarget","(","self",",","target",")",":","key","=","int","(","(","target",".","__name__",")",".","split","(","'_'",")","[","-","1","]",")","if","self",".","_targets",".","has_key","(","key",")",":","exist_target","=","self",".","_targets",".","get","(","key",")","raise","\"target [%d] Already exists,\\\n Conflict between the %s and %s\"","%","(","key",",","exist_target",".","__name__",",","target",".","__name__",")","self",".","_targets","[","key","]","=","target"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/utils\/services.py#L75-L83"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/utils\/services.py","language":"python","identifier":"CommandService.unMapTarget","parameters":"(self, target)","argument_list":"","return_statement":"","docstring":"Remove a target from the service.","docstring_summary":"Remove a target from the service.","docstring_tokens":["Remove","a","target","from","the","service","."],"function":"def unMapTarget(self, target):\n \"\"\"Remove a target from the service.\n \"\"\"\n key = int((target.__name__).split('_')[-1])\n if key in self._targets:\n del self._targets[key]","function_tokens":["def","unMapTarget","(","self",",","target",")",":","key","=","int","(","(","target",".","__name__",")",".","split","(","'_'",")","[","-","1","]",")","if","key","in","self",".","_targets",":","del","self",".","_targets","[","key","]"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/utils\/services.py#L85-L90"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/utils\/version.py","language":"python","identifier":"get_version","parameters":"(version=None)","argument_list":"","return_statement":"return str(main + sub)","docstring":"Returns a PEP 386-compliant version number from VERSION.","docstring_summary":"Returns a PEP 386-compliant version number from VERSION.","docstring_tokens":["Returns","a","PEP","386","-","compliant","version","number","from","VERSION","."],"function":"def get_version(version=None):\n \"Returns a PEP 386-compliant version number from VERSION.\"\n if version is None:\n from gfirefly import VERSION as version\n else:\n assert len(version) == 5\n assert version[3] in ('alpha', 'beta', 'rc', 'final')\n\n parts = 2 if version[2] == 0 else 3\n main = '.'.join(str(x) for x in version[:parts])\n\n sub = ''\n if version[3] == 'alpha' and version[4] == 0:\n git_changeset = get_git_changeset()\n if git_changeset:\n sub = '.dev%s' % git_changeset\n\n elif version[3] != 'final':\n mapping = {'alpha': 'a', 'beta': 'b', 'rc': 'c'}\n sub = mapping[version[3]] + str(version[4])\n\n return str(main + sub)","function_tokens":["def","get_version","(","version","=","None",")",":","if","version","is","None",":","from","gfirefly","import","VERSION","as","version","else",":","assert","len","(","version",")","==","5","assert","version","[","3","]","in","(","'alpha'",",","'beta'",",","'rc'",",","'final'",")","parts","=","2","if","version","[","2","]","==","0","else","3","main","=","'.'",".","join","(","str","(","x",")","for","x","in","version","[",":","parts","]",")","sub","=","''","if","version","[","3","]","==","'alpha'","and","version","[","4","]","==","0",":","git_changeset","=","get_git_changeset","(",")","if","git_changeset",":","sub","=","'.dev%s'","%","git_changeset","elif","version","[","3","]","!=","'final'",":","mapping","=","{","'alpha'",":","'a'",",","'beta'",":","'b'",",","'rc'",":","'c'","}","sub","=","mapping","[","version","[","3","]","]","+","str","(","version","[","4","]",")","return","str","(","main","+","sub",")"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/utils\/version.py#L13-L34"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/utils\/version.py","language":"python","identifier":"get_git_changeset","parameters":"()","argument_list":"","return_statement":"return timestamp.strftime('%Y%m%d%H%M%S')","docstring":"Returns a numeric identifier of the latest git changeset.\n\n The result is the UTC timestamp of the changeset in YYYYMMDDHHMMSS format.\n This value isn't guaranteed to be unique, but collisions are very unlikely,\n so it's sufficient for generating the development version numbers.","docstring_summary":"Returns a numeric identifier of the latest git changeset.","docstring_tokens":["Returns","a","numeric","identifier","of","the","latest","git","changeset","."],"function":"def get_git_changeset():\n \"\"\"Returns a numeric identifier of the latest git changeset.\n\n The result is the UTC timestamp of the changeset in YYYYMMDDHHMMSS format.\n This value isn't guaranteed to be unique, but collisions are very unlikely,\n so it's sufficient for generating the development version numbers.\n \"\"\"\n repo_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))\n git_log = subprocess.Popen('git log --pretty=format:%ct --quiet -1 HEAD',\n stdout=subprocess.PIPE, stderr=subprocess.PIPE,\n shell=True, cwd=repo_dir, universal_newlines=True)\n timestamp = git_log.communicate()[0]\n try:\n timestamp = datetime.datetime.utcfromtimestamp(int(timestamp))\n except ValueError:\n return None\n return timestamp.strftime('%Y%m%d%H%M%S')","function_tokens":["def","get_git_changeset","(",")",":","repo_dir","=","os",".","path",".","dirname","(","os",".","path",".","dirname","(","os",".","path",".","abspath","(","__file__",")",")",")","git_log","=","subprocess",".","Popen","(","'git log --pretty=format:%ct --quiet -1 HEAD'",",","stdout","=","subprocess",".","PIPE",",","stderr","=","subprocess",".","PIPE",",","shell","=","True",",","cwd","=","repo_dir",",","universal_newlines","=","True",")","timestamp","=","git_log",".","communicate","(",")","[","0","]","try",":","timestamp","=","datetime",".","datetime",".","utcfromtimestamp","(","int","(","timestamp",")",")","except","ValueError",":","return","None","return","timestamp",".","strftime","(","'%Y%m%d%H%M%S'",")"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/utils\/version.py#L37-L53"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/management\/__init__.py","language":"python","identifier":"Command.__init__","parameters":"(self,subcommond,*args)","argument_list":"","return_statement":"","docstring":"\u5de5\u5177\u7c7b\u6307\u4ee4","docstring_summary":"\u5de5\u5177\u7c7b\u6307\u4ee4","docstring_tokens":["\u5de5\u5177\u7c7b\u6307\u4ee4"],"function":"def __init__(self,subcommond,*args):\n '''\u5de5\u5177\u7c7b\u6307\u4ee4\n '''\n self.subcommond = subcommond\n self.args = args","function_tokens":["def","__init__","(","self",",","subcommond",",","*","args",")",":","self",".","subcommond","=","subcommond","self",".","args","=","args"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/management\/__init__.py#L18-L22"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/dbentrust\/util.py","language":"python","identifier":"FormatCondition","parameters":"(props)","argument_list":"","return_statement":"return sqlstr[:-4]","docstring":"\u751f\u6210\u67e5\u8be2\u6761\u4ef6\u5b57\u7b26\u4e32","docstring_summary":"\u751f\u6210\u67e5\u8be2\u6761\u4ef6\u5b57\u7b26\u4e32","docstring_tokens":["\u751f\u6210\u67e5\u8be2\u6761\u4ef6\u5b57\u7b26\u4e32"],"function":"def FormatCondition(props):\n \"\"\"\u751f\u6210\u67e5\u8be2\u6761\u4ef6\u5b57\u7b26\u4e32\n \"\"\"\n items = props.items()\n itemstrlist = []\n for _item in items:\n if isinstance(_item[1],Number):\n sqlstr = \" `%s`=%s AND\"%_item\n else:\n sqlstr = \" `%s`='%s' AND \"%(_item[0],str(_item[1]).replace(\"'\", \"\\\\'\"))\n itemstrlist.append(sqlstr)\n sqlstr = ''.join(itemstrlist)\n return sqlstr[:-4]","function_tokens":["def","FormatCondition","(","props",")",":","items","=","props",".","items","(",")","itemstrlist","=","[","]","for","_item","in","items",":","if","isinstance","(","_item","[","1","]",",","Number",")",":","sqlstr","=","\" `%s`=%s AND\"","%","_item","else",":","sqlstr","=","\" `%s`='%s' AND \"","%","(","_item","[","0","]",",","str","(","_item","[","1","]",")",".","replace","(","\"'\"",",","\"\\\\'\"",")",")","itemstrlist",".","append","(","sqlstr",")","sqlstr","=","''",".","join","(","itemstrlist",")","return","sqlstr","[",":","-","4","]"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/dbentrust\/util.py#L57-L69"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/dbentrust\/util.py","language":"python","identifier":"FormatUpdateStr","parameters":"(props)","argument_list":"","return_statement":"return sqlstr[:-1]","docstring":"\u751f\u6210\u66f4\u65b0\u8bed\u53e5","docstring_summary":"\u751f\u6210\u66f4\u65b0\u8bed\u53e5","docstring_tokens":["\u751f\u6210\u66f4\u65b0\u8bed\u53e5"],"function":"def FormatUpdateStr(props):\n \"\"\"\u751f\u6210\u66f4\u65b0\u8bed\u53e5\n \"\"\"\n items = props.items()\n itemstrlist = []\n for _item in items:\n if isinstance(_item[1],Number):\n sqlstr = \" `%s`=%s,\"%_item\n else:\n sqlstr = \" `%s`='%s',\"%(_item[0],str(_item[1]).replace(\"'\", \"\\\\'\"))\n itemstrlist.append(sqlstr)\n sqlstr = ''.join(itemstrlist)\n return sqlstr[:-1]","function_tokens":["def","FormatUpdateStr","(","props",")",":","items","=","props",".","items","(",")","itemstrlist","=","[","]","for","_item","in","items",":","if","isinstance","(","_item","[","1","]",",","Number",")",":","sqlstr","=","\" `%s`=%s,\"","%","_item","else",":","sqlstr","=","\" `%s`='%s',\"","%","(","_item","[","0","]",",","str","(","_item","[","1","]",")",".","replace","(","\"'\"",",","\"\\\\'\"",")",")","itemstrlist",".","append","(","sqlstr",")","sqlstr","=","''",".","join","(","itemstrlist",")","return","sqlstr","[",":","-","1","]"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/dbentrust\/util.py#L71-L83"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/dbentrust\/util.py","language":"python","identifier":"forEachUpdateProps","parameters":"(tablename,props,prere)","argument_list":"","return_statement":"return sqlstr","docstring":"\u904d\u5386\u6240\u8981\u4fee\u6539\u7684\u5c5e\u6027\uff0c\u4ee5\u751f\u6210sql\u8bed\u53e5","docstring_summary":"\u904d\u5386\u6240\u8981\u4fee\u6539\u7684\u5c5e\u6027\uff0c\u4ee5\u751f\u6210sql\u8bed\u53e5","docstring_tokens":["\u904d\u5386\u6240\u8981\u4fee\u6539\u7684\u5c5e\u6027\uff0c\u4ee5\u751f\u6210sql\u8bed\u53e5"],"function":"def forEachUpdateProps(tablename,props,prere):\n '''\u904d\u5386\u6240\u8981\u4fee\u6539\u7684\u5c5e\u6027\uff0c\u4ee5\u751f\u6210sql\u8bed\u53e5'''\n assert isinstance(props, dict)\n pro = FormatUpdateStr(props)\n pre = FormatCondition(prere)\n sqlstr = \"\"\"UPDATE `%s` SET %s WHERE %s;\"\"\"%(tablename,pro,pre) \n return sqlstr","function_tokens":["def","forEachUpdateProps","(","tablename",",","props",",","prere",")",":","assert","isinstance","(","props",",","dict",")","pro","=","FormatUpdateStr","(","props",")","pre","=","FormatCondition","(","prere",")","sqlstr","=","\"\"\"UPDATE `%s` SET %s WHERE %s;\"\"\"","%","(","tablename",",","pro",",","pre",")","return","sqlstr"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/dbentrust\/util.py#L85-L91"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/dbentrust\/util.py","language":"python","identifier":"EachQueryProps","parameters":"(props)","argument_list":"","return_statement":"","docstring":"\u904d\u5386\u5b57\u6bb5\u5217\u8868\u751f\u6210sql\u8bed\u53e5","docstring_summary":"\u904d\u5386\u5b57\u6bb5\u5217\u8868\u751f\u6210sql\u8bed\u53e5","docstring_tokens":["\u904d\u5386\u5b57\u6bb5\u5217\u8868\u751f\u6210sql\u8bed\u53e5"],"function":"def EachQueryProps(props):\n '''\u904d\u5386\u5b57\u6bb5\u5217\u8868\u751f\u6210sql\u8bed\u53e5\n '''\n sqlstr = \"\"\n if props == '*':\n return '*'\n elif type(props) == type([0]):\n for prop in props:\n sqlstr = sqlstr + prop +','\n sqlstr = sqlstr[:-1]\n return sqlstr\n else:\n raise Exception('props to query must be dict')\n return","function_tokens":["def","EachQueryProps","(","props",")",":","sqlstr","=","\"\"","if","props","==","'*'",":","return","'*'","elif","type","(","props",")","==","type","(","[","0","]",")",":","for","prop","in","props",":","sqlstr","=","sqlstr","+","prop","+","','","sqlstr","=","sqlstr","[",":","-","1","]","return","sqlstr","else",":","raise","Exception","(","'props to query must be dict'",")","return"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/dbentrust\/util.py#L93-L106"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/dbentrust\/util.py","language":"python","identifier":"forEachQueryProps","parameters":"(sqlstr, props)","argument_list":"","return_statement":"return sqlstr","docstring":"\u904d\u5386\u6240\u8981\u67e5\u8be2\u5c5e\u6027\uff0c\u4ee5\u751f\u6210sql\u8bed\u53e5","docstring_summary":"\u904d\u5386\u6240\u8981\u67e5\u8be2\u5c5e\u6027\uff0c\u4ee5\u751f\u6210sql\u8bed\u53e5","docstring_tokens":["\u904d\u5386\u6240\u8981\u67e5\u8be2\u5c5e\u6027\uff0c\u4ee5\u751f\u6210sql\u8bed\u53e5"],"function":"def forEachQueryProps(sqlstr, props):\n '''\u904d\u5386\u6240\u8981\u67e5\u8be2\u5c5e\u6027\uff0c\u4ee5\u751f\u6210sql\u8bed\u53e5'''\n if props == '*':\n sqlstr += ' *'\n elif type(props) == type([0]):\n i = 0\n for prop in props:\n if(i == 0):\n sqlstr += ' ' + prop\n else:\n sqlstr += ', ' + prop\n i += 1\n else:\n raise Exception('props to query must be list')\n return\n return sqlstr","function_tokens":["def","forEachQueryProps","(","sqlstr",",","props",")",":","if","props","==","'*'",":","sqlstr","+=","' *'","elif","type","(","props",")","==","type","(","[","0","]",")",":","i","=","0","for","prop","in","props",":","if","(","i","==","0",")",":","sqlstr","+=","' '","+","prop","else",":","sqlstr","+=","', '","+","prop","i","+=","1","else",":","raise","Exception","(","'props to query must be list'",")","return","return","sqlstr"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/dbentrust\/util.py#L108-L123"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/dbentrust\/util.py","language":"python","identifier":"DeleteFromDB","parameters":"(tablename,props)","argument_list":"","return_statement":"return bool(count)","docstring":"\u4ece\u6570\u636e\u5e93\u4e2d\u5220\u9664","docstring_summary":"\u4ece\u6570\u636e\u5e93\u4e2d\u5220\u9664","docstring_tokens":["\u4ece\u6570\u636e\u5e93\u4e2d\u5220\u9664"],"function":"def DeleteFromDB(tablename,props):\n '''\u4ece\u6570\u636e\u5e93\u4e2d\u5220\u9664\n '''\n prers = FormatCondition(props)\n sql = \"\"\"DELETE FROM %s WHERE %s ;\"\"\"%(tablename,prers)\n conn = dbpool.connection(write=True,tablename=tablename)\n cursor = conn.cursor()\n count = 0\n try:\n count = cursor.execute(sql)\n conn.commit()\n except Exception,e:\n log.err(e,traceback.format_exc())\n log.err(sql)\n cursor.close()\n conn.close()\n return bool(count)","function_tokens":["def","DeleteFromDB","(","tablename",",","props",")",":","prers","=","FormatCondition","(","props",")","sql","=","\"\"\"DELETE FROM %s WHERE %s ;\"\"\"","%","(","tablename",",","prers",")","conn","=","dbpool",".","connection","(","write","=","True",",","tablename","=","tablename",")","cursor","=","conn",".","cursor","(",")","count","=","0","try",":","count","=","cursor",".","execute","(","sql",")","conn",".","commit","(",")","except","Exception",",","e",":","log",".","err","(","e",",","traceback",".","format_exc","(",")",")","log",".","err","(","sql",")","cursor",".","close","(",")","conn",".","close","(",")","return","bool","(","count",")"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/dbentrust\/util.py#L153-L169"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/dbentrust\/util.py","language":"python","identifier":"InsertIntoDBAndReturnID","parameters":"(tablename,data)","argument_list":"","return_statement":"return result","docstring":"\u5199\u5165\u6570\u636e\u5e93,\u5e76\u8fd4\u56deID","docstring_summary":"\u5199\u5165\u6570\u636e\u5e93,\u5e76\u8fd4\u56deID","docstring_tokens":["\u5199\u5165\u6570\u636e\u5e93","\u5e76\u8fd4\u56deID"],"function":"def InsertIntoDBAndReturnID(tablename,data):\n \"\"\"\u5199\u5165\u6570\u636e\u5e93,\u5e76\u8fd4\u56deID\n \"\"\"\n sql = forEachPlusInsertProps(tablename,data)\n conn = dbpool.connection(write=True,tablename=tablename)\n cursor = conn.cursor()\n cursor.execute(sql)\n conn.commit()\n cursor.execute(\"SELECT LAST_INSERT_ID();\")\n result=cursor.fetchall()[0]\n cursor.close()\n conn.close()\n return result","function_tokens":["def","InsertIntoDBAndReturnID","(","tablename",",","data",")",":","sql","=","forEachPlusInsertProps","(","tablename",",","data",")","conn","=","dbpool",".","connection","(","write","=","True",",","tablename","=","tablename",")","cursor","=","conn",".","cursor","(",")","cursor",".","execute","(","sql",")","conn",".","commit","(",")","cursor",".","execute","(","\"SELECT LAST_INSERT_ID();\"",")","result","=","cursor",".","fetchall","(",")","[","0","]","cursor",".","close","(",")","conn",".","close","(",")","return","result"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/dbentrust\/util.py#L171-L183"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/dbentrust\/util.py","language":"python","identifier":"InsertIntoDB","parameters":"(tablename,data)","argument_list":"","return_statement":"return bool(count)","docstring":"\u5199\u5165\u6570\u636e\u5e93","docstring_summary":"\u5199\u5165\u6570\u636e\u5e93","docstring_tokens":["\u5199\u5165\u6570\u636e\u5e93"],"function":"def InsertIntoDB(tablename,data):\n \"\"\"\u5199\u5165\u6570\u636e\u5e93\n \"\"\"\n sql = forEachPlusInsertProps(tablename,data)\n conn = dbpool.connection(write=True,tablename=tablename)\n cursor = conn.cursor()\n count = cursor.execute(sql)\n conn.commit()\n cursor.close()\n conn.close()\n return bool(count)","function_tokens":["def","InsertIntoDB","(","tablename",",","data",")",":","sql","=","forEachPlusInsertProps","(","tablename",",","data",")","conn","=","dbpool",".","connection","(","write","=","True",",","tablename","=","tablename",")","cursor","=","conn",".","cursor","(",")","count","=","cursor",".","execute","(","sql",")","conn",".","commit","(",")","cursor",".","close","(",")","conn",".","close","(",")","return","bool","(","count",")"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/dbentrust\/util.py#L185-L195"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/dbentrust\/util.py","language":"python","identifier":"UpdateWithDict","parameters":"(tablename,props,prere)","argument_list":"","return_statement":"return False","docstring":"\u66f4\u65b0\u8bb0\u5f55","docstring_summary":"\u66f4\u65b0\u8bb0\u5f55","docstring_tokens":["\u66f4\u65b0\u8bb0\u5f55"],"function":"def UpdateWithDict(tablename,props,prere):\n \"\"\"\u66f4\u65b0\u8bb0\u5f55\n \"\"\"\n sql = forEachUpdateProps(tablename, props, prere)\n conn = dbpool.connection(write=True,tablename=tablename)\n cursor = conn.cursor()\n count = 0\n try:\n count = cursor.execute(sql)\n conn.commit()\n except Exception,e:\n log.err(e,traceback.format_exc())\n log.err(sql)\n cursor.close()\n conn.close()\n if(count >= 1):\n return True\n return False","function_tokens":["def","UpdateWithDict","(","tablename",",","props",",","prere",")",":","sql","=","forEachUpdateProps","(","tablename",",","props",",","prere",")","conn","=","dbpool",".","connection","(","write","=","True",",","tablename","=","tablename",")","cursor","=","conn",".","cursor","(",")","count","=","0","try",":","count","=","cursor",".","execute","(","sql",")","conn",".","commit","(",")","except","Exception",",","e",":","log",".","err","(","e",",","traceback",".","format_exc","(",")",")","log",".","err","(","sql",")","cursor",".","close","(",")","conn",".","close","(",")","if","(","count",">=","1",")",":","return","True","return","False"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/dbentrust\/util.py#L202-L219"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/dbentrust\/util.py","language":"python","identifier":"getAllPkByFkInDB","parameters":"(tablename,pkname,props)","argument_list":"","return_statement":"return [key[0] for key in result]","docstring":"\u6839\u636e\u6240\u6709\u7684\u5916\u952e\u83b7\u53d6\u4e3b\u952eID","docstring_summary":"\u6839\u636e\u6240\u6709\u7684\u5916\u952e\u83b7\u53d6\u4e3b\u952eID","docstring_tokens":["\u6839\u636e\u6240\u6709\u7684\u5916\u952e\u83b7\u53d6\u4e3b\u952eID"],"function":"def getAllPkByFkInDB(tablename,pkname,props):\n \"\"\"\u6839\u636e\u6240\u6709\u7684\u5916\u952e\u83b7\u53d6\u4e3b\u952eID\n \"\"\"\n props = FormatCondition(props)\n sql = \"\"\"select `%s` from `%s` where %s;\"\"\"%(pkname,tablename,props)\n conn = dbpool.connection(write=False,tablename=tablename)\n cursor = conn.cursor()\n cursor.execute(sql)\n result = cursor.fetchall()\n cursor.close()\n conn.close()\n return [key[0] for key in result]","function_tokens":["def","getAllPkByFkInDB","(","tablename",",","pkname",",","props",")",":","props","=","FormatCondition","(","props",")","sql","=","\"\"\"select `%s` from `%s` where %s;\"\"\"","%","(","pkname",",","tablename",",","props",")","conn","=","dbpool",".","connection","(","write","=","False",",","tablename","=","tablename",")","cursor","=","conn",".","cursor","(",")","cursor",".","execute","(","sql",")","result","=","cursor",".","fetchall","(",")","cursor",".","close","(",")","conn",".","close","(",")","return","[","key","[","0","]","for","key","in","result","]"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/dbentrust\/util.py#L221-L232"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/dbentrust\/util.py","language":"python","identifier":"GetOneRecordInfo","parameters":"(tablename,props)","argument_list":"","return_statement":"return result","docstring":"\u83b7\u53d6\u5355\u6761\u6570\u636e\u7684\u4fe1\u606f","docstring_summary":"\u83b7\u53d6\u5355\u6761\u6570\u636e\u7684\u4fe1\u606f","docstring_tokens":["\u83b7\u53d6\u5355\u6761\u6570\u636e\u7684\u4fe1\u606f"],"function":"def GetOneRecordInfo(tablename,props):\n '''\u83b7\u53d6\u5355\u6761\u6570\u636e\u7684\u4fe1\u606f\n '''\n props = FormatCondition(props)\n sql = \"\"\"Select * from `%s` where %s;\"\"\"%(tablename,props)\n conn = dbpool.connection(write=False,tablename=tablename)\n cursor = conn.cursor(cursorclass = DictCursor)\n cursor.execute(sql)\n result = cursor.fetchone()\n cursor.close()\n conn.close()\n return result","function_tokens":["def","GetOneRecordInfo","(","tablename",",","props",")",":","props","=","FormatCondition","(","props",")","sql","=","\"\"\"Select * from `%s` where %s;\"\"\"","%","(","tablename",",","props",")","conn","=","dbpool",".","connection","(","write","=","False",",","tablename","=","tablename",")","cursor","=","conn",".","cursor","(","cursorclass","=","DictCursor",")","cursor",".","execute","(","sql",")","result","=","cursor",".","fetchone","(",")","cursor",".","close","(",")","conn",".","close","(",")","return","result"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/dbentrust\/util.py#L234-L245"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/dbentrust\/mmode.py","language":"python","identifier":"DBPub._run","parameters":"(self)","argument_list":"","return_statement":"","docstring":"\u6267\u884c\u534f\u8bae","docstring_summary":"\u6267\u884c\u534f\u8bae","docstring_tokens":["\u6267\u884c\u534f\u8bae"],"function":"def _run(self):\n \"\"\"\u6267\u884c\u534f\u8bae\n \"\"\"\n address = 'tcp:\/\/%s:%s'%self.to_db_address\n self.sock.connect(address)\n while True:\n try:\n message = self.inbox.get()\n self.sock.send_pyobj(message)\n except Exception as e:\n log.err(_stuff=e,_why=traceback.format_exc())\n log.msg(str(message))","function_tokens":["def","_run","(","self",")",":","address","=","'tcp:\/\/%s:%s'","%","self",".","to_db_address","self",".","sock",".","connect","(","address",")","while","True",":","try",":","message","=","self",".","inbox",".","get","(",")","self",".","sock",".","send_pyobj","(","message",")","except","Exception","as","e",":","log",".","err","(","_stuff","=","e",",","_why","=","traceback",".","format_exc","(",")",")","log",".","msg","(","str","(","message",")",")"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/dbentrust\/mmode.py#L51-L62"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/dbentrust\/mmode.py","language":"python","identifier":"MMode.getData","parameters":"(self)","argument_list":"","return_statement":"return None","docstring":"\u83b7\u53d6data\u6570\u636e","docstring_summary":"\u83b7\u53d6data\u6570\u636e","docstring_tokens":["\u83b7\u53d6data\u6570\u636e"],"function":"def getData(self):\n \"\"\"\u83b7\u53d6data\u6570\u636e\n \"\"\"\n data = self.get('data')\n if data:\n return data\n tablename,pk_value = self._name.split(':')\n props = {self._pk:int(pk_value)}\n record = util.GetOneRecordInfo(tablename,props)\n if record:\n self.data = record\n self.insert()\n return self.data\n return None","function_tokens":["def","getData","(","self",")",":","data","=","self",".","get","(","'data'",")","if","data",":","return","data","tablename",",","pk_value","=","self",".","_name",".","split","(","':'",")","props","=","{","self",".","_pk",":","int","(","pk_value",")","}","record","=","util",".","GetOneRecordInfo","(","tablename",",","props",")","if","record",":","self",".","data","=","record","self",".","insert","(",")","return","self",".","data","return","None"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/dbentrust\/mmode.py#L127-L140"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/dbentrust\/mmode.py","language":"python","identifier":"MMode.delete","parameters":"(self)","argument_list":"","return_statement":"","docstring":"\u6e05\u7406\u5bf9\u8c61","docstring_summary":"\u6e05\u7406\u5bf9\u8c61","docstring_tokens":["\u6e05\u7406\u5bf9\u8c61"],"function":"def delete(self):\n \"\"\"\u6e05\u7406\u5bf9\u8c61\n \"\"\"\n self.syncDB(state=MMODE_STATE_DEL)\n if self._fk:\n data = self.getData()\n if data:\n fk = data.get(self._fk,\"\")\n pk = data.get(self._pk)\n self._update_fk(pk, fk, None)\n self.mdelete()","function_tokens":["def","delete","(","self",")",":","self",".","syncDB","(","state","=","MMODE_STATE_DEL",")","if","self",".","_fk",":","data","=","self",".","getData","(",")","if","data",":","fk","=","data",".","get","(","self",".","_fk",",","\"\"",")","pk","=","data",".","get","(","self",".","_pk",")","self",".","_update_fk","(","pk",",","fk",",","None",")","self",".","mdelete","(",")"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/dbentrust\/mmode.py#L142-L152"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/dbentrust\/mmode.py","language":"python","identifier":"MMode.IsEffective","parameters":"(self)","argument_list":"","return_statement":"return True","docstring":"\u68c0\u6d4b\u5bf9\u8c61\u662f\u5426\u6709\u6548","docstring_summary":"\u68c0\u6d4b\u5bf9\u8c61\u662f\u5426\u6709\u6548","docstring_tokens":["\u68c0\u6d4b\u5bf9\u8c61\u662f\u5426\u6709\u6548"],"function":"def IsEffective(self):\n '''\u68c0\u6d4b\u5bf9\u8c61\u662f\u5426\u6709\u6548\n '''\n return True","function_tokens":["def","IsEffective","(","self",")",":","return","True"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/dbentrust\/mmode.py#L154-L157"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/dbentrust\/mmode.py","language":"python","identifier":"MMode.syncDB","parameters":"(self,state=MMODE_STATE_UPDATE)","argument_list":"","return_statement":"return result","docstring":"\u540c\u6b65\u5230\u6570\u636e\u5e93","docstring_summary":"\u540c\u6b65\u5230\u6570\u636e\u5e93","docstring_tokens":["\u540c\u6b65\u5230\u6570\u636e\u5e93"],"function":"def syncDB(self,state=MMODE_STATE_UPDATE):\n \"\"\"\u540c\u6b65\u5230\u6570\u636e\u5e93\n \"\"\"\n tablename = self._name.split(':')[0]\n if state==MMODE_STATE_NEW:\n props = self.getData()\n pk = self._pk\n result = util.InsertIntoDB(tablename, props)\n elif state==MMODE_STATE_UPDATE:\n props = self.getData()\n pk = self._pk\n prere = {pk:props.get(pk)}\n sql = util.UpdateWithDictSQL(tablename, props, prere)\n DBPub().send((tablename,sql))\n result = True\n else:\n pk = self._pk\n props = self.getData()\n prere = {pk:props.get(pk)}\n result = util.DeleteFromDB(tablename,prere)\n return result","function_tokens":["def","syncDB","(","self",",","state","=","MMODE_STATE_UPDATE",")",":","tablename","=","self",".","_name",".","split","(","':'",")","[","0","]","if","state","==","MMODE_STATE_NEW",":","props","=","self",".","getData","(",")","pk","=","self",".","_pk","result","=","util",".","InsertIntoDB","(","tablename",",","props",")","elif","state","==","MMODE_STATE_UPDATE",":","props","=","self",".","getData","(",")","pk","=","self",".","_pk","prere","=","{","pk",":","props",".","get","(","pk",")","}","sql","=","util",".","UpdateWithDictSQL","(","tablename",",","props",",","prere",")","DBPub","(",")",".","send","(","(","tablename",",","sql",")",")","result","=","True","else",":","pk","=","self",".","_pk","props","=","self",".","getData","(",")","prere","=","{","pk",":","props",".","get","(","pk",")","}","result","=","util",".","DeleteFromDB","(","tablename",",","prere",")","return","result"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/dbentrust\/mmode.py#L159-L179"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/dbentrust\/mmode.py","language":"python","identifier":"MAdmin.load","parameters":"(self)","argument_list":"","return_statement":"","docstring":"\u8bfb\u53d6\u6570\u636e\u5230\u6570\u636e\u5e93\u4e2d","docstring_summary":"\u8bfb\u53d6\u6570\u636e\u5230\u6570\u636e\u5e93\u4e2d","docstring_tokens":["\u8bfb\u53d6\u6570\u636e\u5230\u6570\u636e\u5e93\u4e2d"],"function":"def load(self):\n '''\u8bfb\u53d6\u6570\u636e\u5230\u6570\u636e\u5e93\u4e2d\n '''\n mmname = self._name\n recordlist = util.ReadDataFromDB(mmname)\n for record in recordlist:\n pk = record[self.pk]\n mm = MMode(self._name+':%s'%pk,self.pk,data=record,fk=self._fk,timeout=self.timeout)\n mm.insert()","function_tokens":["def","load","(","self",")",":","mmname","=","self",".","_name","recordlist","=","util",".","ReadDataFromDB","(","mmname",")","for","record","in","recordlist",":","pk","=","record","[","self",".","pk","]","mm","=","MMode","(","self",".","_name","+","':%s'","%","pk",",","self",".","pk",",","data","=","record",",","fk","=","self",".","_fk",",","timeout","=","self",".","timeout",")","mm",".","insert","(",")"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/dbentrust\/mmode.py#L200-L208"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/dbentrust\/mmode.py","language":"python","identifier":"MAdmin.getAllPkByFk","parameters":"(self,fk)","argument_list":"","return_statement":"return dbkeylist","docstring":"\u6839\u636e\u5916\u952e\u83b7\u53d6\u4e3b\u952e\u5217\u8868","docstring_summary":"\u6839\u636e\u5916\u952e\u83b7\u53d6\u4e3b\u952e\u5217\u8868","docstring_tokens":["\u6839\u636e\u5916\u952e\u83b7\u53d6\u4e3b\u952e\u5217\u8868"],"function":"def getAllPkByFk(self,fk):\n '''\u6839\u636e\u5916\u952e\u83b7\u53d6\u4e3b\u952e\u5217\u8868\n '''\n name = '%s_fk:%s'%(self._name,fk)\n fkmm = MFKMode(name)\n pklist = fkmm.get('pklist')\n if pklist is not None:\n return pklist\n props = {self._fk:fk}\n dbkeylist = util.getAllPkByFkInDB(self._name, self.pk, props)\n name = '%s_fk:%s'%(self._name,fk)\n fkmm = MFKMode(name, pklist = dbkeylist)\n fkmm.insert()\n return dbkeylist","function_tokens":["def","getAllPkByFk","(","self",",","fk",")",":","name","=","'%s_fk:%s'","%","(","self",".","_name",",","fk",")","fkmm","=","MFKMode","(","name",")","pklist","=","fkmm",".","get","(","'pklist'",")","if","pklist","is","not","None",":","return","pklist","props","=","{","self",".","_fk",":","fk","}","dbkeylist","=","util",".","getAllPkByFkInDB","(","self",".","_name",",","self",".","pk",",","props",")","name","=","'%s_fk:%s'","%","(","self",".","_name",",","fk",")","fkmm","=","MFKMode","(","name",",","pklist","=","dbkeylist",")","fkmm",".","insert","(",")","return","dbkeylist"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/dbentrust\/mmode.py#L210-L223"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/dbentrust\/mmode.py","language":"python","identifier":"MAdmin.getObj","parameters":"(self,pk)","argument_list":"","return_statement":"return mm","docstring":"\u6839\u636e\u4e3b\u952e\uff0c\u53ef\u4ee5\u83b7\u5f97mmode\u5bf9\u8c61\u7684\u5b9e\u4f8b.\\n\n >>> m = madmin.getObj(1)","docstring_summary":"\u6839\u636e\u4e3b\u952e\uff0c\u53ef\u4ee5\u83b7\u5f97mmode\u5bf9\u8c61\u7684\u5b9e\u4f8b.\\n\n >>> m = madmin.getObj(1)","docstring_tokens":["\u6839\u636e\u4e3b\u952e\uff0c\u53ef\u4ee5\u83b7\u5f97mmode\u5bf9\u8c61\u7684\u5b9e\u4f8b",".","\\","n",">>>","m","=","madmin",".","getObj","(","1",")"],"function":"def getObj(self,pk):\n '''\u6839\u636e\u4e3b\u952e\uff0c\u53ef\u4ee5\u83b7\u5f97mmode\u5bf9\u8c61\u7684\u5b9e\u4f8b.\\n\n >>> m = madmin.getObj(1)\n '''\n mm = MMode(self._name+':%s'%pk,self.pk,fk=self._fk,timeout=self.timeout)\n if mm.get('data'):\n return mm\n props = {self.pk:pk}\n record = util.GetOneRecordInfo(self._name,props)\n if not record:\n return None\n mm = MMode(self._name+':%s'%pk,self.pk,data = record,fk=self._fk,timeout=self.timeout)\n mm.insert()\n return mm","function_tokens":["def","getObj","(","self",",","pk",")",":","mm","=","MMode","(","self",".","_name","+","':%s'","%","pk",",","self",".","pk",",","fk","=","self",".","_fk",",","timeout","=","self",".","timeout",")","if","mm",".","get","(","'data'",")",":","return","mm","props","=","{","self",".","pk",":","pk","}","record","=","util",".","GetOneRecordInfo","(","self",".","_name",",","props",")","if","not","record",":","return","None","mm","=","MMode","(","self",".","_name","+","':%s'","%","pk",",","self",".","pk",",","data","=","record",",","fk","=","self",".","_fk",",","timeout","=","self",".","timeout",")","mm",".","insert","(",")","return","mm"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/dbentrust\/mmode.py#L225-L238"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/dbentrust\/mmode.py","language":"python","identifier":"MAdmin.getObjData","parameters":"(self,pk)","argument_list":"","return_statement":"return record","docstring":"\u6839\u636e\u4e3b\u952e\uff0c\u53ef\u4ee5\u83b7\u5f97mmode\u5bf9\u8c61\u7684\u5b9e\u4f8b\u7684\u6570\u636e.\\n\n >>> m = madmin.getObjData(1)","docstring_summary":"\u6839\u636e\u4e3b\u952e\uff0c\u53ef\u4ee5\u83b7\u5f97mmode\u5bf9\u8c61\u7684\u5b9e\u4f8b\u7684\u6570\u636e.\\n\n >>> m = madmin.getObjData(1)","docstring_tokens":["\u6839\u636e\u4e3b\u952e\uff0c\u53ef\u4ee5\u83b7\u5f97mmode\u5bf9\u8c61\u7684\u5b9e\u4f8b\u7684\u6570\u636e",".","\\","n",">>>","m","=","madmin",".","getObjData","(","1",")"],"function":"def getObjData(self,pk):\n '''\u6839\u636e\u4e3b\u952e\uff0c\u53ef\u4ee5\u83b7\u5f97mmode\u5bf9\u8c61\u7684\u5b9e\u4f8b\u7684\u6570\u636e.\\n\n >>> m = madmin.getObjData(1)\n '''\n mm = MMode(self._name+':%s'%pk,self.pk,fk=self._fk,timeout=self.timeout)\n if not mm.IsEffective():\n return None\n data = mm.get('data')\n if data:\n return data\n props = {self.pk:pk}\n record = util.GetOneRecordInfo(self._name,props)\n if not record:\n return None\n mm = MMode(self._name+':%s'%pk,self.pk,data = record,fk=self._fk,timeout=self.timeout)\n mm.insert()\n return record","function_tokens":["def","getObjData","(","self",",","pk",")",":","mm","=","MMode","(","self",".","_name","+","':%s'","%","pk",",","self",".","pk",",","fk","=","self",".","_fk",",","timeout","=","self",".","timeout",")","if","not","mm",".","IsEffective","(",")",":","return","None","data","=","mm",".","get","(","'data'",")","if","data",":","return","data","props","=","{","self",".","pk",":","pk","}","record","=","util",".","GetOneRecordInfo","(","self",".","_name",",","props",")","if","not","record",":","return","None","mm","=","MMode","(","self",".","_name","+","':%s'","%","pk",",","self",".","pk",",","data","=","record",",","fk","=","self",".","_fk",",","timeout","=","self",".","timeout",")","mm",".","insert","(",")","return","record"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/dbentrust\/mmode.py#L240-L256"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/dbentrust\/mmode.py","language":"python","identifier":"MAdmin.getObjList","parameters":"(self,pklist)","argument_list":"","return_statement":"return objlist","docstring":"\u6839\u636e\u4e3b\u952e\u5217\u8868\u83b7\u53d6mmode\u5bf9\u8c61\u7684\u5217\u8868.\\n\n >>> m = madmin.getObjList([1,2,3,4,5])","docstring_summary":"\u6839\u636e\u4e3b\u952e\u5217\u8868\u83b7\u53d6mmode\u5bf9\u8c61\u7684\u5217\u8868.\\n\n >>> m = madmin.getObjList([1,2,3,4,5])","docstring_tokens":["\u6839\u636e\u4e3b\u952e\u5217\u8868\u83b7\u53d6mmode\u5bf9\u8c61\u7684\u5217\u8868",".","\\","n",">>>","m","=","madmin",".","getObjList","(","[","1","2","3","4","5","]",")"],"function":"def getObjList(self,pklist):\n '''\u6839\u636e\u4e3b\u952e\u5217\u8868\u83b7\u53d6mmode\u5bf9\u8c61\u7684\u5217\u8868.\\n\n >>> m = madmin.getObjList([1,2,3,4,5])\n '''\n _pklist = []\n objlist = []\n for pk in pklist:\n mm = MMode(self._name+':%s'%pk,self.pk,fk=self._fk,timeout=self.timeout)\n if not mm.IsEffective():\n continue\n if mm.get('data'):\n objlist.append(mm)\n else:\n _pklist.append(pk)\n if _pklist:\n recordlist = util.GetRecordList(self._name, self.pk,_pklist)\n for record in recordlist:\n pk = record[self.pk]\n mm = MMode(self._name+':%s'%pk,self.pk,data = record,fk=self._fk,timeout=self.timeout)\n mm.insert()\n objlist.append(mm)\n return objlist","function_tokens":["def","getObjList","(","self",",","pklist",")",":","_pklist","=","[","]","objlist","=","[","]","for","pk","in","pklist",":","mm","=","MMode","(","self",".","_name","+","':%s'","%","pk",",","self",".","pk",",","fk","=","self",".","_fk",",","timeout","=","self",".","timeout",")","if","not","mm",".","IsEffective","(",")",":","continue","if","mm",".","get","(","'data'",")",":","objlist",".","append","(","mm",")","else",":","_pklist",".","append","(","pk",")","if","_pklist",":","recordlist","=","util",".","GetRecordList","(","self",".","_name",",","self",".","pk",",","_pklist",")","for","record","in","recordlist",":","pk","=","record","[","self",".","pk","]","mm","=","MMode","(","self",".","_name","+","':%s'","%","pk",",","self",".","pk",",","data","=","record",",","fk","=","self",".","_fk",",","timeout","=","self",".","timeout",")","mm",".","insert","(",")","objlist",".","append","(","mm",")","return","objlist"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/dbentrust\/mmode.py#L259-L280"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/dbentrust\/mmode.py","language":"python","identifier":"MAdmin.deleteMode","parameters":"(self,pk)","argument_list":"","return_statement":"return True","docstring":"\u6839\u636e\u4e3b\u952e\u5220\u9664\u5185\u5b58\u4e2d\u7684\u67d0\u6761\u8bb0\u5f55\u4fe1\u606f\uff0c\\n\u8fd9\u91cc\u53ea\u662f\u4fee\u6539\u5185\u5b58\u4e2d\u7684\u8bb0\u5f55\u72b6\u6001_state\u4e3a\u5220\u9664\u72b6\u6001.\\n\n >>> m = madmin.deleteMode(1)","docstring_summary":"\u6839\u636e\u4e3b\u952e\u5220\u9664\u5185\u5b58\u4e2d\u7684\u67d0\u6761\u8bb0\u5f55\u4fe1\u606f\uff0c\\n\u8fd9\u91cc\u53ea\u662f\u4fee\u6539\u5185\u5b58\u4e2d\u7684\u8bb0\u5f55\u72b6\u6001_state\u4e3a\u5220\u9664\u72b6\u6001.\\n\n >>> m = madmin.deleteMode(1)","docstring_tokens":["\u6839\u636e\u4e3b\u952e\u5220\u9664\u5185\u5b58\u4e2d\u7684\u67d0\u6761\u8bb0\u5f55\u4fe1\u606f\uff0c","\\","n\u8fd9\u91cc\u53ea\u662f\u4fee\u6539\u5185\u5b58\u4e2d\u7684\u8bb0\u5f55\u72b6\u6001_state\u4e3a\u5220\u9664\u72b6\u6001",".","\\","n",">>>","m","=","madmin",".","deleteMode","(","1",")"],"function":"def deleteMode(self,pk):\n '''\u6839\u636e\u4e3b\u952e\u5220\u9664\u5185\u5b58\u4e2d\u7684\u67d0\u6761\u8bb0\u5f55\u4fe1\u606f\uff0c\\n\u8fd9\u91cc\u53ea\u662f\u4fee\u6539\u5185\u5b58\u4e2d\u7684\u8bb0\u5f55\u72b6\u6001_state\u4e3a\u5220\u9664\u72b6\u6001.\\n\n >>> m = madmin.deleteMode(1)\n '''\n mm = self.getObj(pk)\n if mm:\n# if self._fk:\n# data = mm.get('data')\n# if data:\n# fk = data.get(self._fk,0)\n# name = '%s_fk:%s'%(self._name,fk)\n# fkmm = MFKMode(name)\n# pklist = fkmm.get('pklist')\n# if pklist and pk in pklist:\n# pklist.remove(pk)\n# fkmm.update('pklist', pklist)\n mm.delete()\n return True","function_tokens":["def","deleteMode","(","self",",","pk",")",":","mm","=","self",".","getObj","(","pk",")","if","mm",":","# if self._fk:","# data = mm.get('data')","# if data:","# fk = data.get(self._fk,0)","# name = '%s_fk:%s'%(self._name,fk)","# fkmm = MFKMode(name)","# pklist = fkmm.get('pklist')","# if pklist and pk in pklist:","# pklist.remove(pk)","# fkmm.update('pklist', pklist)","mm",".","delete","(",")","return","True"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/dbentrust\/mmode.py#L282-L299"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/dbentrust\/mmode.py","language":"python","identifier":"MAdmin.new","parameters":"(self,data)","argument_list":"","return_statement":"return mm","docstring":"\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u5bf9\u8c61","docstring_summary":"\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u5bf9\u8c61","docstring_tokens":["\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u5bf9\u8c61"],"function":"def new(self,data):\n \"\"\"\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u5bf9\u8c61\n \"\"\"\n incrkey = self.incrkey\n tablename = self._name\n if incrkey:\n result = util.InsertIntoDBAndReturnID(tablename, data)\n data[incrkey] = result[0]\n pk = data.get(self.pk)\n if pk is None:\n raise PKValueError(data)\n mm = MMode(self._name+':%s'%pk,self.pk,data=data,fk=self._fk,timeout=self.timeout)\n else:\n pk = data.get(self.pk)\n result = util.InsertIntoDB(tablename, data)\n if not result:\n raise util.SQLError()\n mm = MMode(self._name+':%s'%pk,self.pk,data=data,fk=self._fk,timeout=self.timeout)\n mm.insert()\n if self._fk:\n fk = data.get(self._fk,0)\n name = '%s_fk:%s'%(self._name,fk)\n fkmm = MFKMode(name)\n pklist = fkmm.get('pklist')\n pklist = self.getAllPkByFk(fk)\n pklist.append(pk)\n fkmm.update('pklist', pklist)\n return mm","function_tokens":["def","new","(","self",",","data",")",":","incrkey","=","self",".","incrkey","tablename","=","self",".","_name","if","incrkey",":","result","=","util",".","InsertIntoDBAndReturnID","(","tablename",",","data",")","data","[","incrkey","]","=","result","[","0","]","pk","=","data",".","get","(","self",".","pk",")","if","pk","is","None",":","raise","PKValueError","(","data",")","mm","=","MMode","(","self",".","_name","+","':%s'","%","pk",",","self",".","pk",",","data","=","data",",","fk","=","self",".","_fk",",","timeout","=","self",".","timeout",")","else",":","pk","=","data",".","get","(","self",".","pk",")","result","=","util",".","InsertIntoDB","(","tablename",",","data",")","if","not","result",":","raise","util",".","SQLError","(",")","mm","=","MMode","(","self",".","_name","+","':%s'","%","pk",",","self",".","pk",",","data","=","data",",","fk","=","self",".","_fk",",","timeout","=","self",".","timeout",")","mm",".","insert","(",")","if","self",".","_fk",":","fk","=","data",".","get","(","self",".","_fk",",","0",")","name","=","'%s_fk:%s'","%","(","self",".","_name",",","fk",")","fkmm","=","MFKMode","(","name",")","pklist","=","fkmm",".","get","(","'pklist'",")","pklist","=","self",".","getAllPkByFk","(","fk",")","pklist",".","append","(","pk",")","fkmm",".","update","(","'pklist'",",","pklist",")","return","mm"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/dbentrust\/mmode.py#L327-L354"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/dbentrust\/memobject.py","language":"python","identifier":"MemObject.__init__","parameters":"(self,name,**kw)","argument_list":"","return_statement":"","docstring":"@param name: str \u5bf9\u8c61\u7684\u540d\u79f0\\n\n @param _lock: int \u5bf9\u8c61\u9501 \u4e3a1\u65f6\u8868\u793a\u5bf9\u8c61\u88ab\u9501\u5b9a\u65e0\u6cd5\u8fdb\u884c\u4fee\u6539\\n","docstring_summary":"","docstring_tokens":[],"function":"def __init__(self,name,**kw):\n '''\n @param name: str \u5bf9\u8c61\u7684\u540d\u79f0\\n\n @param _lock: int \u5bf9\u8c61\u9501 \u4e3a1\u65f6\u8868\u793a\u5bf9\u8c61\u88ab\u9501\u5b9a\u65e0\u6cd5\u8fdb\u884c\u4fee\u6539\\n\n '''\n self._name = name\n self._locked = False\n self._timestamp = 0\n self._cas = kw.get(\"cas\",False)\n self._cache = kw.get(\"cache\",True)\n self._timeout = kw.get(\"timeout\",CACHE_TIMEOUT)\n if self._cas:\n self.lock()","function_tokens":["def","__init__","(","self",",","name",",","*","*","kw",")",":","self",".","_name","=","name","self",".","_locked","=","False","self",".","_timestamp","=","0","self",".","_cas","=","kw",".","get","(","\"cas\"",",","False",")","self",".","_cache","=","kw",".","get","(","\"cache\"",",","True",")","self",".","_timeout","=","kw",".","get","(","\"timeout\"",",","CACHE_TIMEOUT",")","if","self",".","_cas",":","self",".","lock","(",")"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/dbentrust\/memobject.py#L41-L53"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/dbentrust\/memobject.py","language":"python","identifier":"MemObject.produceKey","parameters":"(self,keyname)","argument_list":"","return_statement":"","docstring":"\u91cd\u65b0\u751f\u6210key","docstring_summary":"\u91cd\u65b0\u751f\u6210key","docstring_tokens":["\u91cd\u65b0\u751f\u6210key"],"function":"def produceKey(self,keyname):\n '''\n \u91cd\u65b0\u751f\u6210key\n '''\n if isinstance(keyname, basestring):\n return str(''.join([self._name,':',keyname]))\n else:\n raise MEMKeyError()","function_tokens":["def","produceKey","(","self",",","keyname",")",":","if","isinstance","(","keyname",",","basestring",")",":","return","str","(","''",".","join","(","[","self",".","_name",",","':'",",","keyname","]",")",")","else",":","raise","MEMKeyError","(",")"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/dbentrust\/memobject.py#L55-L62"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/dbentrust\/memobject.py","language":"python","identifier":"MemObject.lock","parameters":"(self)","argument_list":"","return_statement":"return self._locked","docstring":"\u9501\u5b9a\u5bf9\u8c61","docstring_summary":"\u9501\u5b9a\u5bf9\u8c61","docstring_tokens":["\u9501\u5b9a\u5bf9\u8c61"],"function":"def lock(self):\n '''\u9501\u5b9a\u5bf9\u8c61\n '''\n print \"locked\"\n if not self.isLocked():\n key = self.produceKey('_lock')\n result = memclient.mclient.add(key,1,LOCK_TIMEOUT)\n if result:\n self._timestamp=time.time()\n self._locked = result\n return self._locked","function_tokens":["def","lock","(","self",")",":","print","\"locked\"","if","not","self",".","isLocked","(",")",":","key","=","self",".","produceKey","(","'_lock'",")","result","=","memclient",".","mclient",".","add","(","key",",","1",",","LOCK_TIMEOUT",")","if","result",":","self",".","_timestamp","=","time",".","time","(",")","self",".","_locked","=","result","return","self",".","_locked"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/dbentrust\/memobject.py#L72-L82"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/dbentrust\/memobject.py","language":"python","identifier":"MemObject.release","parameters":"(self)","argument_list":"","return_statement":"","docstring":"\u91ca\u653e\u9501","docstring_summary":"\u91ca\u653e\u9501","docstring_tokens":["\u91ca\u653e\u9501"],"function":"def release(self):\n '''\u91ca\u653e\u9501\n '''\n if self.isLocked():\n print \"release...\"\n key = self.produceKey('_lock')\n memclient.mclient.delete(key)\n self._locked = False","function_tokens":["def","release","(","self",")",":","if","self",".","isLocked","(",")",":","print","\"release...\"","key","=","self",".","produceKey","(","'_lock'",")","memclient",".","mclient",".","delete","(","key",")","self",".","_locked","=","False"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/dbentrust\/memobject.py#L84-L91"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/dbentrust\/memobject.py","language":"python","identifier":"MemObject.get","parameters":"(self,key)","argument_list":"","return_statement":"return memclient.mclient.get(key)","docstring":"\u83b7\u53d6\u5bf9\u8c61\u503c","docstring_summary":"\u83b7\u53d6\u5bf9\u8c61\u503c","docstring_tokens":["\u83b7\u53d6\u5bf9\u8c61\u503c"],"function":"def get(self,key):\n '''\u83b7\u53d6\u5bf9\u8c61\u503c\n '''\n if self._cas and not self.isLocked():\n for _ in xrange(10):\n if not self.lock():\n gevent.sleep(0.2)\n continue\n break\n else:\n return None\n key = self.produceKey(key)\n return memclient.mclient.get(key)","function_tokens":["def","get","(","self",",","key",")",":","if","self",".","_cas","and","not","self",".","isLocked","(",")",":","for","_","in","xrange","(","10",")",":","if","not","self",".","lock","(",")",":","gevent",".","sleep","(","0.2",")","continue","break","else",":","return","None","key","=","self",".","produceKey","(","key",")","return","memclient",".","mclient",".","get","(","key",")"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/dbentrust\/memobject.py#L93-L105"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/dbentrust\/memobject.py","language":"python","identifier":"MemObject.get_multi","parameters":"(self,keys)","argument_list":"","return_statement":"return newdict","docstring":"\u4e00\u6b21\u83b7\u53d6\u591a\u4e2akey\u7684\u503c\n @param keys: list(str) key\u7684\u5217\u8868","docstring_summary":"\u4e00\u6b21\u83b7\u53d6\u591a\u4e2akey\u7684\u503c","docstring_tokens":["\u4e00\u6b21\u83b7\u53d6\u591a\u4e2akey\u7684\u503c"],"function":"def get_multi(self,keys):\n '''\u4e00\u6b21\u83b7\u53d6\u591a\u4e2akey\u7684\u503c\n @param keys: list(str) key\u7684\u5217\u8868\n '''\n if self._cas and not self.isLocked():\n for _ in xrange(10):\n if not self.lock():\n gevent.sleep(0.2)\n continue\n break\n else:\n return None\n keynamelist = [self.produceKey(keyname) for keyname in keys]\n olddict = memclient.mclient.get_multi(keynamelist)\n newdict = dict(zip([keyname.split(':')[-1] for keyname in olddict.keys()],\n olddict.values()))\n return newdict","function_tokens":["def","get_multi","(","self",",","keys",")",":","if","self",".","_cas","and","not","self",".","isLocked","(",")",":","for","_","in","xrange","(","10",")",":","if","not","self",".","lock","(",")",":","gevent",".","sleep","(","0.2",")","continue","break","else",":","return","None","keynamelist","=","[","self",".","produceKey","(","keyname",")","for","keyname","in","keys","]","olddict","=","memclient",".","mclient",".","get_multi","(","keynamelist",")","newdict","=","dict","(","zip","(","[","keyname",".","split","(","':'",")","[","-","1","]","for","keyname","in","olddict",".","keys","(",")","]",",","olddict",".","values","(",")",")",")","return","newdict"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/dbentrust\/memobject.py#L107-L123"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/dbentrust\/memobject.py","language":"python","identifier":"MemObject.update","parameters":"(self,key,values)","argument_list":"","return_statement":"return memclient.mclient.set(key,values,time=self._timeout)","docstring":"\u4fee\u6539\u5bf9\u8c61\u7684\u503c","docstring_summary":"\u4fee\u6539\u5bf9\u8c61\u7684\u503c","docstring_tokens":["\u4fee\u6539\u5bf9\u8c61\u7684\u503c"],"function":"def update(self,key,values):\n '''\u4fee\u6539\u5bf9\u8c61\u7684\u503c\n '''\n if self._cas and not self.isLocked():\n for _ in xrange(10):\n if not self.lock():\n gevent.sleep(0.2)\n continue\n break\n else:\n return None\n key = self.produceKey(key)\n return memclient.mclient.set(key,values,time=self._timeout)","function_tokens":["def","update","(","self",",","key",",","values",")",":","if","self",".","_cas","and","not","self",".","isLocked","(",")",":","for","_","in","xrange","(","10",")",":","if","not","self",".","lock","(",")",":","gevent",".","sleep","(","0.2",")","continue","break","else",":","return","None","key","=","self",".","produceKey","(","key",")","return","memclient",".","mclient",".","set","(","key",",","values",",","time","=","self",".","_timeout",")"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/dbentrust\/memobject.py#L125-L137"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/dbentrust\/memobject.py","language":"python","identifier":"MemObject.update_multi","parameters":"(self,mapping)","argument_list":"","return_statement":"return memclient.mclient.set_multi(newmapping,time=self._timeout)","docstring":"\u540c\u65f6\u4fee\u6539\u591a\u4e2akey\u503c","docstring_summary":"\u540c\u65f6\u4fee\u6539\u591a\u4e2akey\u503c","docstring_tokens":["\u540c\u65f6\u4fee\u6539\u591a\u4e2akey\u503c"],"function":"def update_multi(self,mapping):\n '''\u540c\u65f6\u4fee\u6539\u591a\u4e2akey\u503c\n '''\n if self._cas and not self.isLocked():\n for _ in xrange(10):\n if not self.lock():\n gevent.sleep(0.2)\n continue\n break\n else:\n return None\n newmapping = dict(zip([self.produceKey(keyname) for keyname in mapping.keys()],\n mapping.values()))\n return memclient.mclient.set_multi(newmapping,time=self._timeout)","function_tokens":["def","update_multi","(","self",",","mapping",")",":","if","self",".","_cas","and","not","self",".","isLocked","(",")",":","for","_","in","xrange","(","10",")",":","if","not","self",".","lock","(",")",":","gevent",".","sleep","(","0.2",")","continue","break","else",":","return","None","newmapping","=","dict","(","zip","(","[","self",".","produceKey","(","keyname",")","for","keyname","in","mapping",".","keys","(",")","]",",","mapping",".","values","(",")",")",")","return","memclient",".","mclient",".","set_multi","(","newmapping",",","time","=","self",".","_timeout",")"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/dbentrust\/memobject.py#L139-L152"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/dbentrust\/memobject.py","language":"python","identifier":"MemObject.mdelete","parameters":"(self)","argument_list":"","return_statement":"","docstring":"\u5220\u9664memcache\u4e2d\u7684\u6570\u636e","docstring_summary":"\u5220\u9664memcache\u4e2d\u7684\u6570\u636e","docstring_tokens":["\u5220\u9664memcache\u4e2d\u7684\u6570\u636e"],"function":"def mdelete(self):\n '''\u5220\u9664memcache\u4e2d\u7684\u6570\u636e\n '''\n nowdict = dict(self.__dict__)\n keys = [keyname for keyname in nowdict.keys() if not keyname.startswith('_')]\n keys = [self.produceKey(key) for key in keys]\n memclient.mclient.delete_multi(keys)","function_tokens":["def","mdelete","(","self",")",":","nowdict","=","dict","(","self",".","__dict__",")","keys","=","[","keyname","for","keyname","in","nowdict",".","keys","(",")","if","not","keyname",".","startswith","(","'_'",")","]","keys","=","[","self",".","produceKey","(","key",")","for","key","in","keys","]","memclient",".","mclient",".","delete_multi","(","keys",")"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/dbentrust\/memobject.py#L154-L160"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/dbentrust\/memobject.py","language":"python","identifier":"MemObject.insert","parameters":"(self)","argument_list":"","return_statement":"","docstring":"\u63d2\u5165\u5bf9\u8c61\u8bb0\u5f55","docstring_summary":"\u63d2\u5165\u5bf9\u8c61\u8bb0\u5f55","docstring_tokens":["\u63d2\u5165\u5bf9\u8c61\u8bb0\u5f55"],"function":"def insert(self):\n '''\u63d2\u5165\u5bf9\u8c61\u8bb0\u5f55\n '''\n nowdict = dict(self.__dict__)\n newmapping = dict([(self.produceKey(keyname),nowdict[keyname]) for keyname in nowdict.keys() if not keyname.startswith('_')])\n memclient.mclient.set_multi(newmapping,time=self._timeout)","function_tokens":["def","insert","(","self",")",":","nowdict","=","dict","(","self",".","__dict__",")","newmapping","=","dict","(","[","(","self",".","produceKey","(","keyname",")",",","nowdict","[","keyname","]",")","for","keyname","in","nowdict",".","keys","(",")","if","not","keyname",".","startswith","(","'_'",")","]",")","memclient",".","mclient",".","set_multi","(","newmapping",",","time","=","self",".","_timeout",")"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/dbentrust\/memobject.py#L162-L167"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/dbentrust\/memobject.py","language":"python","identifier":"MemObject.__del__","parameters":"(self)","argument_list":"","return_statement":"","docstring":"\u5728\u5bf9\u8c61\u9500\u6bc1\u65f6\u91ca\u653e\u9501\uff0c\u907f\u514d\u5728\u83b7\u53d6memcache\u6570\u636e\u65f6\u6b7b\u9501","docstring_summary":"\u5728\u5bf9\u8c61\u9500\u6bc1\u65f6\u91ca\u653e\u9501\uff0c\u907f\u514d\u5728\u83b7\u53d6memcache\u6570\u636e\u65f6\u6b7b\u9501","docstring_tokens":["\u5728\u5bf9\u8c61\u9500\u6bc1\u65f6\u91ca\u653e\u9501\uff0c\u907f\u514d\u5728\u83b7\u53d6memcache\u6570\u636e\u65f6\u6b7b\u9501"],"function":"def __del__(self):\n \"\"\"\n \u5728\u5bf9\u8c61\u9500\u6bc1\u65f6\u91ca\u653e\u9501\uff0c\u907f\u514d\u5728\u83b7\u53d6memcache\u6570\u636e\u65f6\u6b7b\u9501\n \"\"\"\n try:\n if self.isLocked():\n self.release()\n except Exception as e:\n print e","function_tokens":["def","__del__","(","self",")",":","try",":","if","self",".","isLocked","(",")",":","self",".","release","(",")","except","Exception","as","e",":","print","e"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/dbentrust\/memobject.py#L169-L177"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/dbentrust\/memfields.py","language":"python","identifier":"MemFields.__init__","parameters":"(self, value=None, cache=True,timeout=CACHE_TIMEOUT)","argument_list":"","return_statement":"","docstring":"@param name: str\u3000\u5b57\u6bb5\u7684\u540d\u79f0\n @param cache: bool \u662f\u5426\u672c\u5730\u7f13\u5b58\u83b7\u53d6\u5230\u7684\u503c","docstring_summary":"","docstring_tokens":[],"function":"def __init__(self, value=None, cache=True,timeout=CACHE_TIMEOUT):\n \"\"\"\n @param name: str\u3000\u5b57\u6bb5\u7684\u540d\u79f0\n @param cache: bool \u662f\u5426\u672c\u5730\u7f13\u5b58\u83b7\u53d6\u5230\u7684\u503c\n \"\"\"\n self.name = \"\"\n self.value = value\n self.cache = cache\n self.timeout = timeout","function_tokens":["def","__init__","(","self",",","value","=","None",",","cache","=","True",",","timeout","=","CACHE_TIMEOUT",")",":","self",".","name","=","\"\"","self",".","value","=","value","self",".","cache","=","cache","self",".","timeout","=","timeout"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/dbentrust\/memfields.py#L25-L33"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/dbentrust\/memfields.py","language":"python","identifier":"MemFields.getValue","parameters":"(self)","argument_list":"","return_statement":"","docstring":"\u83b7\u53d6name\u5bf9\u5e94\u7684\u503c\n \u5f53cache\u4e3aTrue\u65f6\uff0c\u5e76\u4e14value\u503c\u5b58\u5728\u65f6\uff0c\u4e0d\u518d\u91cd\u65b0\u4ecememcache\u4e2d\u83b7\u53d6\u503c","docstring_summary":"\u83b7\u53d6name\u5bf9\u5e94\u7684\u503c\n \u5f53cache\u4e3aTrue\u65f6\uff0c\u5e76\u4e14value\u503c\u5b58\u5728\u65f6\uff0c\u4e0d\u518d\u91cd\u65b0\u4ecememcache\u4e2d\u83b7\u53d6\u503c","docstring_tokens":["\u83b7\u53d6name\u5bf9\u5e94\u7684\u503c","\u5f53cache\u4e3aTrue\u65f6\uff0c\u5e76\u4e14value\u503c\u5b58\u5728\u65f6\uff0c\u4e0d\u518d\u91cd\u65b0\u4ecememcache\u4e2d\u83b7\u53d6\u503c"],"function":"def getValue(self):\n \"\"\"\n \u83b7\u53d6name\u5bf9\u5e94\u7684\u503c\n \u5f53cache\u4e3aTrue\u65f6\uff0c\u5e76\u4e14value\u503c\u5b58\u5728\u65f6\uff0c\u4e0d\u518d\u91cd\u65b0\u4ecememcache\u4e2d\u83b7\u53d6\u503c\n \"\"\"\n if self.cache and self.value:\n return self.value\n else:\n self.refreshValue()\n return self.value","function_tokens":["def","getValue","(","self",")",":","if","self",".","cache","and","self",".","value",":","return","self",".","value","else",":","self",".","refreshValue","(",")","return","self",".","value"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/dbentrust\/memfields.py#L35-L44"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/dbentrust\/memfields.py","language":"python","identifier":"MemFields.refreshValue","parameters":"(self)","argument_list":"","return_statement":"return self.value","docstring":"\u91cd\u65b0\u4ecememcached\u4e2d\u83b7\u53d6\u503c","docstring_summary":"\u91cd\u65b0\u4ecememcached\u4e2d\u83b7\u53d6\u503c","docstring_tokens":["\u91cd\u65b0\u4ecememcached\u4e2d\u83b7\u53d6\u503c"],"function":"def refreshValue(self):\n \"\"\"\n \u91cd\u65b0\u4ecememcached\u4e2d\u83b7\u53d6\u503c\n \"\"\"\n self.value = memclient.mclient.get(self.name)\n return self.value","function_tokens":["def","refreshValue","(","self",")",":","self",".","value","=","memclient",".","mclient",".","get","(","self",".","name",")","return","self",".","value"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/dbentrust\/memfields.py#L46-L51"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/dbentrust\/memfields.py","language":"python","identifier":"MemFields.setValue","parameters":"(self,value)","argument_list":"","return_statement":"return result","docstring":"\u4fee\u6539\u5bf9\u5e94\u7684\u503c","docstring_summary":"\u4fee\u6539\u5bf9\u5e94\u7684\u503c","docstring_tokens":["\u4fee\u6539\u5bf9\u5e94\u7684\u503c"],"function":"def setValue(self,value):\n \"\"\"\n \u4fee\u6539\u5bf9\u5e94\u7684\u503c\n \"\"\"\n self.value = value\n result = memclient.mclient.set(self.name,value,time=self.timeout)\n return result","function_tokens":["def","setValue","(","self",",","value",")",":","self",".","value","=","value","result","=","memclient",".","mclient",".","set","(","self",".","name",",","value",",","time","=","self",".","timeout",")","return","result"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/dbentrust\/memfields.py#L53-L59"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/dbentrust\/memfields.py","language":"python","identifier":"MemObj.__init__","parameters":"(self, name,**kw)","argument_list":"","return_statement":"","docstring":"@param name: str \u8868\u793a\u5bf9\u8c61\u7684\u540d\u79f0","docstring_summary":"","docstring_tokens":[],"function":"def __init__(self, name,**kw):\n \"\"\"\n @param name: str \u8868\u793a\u5bf9\u8c61\u7684\u540d\u79f0\n \n \"\"\"\n self._name = name\n self._locked = False\n self._timestamp = 0\n self._cas = kw.get(\"cas\",False)\n self._cache = kw.get(\"cache\",True)\n self._timeout = kw.get(\"timeout\",CACHE_TIMEOUT)\n if self._cas:\n self.lock()","function_tokens":["def","__init__","(","self",",","name",",","*","*","kw",")",":","self",".","_name","=","name","self",".","_locked","=","False","self",".","_timestamp","=","0","self",".","_cas","=","kw",".","get","(","\"cas\"",",","False",")","self",".","_cache","=","kw",".","get","(","\"cache\"",",","True",")","self",".","_timeout","=","kw",".","get","(","\"timeout\"",",","CACHE_TIMEOUT",")","if","self",".","_cas",":","self",".","lock","(",")"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/dbentrust\/memfields.py#L63-L75"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/dbentrust\/memfields.py","language":"python","identifier":"MemObj.initFields","parameters":"(self)","argument_list":"","return_statement":"","docstring":"\u521d\u59cb\u5316\u5b57\u6bb5","docstring_summary":"\u521d\u59cb\u5316\u5b57\u6bb5","docstring_tokens":["\u521d\u59cb\u5316\u5b57\u6bb5"],"function":"def initFields(self):\n \"\"\"\n \u521d\u59cb\u5316\u5b57\u6bb5\n \"\"\"\n nowdict = dict(self.__dict__)\n for item_key,item_value in nowdict.items():\n if isinstance(item_value, MemFields):\n item_value.name = self.produceKey(item_key)\n item_value.timeout = self._timeout\n item_value.cache = self._cache","function_tokens":["def","initFields","(","self",")",":","nowdict","=","dict","(","self",".","__dict__",")","for","item_key",",","item_value","in","nowdict",".","items","(",")",":","if","isinstance","(","item_value",",","MemFields",")",":","item_value",".","name","=","self",".","produceKey","(","item_key",")","item_value",".","timeout","=","self",".","_timeout","item_value",".","cache","=","self",".","_cache"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/dbentrust\/memfields.py#L77-L86"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/dbentrust\/memfields.py","language":"python","identifier":"MemObj.produceKey","parameters":"(self,keyname)","argument_list":"","return_statement":"","docstring":"\u91cd\u65b0\u751f\u6210key","docstring_summary":"\u91cd\u65b0\u751f\u6210key","docstring_tokens":["\u91cd\u65b0\u751f\u6210key"],"function":"def produceKey(self,keyname):\n '''\n \u91cd\u65b0\u751f\u6210key\n '''\n if isinstance(keyname, basestring):\n return ''.join([self._name,':',keyname])\n else:\n raise MEMKeyError()","function_tokens":["def","produceKey","(","self",",","keyname",")",":","if","isinstance","(","keyname",",","basestring",")",":","return","''",".","join","(","[","self",".","_name",",","':'",",","keyname","]",")","else",":","raise","MEMKeyError","(",")"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/dbentrust\/memfields.py#L88-L95"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/dbentrust\/memfields.py","language":"python","identifier":"MemObj.lock","parameters":"(self)","argument_list":"","return_statement":"return self._locked","docstring":"\u68c0\u6d4b\u5bf9\u8c61\u662f\u5426\u88ab\u9501\u5b9a","docstring_summary":"\u68c0\u6d4b\u5bf9\u8c61\u662f\u5426\u88ab\u9501\u5b9a","docstring_tokens":["\u68c0\u6d4b\u5bf9\u8c61\u662f\u5426\u88ab\u9501\u5b9a"],"function":"def lock(self):\n '''\n \u68c0\u6d4b\u5bf9\u8c61\u662f\u5426\u88ab\u9501\u5b9a\n '''\n print \"lock\"\n if not self.isLocked():\n key = self.produceKey('_lock')\n result = memclient.mclient.add(key,1,LOCK_TIMEOUT)\n if result:\n self._timestamp=time.time()\n self._locked = result\n return self._locked","function_tokens":["def","lock","(","self",")",":","print","\"lock\"","if","not","self",".","isLocked","(",")",":","key","=","self",".","produceKey","(","'_lock'",")","result","=","memclient",".","mclient",".","add","(","key",",","1",",","LOCK_TIMEOUT",")","if","result",":","self",".","_timestamp","=","time",".","time","(",")","self",".","_locked","=","result","return","self",".","_locked"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/dbentrust\/memfields.py#L105-L116"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/dbentrust\/memfields.py","language":"python","identifier":"MemObj.release","parameters":"(self)","argument_list":"","return_statement":"","docstring":"\u91ca\u653e\u9501","docstring_summary":"\u91ca\u653e\u9501","docstring_tokens":["\u91ca\u653e\u9501"],"function":"def release(self):\n '''\u91ca\u653e\u9501\n '''\n if self.isLocked():\n key = self.produceKey('_lock')\n memclient.mclient.delete(key)\n self._locked = False","function_tokens":["def","release","(","self",")",":","if","self",".","isLocked","(",")",":","key","=","self",".","produceKey","(","'_lock'",")","memclient",".","mclient",".","delete","(","key",")","self",".","_locked","=","False"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/dbentrust\/memfields.py#L118-L124"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/dbentrust\/memfields.py","language":"python","identifier":"MemObj.insert","parameters":"(self)","argument_list":"","return_statement":"","docstring":"\u63d2\u5165\u5bf9\u8c61\u8bb0\u5f55","docstring_summary":"\u63d2\u5165\u5bf9\u8c61\u8bb0\u5f55","docstring_tokens":["\u63d2\u5165\u5bf9\u8c61\u8bb0\u5f55"],"function":"def insert(self):\n '''\n \u63d2\u5165\u5bf9\u8c61\u8bb0\u5f55\n '''\n nowdict = dict(self.__dict__)\n newmapping = dict([(self.produceKey(item_key), item_value.value) for item_key,item_value in\\\n nowdict.items() if isinstance(item_value, MemFields) and item_value.value])\n memclient.mclient.set_multi(newmapping,time=self._timeout)","function_tokens":["def","insert","(","self",")",":","nowdict","=","dict","(","self",".","__dict__",")","newmapping","=","dict","(","[","(","self",".","produceKey","(","item_key",")",",","item_value",".","value",")","for","item_key",",","item_value","in","nowdict",".","items","(",")","if","isinstance","(","item_value",",","MemFields",")","and","item_value",".","value","]",")","memclient",".","mclient",".","set_multi","(","newmapping",",","time","=","self",".","_timeout",")"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/dbentrust\/memfields.py#L126-L133"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/dbentrust\/memfields.py","language":"python","identifier":"MemObj.mdelete","parameters":"(self)","argument_list":"","return_statement":"return memclient.mclient.delete_multi(keys)","docstring":"\u5220\u9664\u7f13\u5b58\u4e2d\u7684\u5bf9\u8c61","docstring_summary":"\u5220\u9664\u7f13\u5b58\u4e2d\u7684\u5bf9\u8c61","docstring_tokens":["\u5220\u9664\u7f13\u5b58\u4e2d\u7684\u5bf9\u8c61"],"function":"def mdelete(self):\n \"\"\"\n \u5220\u9664\u7f13\u5b58\u4e2d\u7684\u5bf9\u8c61\n \"\"\"\n nowdict = dict(self.__dict__)\n keys = [self.produceKey(item_key) for item_key,item_value in\\\n nowdict.items() if isinstance(item_value, MemFields)]\n return memclient.mclient.delete_multi(keys)","function_tokens":["def","mdelete","(","self",")",":","nowdict","=","dict","(","self",".","__dict__",")","keys","=","[","self",".","produceKey","(","item_key",")","for","item_key",",","item_value","in","nowdict",".","items","(",")","if","isinstance","(","item_value",",","MemFields",")","]","return","memclient",".","mclient",".","delete_multi","(","keys",")"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/dbentrust\/memfields.py#L135-L142"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/dbentrust\/memfields.py","language":"python","identifier":"MemObj.__getattribute__","parameters":"(self,attr)","argument_list":"","return_statement":"return value","docstring":"\u5c01\u88c5\u4e86\u83b7\u53d6\u5b57\u6bb5\u503c\u7684\u8fc7\u7a0b","docstring_summary":"\u5c01\u88c5\u4e86\u83b7\u53d6\u5b57\u6bb5\u503c\u7684\u8fc7\u7a0b","docstring_tokens":["\u5c01\u88c5\u4e86\u83b7\u53d6\u5b57\u6bb5\u503c\u7684\u8fc7\u7a0b"],"function":"def __getattribute__(self,attr):\n \"\"\"\n \u5c01\u88c5\u4e86\u83b7\u53d6\u5b57\u6bb5\u503c\u7684\u8fc7\u7a0b\n \"\"\"\n value = object.__getattribute__(self,attr)\n if isinstance(value, MemFields):\n print 'locked',self.isLocked()\n if self._cas and not self.isLocked():\n for _ in xrange(10):\n if not self.lock():\n time.sleep(0.2)\n continue\n break\n else:\n return None\n return value.getValue()\n return value","function_tokens":["def","__getattribute__","(","self",",","attr",")",":","value","=","object",".","__getattribute__","(","self",",","attr",")","if","isinstance","(","value",",","MemFields",")",":","print","'locked'",",","self",".","isLocked","(",")","if","self",".","_cas","and","not","self",".","isLocked","(",")",":","for","_","in","xrange","(","10",")",":","if","not","self",".","lock","(",")",":","time",".","sleep","(","0.2",")","continue","break","else",":","return","None","return","value",".","getValue","(",")","return","value"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/dbentrust\/memfields.py#L144-L160"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/dbentrust\/memfields.py","language":"python","identifier":"MemObj.__del__","parameters":"(self)","argument_list":"","return_statement":"","docstring":"\u5728\u5bf9\u8c61\u9500\u6bc1\u65f6\u91ca\u653e\u9501\uff0c\u907f\u514d\u5728\u83b7\u53d6memcache\u6570\u636e\u65f6\u6b7b\u9501","docstring_summary":"\u5728\u5bf9\u8c61\u9500\u6bc1\u65f6\u91ca\u653e\u9501\uff0c\u907f\u514d\u5728\u83b7\u53d6memcache\u6570\u636e\u65f6\u6b7b\u9501","docstring_tokens":["\u5728\u5bf9\u8c61\u9500\u6bc1\u65f6\u91ca\u653e\u9501\uff0c\u907f\u514d\u5728\u83b7\u53d6memcache\u6570\u636e\u65f6\u6b7b\u9501"],"function":"def __del__(self):\n \"\"\"\n \u5728\u5bf9\u8c61\u9500\u6bc1\u65f6\u91ca\u653e\u9501\uff0c\u907f\u514d\u5728\u83b7\u53d6memcache\u6570\u636e\u65f6\u6b7b\u9501\n \"\"\"\n try:\n if self.isLocked():\n self.release()\n except Exception as e:\n print e","function_tokens":["def","__del__","(","self",")",":","try",":","if","self",".","isLocked","(",")",":","self",".","release","(",")","except","Exception","as","e",":","print","e"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/dbentrust\/memfields.py#L177-L185"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/dbentrust\/madminanager.py","language":"python","identifier":"MAdminManager.__init__","parameters":"(self)","argument_list":"","return_statement":"","docstring":"\u521d\u59cb\u5316\u6240\u6709\u7ba1\u7406\u7684\u7684madmin\u7684\u96c6\u5408\uff0c\u653e\u5728self.admins\u4e2d","docstring_summary":"\u521d\u59cb\u5316\u6240\u6709\u7ba1\u7406\u7684\u7684madmin\u7684\u96c6\u5408\uff0c\u653e\u5728self.admins\u4e2d","docstring_tokens":["\u521d\u59cb\u5316\u6240\u6709\u7ba1\u7406\u7684\u7684madmin\u7684\u96c6\u5408\uff0c\u653e\u5728self",".","admins\u4e2d"],"function":"def __init__(self):\n \"\"\"\u521d\u59cb\u5316\u6240\u6709\u7ba1\u7406\u7684\u7684madmin\u7684\u96c6\u5408\uff0c\u653e\u5728self.admins\u4e2d\n \"\"\"\n self.isStart = False\n self.to_db_port = None","function_tokens":["def","__init__","(","self",")",":","self",".","isStart","=","False","self",".","to_db_port","=","None"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/dbentrust\/madminanager.py#L21-L25"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/dbentrust\/madminanager.py","language":"python","identifier":"MAdminManager.registe","parameters":"(self,admin)","argument_list":"","return_statement":"","docstring":"\u6ce8\u518c\u4e00\u4e2amadmin\u5bf9\u8c61\u5230\u7ba1\u7406\u4e2d.\n >>> madmin = MAdmin('tb_registe','characterId',incrkey='id')\n >>> MAdminManager().registe(madmin)","docstring_summary":"\u6ce8\u518c\u4e00\u4e2amadmin\u5bf9\u8c61\u5230\u7ba1\u7406\u4e2d.\n >>> madmin = MAdmin('tb_registe','characterId',incrkey='id')\n >>> MAdminManager().registe(madmin)","docstring_tokens":["\u6ce8\u518c\u4e00\u4e2amadmin\u5bf9\u8c61\u5230\u7ba1\u7406\u4e2d",".",">>>","madmin","=","MAdmin","(","tb_registe","characterId","incrkey","=","id",")",">>>","MAdminManager","()",".","registe","(","madmin",")"],"function":"def registe(self,admin):\n \"\"\"\u6ce8\u518c\u4e00\u4e2amadmin\u5bf9\u8c61\u5230\u7ba1\u7406\u4e2d.\n >>> madmin = MAdmin('tb_registe','characterId',incrkey='id')\n >>> MAdminManager().registe(madmin)\n \"\"\"\n pass","function_tokens":["def","registe","(","self",",","admin",")",":","pass"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/dbentrust\/madminanager.py#L27-L32"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/dbentrust\/madminanager.py","language":"python","identifier":"MAdminManager._run","parameters":"(self)","argument_list":"","return_statement":"","docstring":"\u6267\u884c\u534f\u8bae","docstring_summary":"\u6267\u884c\u534f\u8bae","docstring_tokens":["\u6267\u884c\u534f\u8bae"],"function":"def _run(self):\n \"\"\"\u6267\u884c\u534f\u8bae\n \"\"\"\n while True:\n# msg = self.sock.recv()\n try:\n pyobj = self.sock.recv_pyobj()\n tablename,sql = pyobj\n excuteSQL(tablename, sql)\n except Exception,e:\n log.err(_stuff=e,_why=traceback.format_exc())","function_tokens":["def","_run","(","self",")",":","while","True",":","# msg = self.sock.recv()","try",":","pyobj","=","self",".","sock",".","recv_pyobj","(",")","tablename",",","sql","=","pyobj","excuteSQL","(","tablename",",","sql",")","except","Exception",",","e",":","log",".","err","(","_stuff","=","e",",","_why","=","traceback",".","format_exc","(",")",")"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/dbentrust\/madminanager.py#L35-L45"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/dbentrust\/madminanager.py","language":"python","identifier":"MAdminManager.checkAdmins","parameters":"(self,port=M2DB_PORT)","argument_list":"","return_statement":"","docstring":"\u904d\u5386\u6240\u6709\u7684madmin\uff0c\u4e0e\u6570\u636e\u5e93\u8fdb\u884c\u540c\u6b65\u3002\n\n >>>MAdminManager().checkAdmins(port=M2DB_PORT)","docstring_summary":"\u904d\u5386\u6240\u6709\u7684madmin\uff0c\u4e0e\u6570\u636e\u5e93\u8fdb\u884c\u540c\u6b65\u3002","docstring_tokens":["\u904d\u5386\u6240\u6709\u7684madmin\uff0c\u4e0e\u6570\u636e\u5e93\u8fdb\u884c\u540c\u6b65\u3002"],"function":"def checkAdmins(self,port=M2DB_PORT):\n \"\"\"\u904d\u5386\u6240\u6709\u7684madmin\uff0c\u4e0e\u6570\u636e\u5e93\u8fdb\u884c\u540c\u6b65\u3002\n\n >>>MAdminManager().checkAdmins(port=M2DB_PORT)\n \"\"\"\n if self.isStart:\n return\n self.isStart=True\n context = zmq.Context()\n self.sock = context.socket(zmq.SUB)\n \n if port==M2DB_PORT:\n port = ToDBAddress().m2db_port\n address = 'tcp:\/\/*:%s'%port\n self.sock.bind(address)\n self.sock.setsockopt(zmq.SUBSCRIBE, \"\")\n gevent.spawn(self._run)","function_tokens":["def","checkAdmins","(","self",",","port","=","M2DB_PORT",")",":","if","self",".","isStart",":","return","self",".","isStart","=","True","context","=","zmq",".","Context","(",")","self",".","sock","=","context",".","socket","(","zmq",".","SUB",")","if","port","==","M2DB_PORT",":","port","=","ToDBAddress","(",")",".","m2db_port","address","=","'tcp:\/\/*:%s'","%","port","self",".","sock",".","bind","(","address",")","self",".","sock",".","setsockopt","(","zmq",".","SUBSCRIBE",",","\"\"",")","gevent",".","spawn","(","self",".","_run",")"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/dbentrust\/madminanager.py#L47-L63"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/dbentrust\/memclient.py","language":"python","identifier":"memcached_connect","parameters":"(servers,mem_lib=\"default\",dead_retry=_DEAD_RETRY,**kw)","argument_list":"","return_statement":"","docstring":"memcached connect\n @param servers: (list) memcached\u7684\u5730\u5740\uff0c\u4f8b\u5982[\"127.0.0.1:11211\",\"127.0.0.1:11222\",]\n @param mem_lib: \u9009\u62e9\u6027\u7684\u4f7f\u7528memcached\u5e93,\u9ed8\u8ba4\u7684\u4f7f\u7528python-memcached\n {'python-memcached':\"memcache\",\"python-ultramemcache\":\"ultramemcache\",\"default\":\"memcache\"}","docstring_summary":"memcached connect","docstring_tokens":["memcached","connect"],"function":"def memcached_connect(servers,mem_lib=\"default\",dead_retry=_DEAD_RETRY,**kw):\n \"\"\"\n memcached connect\n @param servers: (list) memcached\u7684\u5730\u5740\uff0c\u4f8b\u5982[\"127.0.0.1:11211\",\"127.0.0.1:11222\",]\n @param mem_lib: \u9009\u62e9\u6027\u7684\u4f7f\u7528memcached\u5e93,\u9ed8\u8ba4\u7684\u4f7f\u7528python-memcached\n {'python-memcached':\"memcache\",\"python-ultramemcache\":\"ultramemcache\",\"default\":\"memcache\"}\n \"\"\"\n global mclient\n memcache = __import__(MEMCS.get(mem_lib))\n mclient = memcache.Client(servers,dead_retry=dead_retry,**kw)\n server,key = mclient._get_server(\"ping\")\n if not server or not key:\n raise MemConnError()","function_tokens":["def","memcached_connect","(","servers",",","mem_lib","=","\"default\"",",","dead_retry","=","_DEAD_RETRY",",","*","*","kw",")",":","global","mclient","memcache","=","__import__","(","MEMCS",".","get","(","mem_lib",")",")","mclient","=","memcache",".","Client","(","servers",",","dead_retry","=","dead_retry",",","*","*","kw",")","server",",","key","=","mclient",".","_get_server","(","\"ping\"",")","if","not","server","or","not","key",":","raise","MemConnError","(",")"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/dbentrust\/memclient.py#L23-L35"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/dbentrust\/memmodel.py","language":"python","identifier":"MemModel.syncDB","parameters":"(self)","argument_list":"","return_statement":"return result","docstring":"\u540c\u6b65\u5230\u6570\u636e\u5e93","docstring_summary":"\u540c\u6b65\u5230\u6570\u636e\u5e93","docstring_tokens":["\u540c\u6b65\u5230\u6570\u636e\u5e93"],"function":"def syncDB(self):\n \"\"\"\u540c\u6b65\u5230\u6570\u636e\u5e93\n \"\"\"\n tablename = self._name.split(':')[0]\n data_item = self.__dict__.get(\"data\")\n data_item.setValue(data_item.value)\n if self._cas:\n self.release()\n props = self.data\n pk = self.pk\n prere = {pk:props.get(pk)}\n result = util.UpdateWithDict(tablename, props, prere)\n return result","function_tokens":["def","syncDB","(","self",")",":","tablename","=","self",".","_name",".","split","(","':'",")","[","0","]","data_item","=","self",".","__dict__",".","get","(","\"data\"",")","data_item",".","setValue","(","data_item",".","value",")","if","self",".","_cas",":","self",".","release","(",")","props","=","self",".","data","pk","=","self",".","pk","prere","=","{","pk",":","props",".","get","(","pk",")","}","result","=","util",".","UpdateWithDict","(","tablename",",","props",",","prere",")","return","result"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/dbentrust\/memmodel.py#L56-L68"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/dbentrust\/memmodel.py","language":"python","identifier":"MemAdmin.load","parameters":"(self)","argument_list":"","return_statement":"","docstring":"\u8bfb\u53d6\u6570\u636e\u5230\u6570\u636e\u5e93\u4e2d","docstring_summary":"\u8bfb\u53d6\u6570\u636e\u5230\u6570\u636e\u5e93\u4e2d","docstring_tokens":["\u8bfb\u53d6\u6570\u636e\u5230\u6570\u636e\u5e93\u4e2d"],"function":"def load(self):\n '''\u8bfb\u53d6\u6570\u636e\u5230\u6570\u636e\u5e93\u4e2d\n '''\n mmname = self.name\n recordlist = util.ReadDataFromDB(mmname)\n for record in recordlist:\n pk = record[self.pk]\n mm = MemModel(self.name+':%s'%pk,self.pk,data=record,**self.kw)\n mm.insert()","function_tokens":["def","load","(","self",")",":","mmname","=","self",".","name","recordlist","=","util",".","ReadDataFromDB","(","mmname",")","for","record","in","recordlist",":","pk","=","record","[","self",".","pk","]","mm","=","MemModel","(","self",".","name","+","':%s'","%","pk",",","self",".","pk",",","data","=","record",",","*","*","self",".","kw",")","mm",".","insert","(",")"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/dbentrust\/memmodel.py#L90-L98"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/dbentrust\/memmodel.py","language":"python","identifier":"MemAdmin.new","parameters":"(self,data)","argument_list":"","return_statement":"return mm","docstring":"\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u5bf9\u8c61","docstring_summary":"\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u5bf9\u8c61","docstring_tokens":["\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u5bf9\u8c61"],"function":"def new(self,data):\n \"\"\"\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u5bf9\u8c61\n \"\"\"\n incrkey = self.incrkey\n tablename = self.name\n if incrkey:\n result = util.InsertIntoDBAndReturnID(tablename, data)\n data[incrkey] = result\n pk = data.get(self.pk)\n if pk is None:\n raise PKValueError(data)\n mm = MemModel(self.name+':%s'%pk,self.pk,data=data,**self.kw)\n setattr(mm,incrkey,pk)\n else:\n pk = data.get(self.pk)\n result = util.InsertIntoDB(tablename, data)\n if not result:\n raise util.SQLError()\n mm = MemModel(self.name+':%s'%pk,self.pk,data=data,**self.kw)\n mm.insert()\n return mm","function_tokens":["def","new","(","self",",","data",")",":","incrkey","=","self",".","incrkey","tablename","=","self",".","name","if","incrkey",":","result","=","util",".","InsertIntoDBAndReturnID","(","tablename",",","data",")","data","[","incrkey","]","=","result","pk","=","data",".","get","(","self",".","pk",")","if","pk","is","None",":","raise","PKValueError","(","data",")","mm","=","MemModel","(","self",".","name","+","':%s'","%","pk",",","self",".","pk",",","data","=","data",",","*","*","self",".","kw",")","setattr","(","mm",",","incrkey",",","pk",")","else",":","pk","=","data",".","get","(","self",".","pk",")","result","=","util",".","InsertIntoDB","(","tablename",",","data",")","if","not","result",":","raise","util",".","SQLError","(",")","mm","=","MemModel","(","self",".","name","+","':%s'","%","pk",",","self",".","pk",",","data","=","data",",","*","*","self",".","kw",")","mm",".","insert","(",")","return","mm"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/dbentrust\/memmodel.py#L100-L120"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/dbentrust\/memmodel.py","language":"python","identifier":"MemAdmin.getObj","parameters":"(self,pk)","argument_list":"","return_statement":"","docstring":"\u6839\u636e\u4e3b\u952e\uff0c\u53ef\u4ee5\u83b7\u5f97mmode\u5bf9\u8c61\u7684\u5b9e\u4f8b.","docstring_summary":"\u6839\u636e\u4e3b\u952e\uff0c\u53ef\u4ee5\u83b7\u5f97mmode\u5bf9\u8c61\u7684\u5b9e\u4f8b.","docstring_tokens":["\u6839\u636e\u4e3b\u952e\uff0c\u53ef\u4ee5\u83b7\u5f97mmode\u5bf9\u8c61\u7684\u5b9e\u4f8b","."],"function":"def getObj(self,pk):\n '''\u6839\u636e\u4e3b\u952e\uff0c\u53ef\u4ee5\u83b7\u5f97mmode\u5bf9\u8c61\u7684\u5b9e\u4f8b.\n '''\n mm = MemModel(self.name+':%s'%pk,self.pk,**self.kw)\n if mm.data:\n return mm\n else:\n return None","function_tokens":["def","getObj","(","self",",","pk",")",":","mm","=","MemModel","(","self",".","name","+","':%s'","%","pk",",","self",".","pk",",","*","*","self",".","kw",")","if","mm",".","data",":","return","mm","else",":","return","None"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/dbentrust\/memmodel.py#L122-L129"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/dbentrust\/memmodel.py","language":"python","identifier":"MemAdmin.getObjList","parameters":"(self,pklist)","argument_list":"","return_statement":"return objlist","docstring":"\u6839\u636e\u4e3b\u952e\u5217\u8868\u83b7\u53d6mmode\u5bf9\u8c61\u7684\u5217\u8868.\\n\n >>> m = madmin.getObjList([1,2,3,4,5])","docstring_summary":"\u6839\u636e\u4e3b\u952e\u5217\u8868\u83b7\u53d6mmode\u5bf9\u8c61\u7684\u5217\u8868.\\n\n >>> m = madmin.getObjList([1,2,3,4,5])","docstring_tokens":["\u6839\u636e\u4e3b\u952e\u5217\u8868\u83b7\u53d6mmode\u5bf9\u8c61\u7684\u5217\u8868",".","\\","n",">>>","m","=","madmin",".","getObjList","(","[","1","2","3","4","5","]",")"],"function":"def getObjList(self,pklist):\n '''\u6839\u636e\u4e3b\u952e\u5217\u8868\u83b7\u53d6mmode\u5bf9\u8c61\u7684\u5217\u8868.\\n\n >>> m = madmin.getObjList([1,2,3,4,5])\n '''\n objlist = []\n for pk in pklist:\n mm = MemModel(self.name+':%s'%pk,self.pk,**self.kw)\n objlist.append(mm)\n return objlist","function_tokens":["def","getObjList","(","self",",","pklist",")",":","objlist","=","[","]","for","pk","in","pklist",":","mm","=","MemModel","(","self",".","name","+","':%s'","%","pk",",","self",".","pk",",","*","*","self",".","kw",")","objlist",".","append","(","mm",")","return","objlist"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/dbentrust\/memmodel.py#L137-L145"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/master\/rootapp.py","language":"python","identifier":"_doChildConnect","parameters":"(name,transport)","argument_list":"","return_statement":"","docstring":"\u5f53server\u8282\u70b9\u8fde\u63a5\u5230master\u7684\u5904\u7406","docstring_summary":"\u5f53server\u8282\u70b9\u8fde\u63a5\u5230master\u7684\u5904\u7406","docstring_tokens":["\u5f53server\u8282\u70b9\u8fde\u63a5\u5230master\u7684\u5904\u7406"],"function":"def _doChildConnect(name,transport):\n \"\"\"\u5f53server\u8282\u70b9\u8fde\u63a5\u5230master\u7684\u5904\u7406\n \"\"\"\n server_config = GlobalObject().json_config.get('servers',{}).get(name,{})\n remoteport = server_config.get('remoteport',[])\n child_host = transport.transport.address[0]\n root_list = [rootport.get('rootname') for rootport in remoteport]\n GlobalObject().remote_map[name] = {\"host\":child_host,\"root_list\":root_list}\n #\u901a\u77e5\u6709\u9700\u8981\u8fde\u7684node\u8282\u70b9\u8fde\u63a5\u5230\u6b64root\u8282\u70b9\n for servername,remote_list in GlobalObject().remote_map.items():\n remote_host = remote_list.get(\"host\",\"\")\n remote_name_host = remote_list.get(\"root_list\",\"\")\n if name in remote_name_host:\n GlobalObject().root.callChild(servername,\"remote_connect\",name,remote_host)\n #\u67e5\u770b\u5f53\u524d\u662f\u5426\u6709\u53ef\u4f9b\u8fde\u63a5\u7684root\u8282\u70b9\n master_node_list = GlobalObject().remote_map.keys()\n for root_name in root_list:\n if root_name in master_node_list:\n root_host = GlobalObject().remote_map[root_name]['host']\n GlobalObject().root.callChild(name,\"remote_connect\",root_name,root_host)","function_tokens":["def","_doChildConnect","(","name",",","transport",")",":","server_config","=","GlobalObject","(",")",".","json_config",".","get","(","'servers'",",","{","}",")",".","get","(","name",",","{","}",")","remoteport","=","server_config",".","get","(","'remoteport'",",","[","]",")","child_host","=","transport",".","transport",".","address","[","0","]","root_list","=","[","rootport",".","get","(","'rootname'",")","for","rootport","in","remoteport","]","GlobalObject","(",")",".","remote_map","[","name","]","=","{","\"host\"",":","child_host",",","\"root_list\"",":","root_list","}","#\u901a\u77e5\u6709\u9700\u8981\u8fde\u7684node\u8282\u70b9\u8fde\u63a5\u5230\u6b64root\u8282\u70b9","for","servername",",","remote_list","in","GlobalObject","(",")",".","remote_map",".","items","(",")",":","remote_host","=","remote_list",".","get","(","\"host\"",",","\"\"",")","remote_name_host","=","remote_list",".","get","(","\"root_list\"",",","\"\"",")","if","name","in","remote_name_host",":","GlobalObject","(",")",".","root",".","callChild","(","servername",",","\"remote_connect\"",",","name",",","remote_host",")","#\u67e5\u770b\u5f53\u524d\u662f\u5426\u6709\u53ef\u4f9b\u8fde\u63a5\u7684root\u8282\u70b9","master_node_list","=","GlobalObject","(",")",".","remote_map",".","keys","(",")","for","root_name","in","root_list",":","if","root_name","in","master_node_list",":","root_host","=","GlobalObject","(",")",".","remote_map","[","root_name","]","[","'host'","]","GlobalObject","(",")",".","root",".","callChild","(","name",",","\"remote_connect\"",",","root_name",",","root_host",")"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/master\/rootapp.py#L11-L30"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/master\/webapp.py","language":"python","identifier":"stop","parameters":"()","argument_list":"","return_statement":"return \"stop\"","docstring":"stop service","docstring_summary":"stop service","docstring_tokens":["stop","service"],"function":"def stop():\n '''stop service\n '''\n for child in GlobalObject().root.childsmanager._childs.values():\n child.callbackChildNotForResult('serverStop')\n reactor.callLater(0.5,reactor.stop)\n return \"stop\"","function_tokens":["def","stop","(",")",":","for","child","in","GlobalObject","(",")",".","root",".","childsmanager",".","_childs",".","values","(",")",":","child",".","callbackChildNotForResult","(","'serverStop'",")","reactor",".","callLater","(","0.5",",","reactor",".","stop",")","return","\"stop\""],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/master\/webapp.py#L12-L18"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/master\/webapp.py","language":"python","identifier":"reloadmodule","parameters":"()","argument_list":"","return_statement":"return \"reload\"","docstring":"reload module","docstring_summary":"reload module","docstring_tokens":["reload","module"],"function":"def reloadmodule():\n '''reload module\n '''\n for child in GlobalObject().root.childsmanager._childs.values():\n child.callbackChildNotForResult('sreload')\n return \"reload\"","function_tokens":["def","reloadmodule","(",")",":","for","child","in","GlobalObject","(",")",".","root",".","childsmanager",".","_childs",".","values","(",")",":","child",".","callbackChildNotForResult","(","'sreload'",")","return","\"reload\""],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/master\/webapp.py#L21-L26"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/distributed\/reference.py","language":"python","identifier":"ProxyReference.__init__","parameters":"(self)","argument_list":"","return_statement":"","docstring":"\u521d\u59cb\u5316","docstring_summary":"\u521d\u59cb\u5316","docstring_tokens":["\u521d\u59cb\u5316"],"function":"def __init__(self):\n '''\u521d\u59cb\u5316'''\n self._service = Service('proxy')","function_tokens":["def","__init__","(","self",")",":","self",".","_service","=","Service","(","'proxy'",")"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/distributed\/reference.py#L13-L15"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/distributed\/reference.py","language":"python","identifier":"ProxyReference.addService","parameters":"(self,service)","argument_list":"","return_statement":"","docstring":"\u6dfb\u52a0\u4e00\u6761\u670d\u52a1\u901a\u9053","docstring_summary":"\u6dfb\u52a0\u4e00\u6761\u670d\u52a1\u901a\u9053","docstring_tokens":["\u6dfb\u52a0\u4e00\u6761\u670d\u52a1\u901a\u9053"],"function":"def addService(self,service):\n '''\u6dfb\u52a0\u4e00\u6761\u670d\u52a1\u901a\u9053'''\n self._service = service","function_tokens":["def","addService","(","self",",","service",")",":","self",".","_service","=","service"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/distributed\/reference.py#L17-L19"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/distributed\/reference.py","language":"python","identifier":"ProxyReference.remote_callChild","parameters":"(self, command,*arg,**kw)","argument_list":"","return_statement":"return self._service.callTarget(command,*arg,**kw)","docstring":"\u4ee3\u7406\u53d1\u9001\u6570\u636e","docstring_summary":"\u4ee3\u7406\u53d1\u9001\u6570\u636e","docstring_tokens":["\u4ee3\u7406\u53d1\u9001\u6570\u636e"],"function":"def remote_callChild(self, command,*arg,**kw):\n '''\u4ee3\u7406\u53d1\u9001\u6570\u636e\n '''\n return self._service.callTarget(command,*arg,**kw)","function_tokens":["def","remote_callChild","(","self",",","command",",","*","arg",",","*","*","kw",")",":","return","self",".","_service",".","callTarget","(","command",",","*","arg",",","*","*","kw",")"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/distributed\/reference.py#L21-L24"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/distributed\/child.py","language":"python","identifier":"Child.__init__","parameters":"(self,name)","argument_list":"","return_statement":"","docstring":"\u521d\u59cb\u5316\u5b50\u8282\u70b9\u5bf9\u8c61","docstring_summary":"\u521d\u59cb\u5316\u5b50\u8282\u70b9\u5bf9\u8c61","docstring_tokens":["\u521d\u59cb\u5316\u5b50\u8282\u70b9\u5bf9\u8c61"],"function":"def __init__(self,name):\n '''\u521d\u59cb\u5316\u5b50\u8282\u70b9\u5bf9\u8c61\n '''\n self._name = name\n self._transport = None","function_tokens":["def","__init__","(","self",",","name",")",":","self",".","_name","=","name","self",".","_transport","=","None"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/distributed\/child.py#L10-L14"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/distributed\/child.py","language":"python","identifier":"Child.getName","parameters":"(self)","argument_list":"","return_statement":"return self._name","docstring":"\u83b7\u53d6\u5b50\u8282\u70b9\u7684\u540d\u79f0","docstring_summary":"\u83b7\u53d6\u5b50\u8282\u70b9\u7684\u540d\u79f0","docstring_tokens":["\u83b7\u53d6\u5b50\u8282\u70b9\u7684\u540d\u79f0"],"function":"def getName(self):\n '''\u83b7\u53d6\u5b50\u8282\u70b9\u7684\u540d\u79f0'''\n return self._name","function_tokens":["def","getName","(","self",")",":","return","self",".","_name"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/distributed\/child.py#L16-L18"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/distributed\/child.py","language":"python","identifier":"Child.setTransport","parameters":"(self,transport)","argument_list":"","return_statement":"","docstring":"\u8bbe\u7f6e\u5b50\u8282\u70b9\u7684\u901a\u9053","docstring_summary":"\u8bbe\u7f6e\u5b50\u8282\u70b9\u7684\u901a\u9053","docstring_tokens":["\u8bbe\u7f6e\u5b50\u8282\u70b9\u7684\u901a\u9053"],"function":"def setTransport(self,transport):\n '''\u8bbe\u7f6e\u5b50\u8282\u70b9\u7684\u901a\u9053'''\n self._transport = transport","function_tokens":["def","setTransport","(","self",",","transport",")",":","self",".","_transport","=","transport"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/distributed\/child.py#L20-L22"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/distributed\/child.py","language":"python","identifier":"Child.callbackChild","parameters":"(self,*args,**kw)","argument_list":"","return_statement":"return self.callbackChildForResult(*args,**kw)","docstring":"\u56de\u8c03\u5b50\u8282\u70b9\u7684\u63a5\u53e3\\n\n return a Defered Object (recvdata)","docstring_summary":"\u56de\u8c03\u5b50\u8282\u70b9\u7684\u63a5\u53e3\\n\n return a Defered Object (recvdata)","docstring_tokens":["\u56de\u8c03\u5b50\u8282\u70b9\u7684\u63a5\u53e3","\\","n","return","a","Defered","Object","(","recvdata",")"],"function":"def callbackChild(self,*args,**kw):\n '''\u56de\u8c03\u5b50\u8282\u70b9\u7684\u63a5\u53e3\\n\n return a Defered Object (recvdata)\n '''\n return self.callbackChildForResult(*args,**kw)","function_tokens":["def","callbackChild","(","self",",","*","args",",","*","*","kw",")",":","return","self",".","callbackChildForResult","(","*","args",",","*","*","kw",")"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/distributed\/child.py#L24-L28"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/distributed\/child.py","language":"python","identifier":"Child.callbackChildNotForResult","parameters":"(self,*args,**kw)","argument_list":"","return_statement":"","docstring":"\u56de\u8c03\u5b50\u8282\u70b9\u7684\u63a5\u53e3\\n\n return a Defered Object (recvdata)","docstring_summary":"\u56de\u8c03\u5b50\u8282\u70b9\u7684\u63a5\u53e3\\n\n return a Defered Object (recvdata)","docstring_tokens":["\u56de\u8c03\u5b50\u8282\u70b9\u7684\u63a5\u53e3","\\","n","return","a","Defered","Object","(","recvdata",")"],"function":"def callbackChildNotForResult(self,*args,**kw):\n '''\u56de\u8c03\u5b50\u8282\u70b9\u7684\u63a5\u53e3\\n\n return a Defered Object (recvdata)\n '''\n remote = self._transport.getRootObject()\n remote.callRemoteNotForResult('callChild',*args,**kw)","function_tokens":["def","callbackChildNotForResult","(","self",",","*","args",",","*","*","kw",")",":","remote","=","self",".","_transport",".","getRootObject","(",")","remote",".","callRemoteNotForResult","(","'callChild'",",","*","args",",","*","*","kw",")"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/distributed\/child.py#L30-L35"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/distributed\/child.py","language":"python","identifier":"Child.callbackChildForResult","parameters":"(self,*args,**kw)","argument_list":"","return_statement":"return recvdata","docstring":"\u56de\u8c03\u5b50\u8282\u70b9\u7684\u63a5\u53e3\\n\n return a Defered Object (recvdata)","docstring_summary":"\u56de\u8c03\u5b50\u8282\u70b9\u7684\u63a5\u53e3\\n\n return a Defered Object (recvdata)","docstring_tokens":["\u56de\u8c03\u5b50\u8282\u70b9\u7684\u63a5\u53e3","\\","n","return","a","Defered","Object","(","recvdata",")"],"function":"def callbackChildForResult(self,*args,**kw):\n '''\u56de\u8c03\u5b50\u8282\u70b9\u7684\u63a5\u53e3\\n\n return a Defered Object (recvdata)\n '''\n remote = self._transport.getRootObject()\n recvdata = remote.callRemoteForResult('callChild',*args,**kw)\n return recvdata","function_tokens":["def","callbackChildForResult","(","self",",","*","args",",","*","*","kw",")",":","remote","=","self",".","_transport",".","getRootObject","(",")","recvdata","=","remote",".","callRemoteForResult","(","'callChild'",",","*","args",",","*","*","kw",")","return","recvdata"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/distributed\/child.py#L37-L43"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/distributed\/root.py","language":"python","identifier":"BilateralBroker.remote_takeProxy","parameters":"(self,name)","argument_list":"","return_statement":"","docstring":"\u8bbe\u7f6e\u4ee3\u7406\u901a\u9053\n @param name: \u6839\u8282\u70b9\u7684\u540d\u79f0","docstring_summary":"\u8bbe\u7f6e\u4ee3\u7406\u901a\u9053","docstring_tokens":["\u8bbe\u7f6e\u4ee3\u7406\u901a\u9053"],"function":"def remote_takeProxy(self,name):\n '''\u8bbe\u7f6e\u4ee3\u7406\u901a\u9053\n @param name: \u6839\u8282\u70b9\u7684\u540d\u79f0\n '''\n self.factory.root.remote_takeProxy(name,self)","function_tokens":["def","remote_takeProxy","(","self",",","name",")",":","self",".","factory",".","root",".","remote_takeProxy","(","name",",","self",")"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/distributed\/root.py#L19-L23"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/distributed\/root.py","language":"python","identifier":"BilateralBroker.remote_callTarget","parameters":"(self,command,*args,**kw)","argument_list":"","return_statement":"return data","docstring":"\u8fdc\u7a0b\u8c03\u7528\u65b9\u6cd5\n @param commandId: int \u6307\u4ee4\u53f7\n @param data: str \u8c03\u7528\u53c2\u6570","docstring_summary":"\u8fdc\u7a0b\u8c03\u7528\u65b9\u6cd5","docstring_tokens":["\u8fdc\u7a0b\u8c03\u7528\u65b9\u6cd5"],"function":"def remote_callTarget(self,command,*args,**kw):\n '''\u8fdc\u7a0b\u8c03\u7528\u65b9\u6cd5\n @param commandId: int \u6307\u4ee4\u53f7\n @param data: str \u8c03\u7528\u53c2\u6570\n '''\n data = self.factory.root.remote_callTarget(command,*args,**kw)\n return data","function_tokens":["def","remote_callTarget","(","self",",","command",",","*","args",",","*","*","kw",")",":","data","=","self",".","factory",".","root",".","remote_callTarget","(","command",",","*","args",",","*","*","kw",")","return","data"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/distributed\/root.py#L25-L31"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/distributed\/root.py","language":"python","identifier":"PBRoot.__init__","parameters":"(self,dnsmanager = ChildsManager())","argument_list":"","return_statement":"","docstring":"\u521d\u59cb\u5316\u6839\u8282\u70b9","docstring_summary":"\u521d\u59cb\u5316\u6839\u8282\u70b9","docstring_tokens":["\u521d\u59cb\u5316\u6839\u8282\u70b9"],"function":"def __init__(self,dnsmanager = ChildsManager()):\n '''\u521d\u59cb\u5316\u6839\u8282\u70b9\n '''\n self.service = None\n self.childsmanager = dnsmanager","function_tokens":["def","__init__","(","self",",","dnsmanager","=","ChildsManager","(",")",")",":","self",".","service","=","None","self",".","childsmanager","=","dnsmanager"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/distributed\/root.py#L46-L50"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/distributed\/root.py","language":"python","identifier":"PBRoot.addServiceChannel","parameters":"(self,service)","argument_list":"","return_statement":"","docstring":"\u6dfb\u52a0\u670d\u52a1\u901a\u9053\n @param service: Service Object(In bilateral.services)","docstring_summary":"\u6dfb\u52a0\u670d\u52a1\u901a\u9053","docstring_tokens":["\u6dfb\u52a0\u670d\u52a1\u901a\u9053"],"function":"def addServiceChannel(self,service):\n '''\u6dfb\u52a0\u670d\u52a1\u901a\u9053\n @param service: Service Object(In bilateral.services)\n '''\n self.service = service","function_tokens":["def","addServiceChannel","(","self",",","service",")",":","self",".","service","=","service"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/distributed\/root.py#L52-L56"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/distributed\/root.py","language":"python","identifier":"PBRoot.remote_takeProxy","parameters":"(self,name,transport)","argument_list":"","return_statement":"","docstring":"\u8bbe\u7f6e\u4ee3\u7406\u901a\u9053\n @param name: \u6839\u8282\u70b9\u7684\u540d\u79f0","docstring_summary":"\u8bbe\u7f6e\u4ee3\u7406\u901a\u9053","docstring_tokens":["\u8bbe\u7f6e\u4ee3\u7406\u901a\u9053"],"function":"def remote_takeProxy(self,name,transport):\n '''\u8bbe\u7f6e\u4ee3\u7406\u901a\u9053\n @param name: \u6839\u8282\u70b9\u7684\u540d\u79f0\n '''\n log.msg('node [%s] takeProxy ready'%name)\n child = Child(name)\n self.childsmanager.addChild(child)\n child.setTransport(transport)\n self.doChildConnect(name, transport)","function_tokens":["def","remote_takeProxy","(","self",",","name",",","transport",")",":","log",".","msg","(","'node [%s] takeProxy ready'","%","name",")","child","=","Child","(","name",")","self",".","childsmanager",".","addChild","(","child",")","child",".","setTransport","(","transport",")","self",".","doChildConnect","(","name",",","transport",")"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/distributed\/root.py#L58-L66"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/distributed\/root.py","language":"python","identifier":"PBRoot.doChildConnect","parameters":"(self,name,transport)","argument_list":"","return_statement":"","docstring":"\u5f53node\u8282\u70b9\u8fde\u63a5\u65f6\u7684\u5904\u7406","docstring_summary":"\u5f53node\u8282\u70b9\u8fde\u63a5\u65f6\u7684\u5904\u7406","docstring_tokens":["\u5f53node\u8282\u70b9\u8fde\u63a5\u65f6\u7684\u5904\u7406"],"function":"def doChildConnect(self,name,transport):\n \"\"\"\u5f53node\u8282\u70b9\u8fde\u63a5\u65f6\u7684\u5904\u7406\n \"\"\"\n pass","function_tokens":["def","doChildConnect","(","self",",","name",",","transport",")",":","pass"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/distributed\/root.py#L68-L71"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/distributed\/root.py","language":"python","identifier":"PBRoot.remote_callTarget","parameters":"(self,command,*args,**kw)","argument_list":"","return_statement":"return data","docstring":"\u8fdc\u7a0b\u8c03\u7528\u65b9\u6cd5\n @param commandId: int \u6307\u4ee4\u53f7\n @param data: str \u8c03\u7528\u53c2\u6570","docstring_summary":"\u8fdc\u7a0b\u8c03\u7528\u65b9\u6cd5","docstring_tokens":["\u8fdc\u7a0b\u8c03\u7528\u65b9\u6cd5"],"function":"def remote_callTarget(self,command,*args,**kw):\n '''\u8fdc\u7a0b\u8c03\u7528\u65b9\u6cd5\n @param commandId: int \u6307\u4ee4\u53f7\n @param data: str \u8c03\u7528\u53c2\u6570\n '''\n data = self.service.callTarget(command,*args,**kw)\n return data","function_tokens":["def","remote_callTarget","(","self",",","command",",","*","args",",","*","*","kw",")",":","data","=","self",".","service",".","callTarget","(","command",",","*","args",",","*","*","kw",")","return","data"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/distributed\/root.py#L73-L79"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/distributed\/root.py","language":"python","identifier":"PBRoot.dropChild","parameters":"(self,*args,**kw)","argument_list":"","return_statement":"","docstring":"\u5220\u9664\u5b50\u8282\u70b9\u8bb0\u5f55","docstring_summary":"\u5220\u9664\u5b50\u8282\u70b9\u8bb0\u5f55","docstring_tokens":["\u5220\u9664\u5b50\u8282\u70b9\u8bb0\u5f55"],"function":"def dropChild(self,*args,**kw):\n '''\u5220\u9664\u5b50\u8282\u70b9\u8bb0\u5f55'''\n self.childsmanager.dropChild(*args,**kw)","function_tokens":["def","dropChild","(","self",",","*","args",",","*","*","kw",")",":","self",".","childsmanager",".","dropChild","(","*","args",",","*","*","kw",")"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/distributed\/root.py#L81-L83"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/distributed\/root.py","language":"python","identifier":"PBRoot.dropChildByID","parameters":"(self,childId)","argument_list":"","return_statement":"","docstring":"\u5220\u9664\u5b50\u8282\u70b9\u8bb0\u5f55","docstring_summary":"\u5220\u9664\u5b50\u8282\u70b9\u8bb0\u5f55","docstring_tokens":["\u5220\u9664\u5b50\u8282\u70b9\u8bb0\u5f55"],"function":"def dropChildByID(self,childId):\n '''\u5220\u9664\u5b50\u8282\u70b9\u8bb0\u5f55\n '''\n self.doChildLostConnect(childId)\n self.childsmanager.dropChildByID(childId)","function_tokens":["def","dropChildByID","(","self",",","childId",")",":","self",".","doChildLostConnect","(","childId",")","self",".","childsmanager",".","dropChildByID","(","childId",")"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/distributed\/root.py#L85-L89"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/distributed\/root.py","language":"python","identifier":"PBRoot.dropChildSessionId","parameters":"(self, session_id)","argument_list":"","return_statement":"","docstring":"\u5220\u9664\u5b50\u8282\u70b9\u8bb0\u5f55","docstring_summary":"\u5220\u9664\u5b50\u8282\u70b9\u8bb0\u5f55","docstring_tokens":["\u5220\u9664\u5b50\u8282\u70b9\u8bb0\u5f55"],"function":"def dropChildSessionId(self, session_id):\n '''\u5220\u9664\u5b50\u8282\u70b9\u8bb0\u5f55'''\n child = self.childsmanager.getChildBYSessionId(session_id)\n if not child:\n return\n childname = child.getName()\n self.doChildLostConnect(childname)\n self.childsmanager.dropChildByID(childname)","function_tokens":["def","dropChildSessionId","(","self",",","session_id",")",":","child","=","self",".","childsmanager",".","getChildBYSessionId","(","session_id",")","if","not","child",":","return","childname","=","child",".","getName","(",")","self",".","doChildLostConnect","(","childname",")","self",".","childsmanager",".","dropChildByID","(","childname",")"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/distributed\/root.py#L91-L98"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/distributed\/root.py","language":"python","identifier":"PBRoot.doChildLostConnect","parameters":"(self,childname)","argument_list":"","return_statement":"","docstring":"\u5f53node\u8282\u70b9\u8fde\u63a5\u65f6\u7684\u5904\u7406","docstring_summary":"\u5f53node\u8282\u70b9\u8fde\u63a5\u65f6\u7684\u5904\u7406","docstring_tokens":["\u5f53node\u8282\u70b9\u8fde\u63a5\u65f6\u7684\u5904\u7406"],"function":"def doChildLostConnect(self,childname):\n \"\"\"\u5f53node\u8282\u70b9\u8fde\u63a5\u65f6\u7684\u5904\u7406\n \"\"\"\n pass","function_tokens":["def","doChildLostConnect","(","self",",","childname",")",":","pass"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/distributed\/root.py#L100-L103"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/distributed\/root.py","language":"python","identifier":"PBRoot.callChild","parameters":"(self,key,*args,**kw)","argument_list":"","return_statement":"return self.childsmanager.callChild(key,*args,**kw)","docstring":"\u8c03\u7528\u5b50\u8282\u70b9\u7684\u63a5\u53e3\n @param childId: int \u5b50\u8282\u70b9\u7684id\n return Defered Object","docstring_summary":"\u8c03\u7528\u5b50\u8282\u70b9\u7684\u63a5\u53e3","docstring_tokens":["\u8c03\u7528\u5b50\u8282\u70b9\u7684\u63a5\u53e3"],"function":"def callChild(self,key,*args,**kw):\n '''\u8c03\u7528\u5b50\u8282\u70b9\u7684\u63a5\u53e3\n @param childId: int \u5b50\u8282\u70b9\u7684id\n return Defered Object\n '''\n return self.childsmanager.callChild(key,*args,**kw)","function_tokens":["def","callChild","(","self",",","key",",","*","args",",","*","*","kw",")",":","return","self",".","childsmanager",".","callChild","(","key",",","*","args",",","*","*","kw",")"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/distributed\/root.py#L105-L110"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/distributed\/root.py","language":"python","identifier":"PBRoot.callChildNotForResult","parameters":"(self,childname,*args,**kw)","argument_list":"","return_statement":"","docstring":"\u8c03\u7528\u5b50\u8282\u70b9\u7684\u63a5\u53e3\n @param childId: int \u5b50\u8282\u70b9\u7684id\n return Defered Object","docstring_summary":"\u8c03\u7528\u5b50\u8282\u70b9\u7684\u63a5\u53e3","docstring_tokens":["\u8c03\u7528\u5b50\u8282\u70b9\u7684\u63a5\u53e3"],"function":"def callChildNotForResult(self,childname,*args,**kw):\n '''\u8c03\u7528\u5b50\u8282\u70b9\u7684\u63a5\u53e3\n @param childId: int \u5b50\u8282\u70b9\u7684id\n return Defered Object\n '''\n self.childsmanager.callChildNotForResult(childname,*args,**kw)","function_tokens":["def","callChildNotForResult","(","self",",","childname",",","*","args",",","*","*","kw",")",":","self",".","childsmanager",".","callChildNotForResult","(","childname",",","*","args",",","*","*","kw",")"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/distributed\/root.py#L112-L117"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/distributed\/manager.py","language":"python","identifier":"ChildsManager.__init__","parameters":"(self)","argument_list":"","return_statement":"","docstring":"\u521d\u59cb\u5316\u5b50\u8282\u70b9\u7ba1\u7406\u5668","docstring_summary":"\u521d\u59cb\u5316\u5b50\u8282\u70b9\u7ba1\u7406\u5668","docstring_tokens":["\u521d\u59cb\u5316\u5b50\u8282\u70b9\u7ba1\u7406\u5668"],"function":"def __init__(self):\n '''\u521d\u59cb\u5316\u5b50\u8282\u70b9\u7ba1\u7406\u5668'''\n self._childs = {}","function_tokens":["def","__init__","(","self",")",":","self",".","_childs","=","{","}"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/distributed\/manager.py#L12-L14"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/distributed\/manager.py","language":"python","identifier":"ChildsManager.getChild","parameters":"(self,childname)","argument_list":"","return_statement":"return None","docstring":"\u6839\u636e\u8282\u70b9\u7684\u540d\u79f0\u83b7\u53d6\u8282\u70b9\u5b9e\u4f8b","docstring_summary":"\u6839\u636e\u8282\u70b9\u7684\u540d\u79f0\u83b7\u53d6\u8282\u70b9\u5b9e\u4f8b","docstring_tokens":["\u6839\u636e\u8282\u70b9\u7684\u540d\u79f0\u83b7\u53d6\u8282\u70b9\u5b9e\u4f8b"],"function":"def getChild(self,childname):\n '''\u6839\u636e\u8282\u70b9\u7684\u540d\u79f0\u83b7\u53d6\u8282\u70b9\u5b9e\u4f8b'''\n for key,child in self._childs.items():\n if child.getName() == childname:\n return self._childs[key]\n return None","function_tokens":["def","getChild","(","self",",","childname",")",":","for","key",",","child","in","self",".","_childs",".","items","(",")",":","if","child",".","getName","(",")","==","childname",":","return","self",".","_childs","[","key","]","return","None"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/distributed\/manager.py#L16-L21"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/distributed\/manager.py","language":"python","identifier":"ChildsManager.addChild","parameters":"(self,child)","argument_list":"","return_statement":"","docstring":"\u6dfb\u52a0\u4e00\u4e2achild\u8282\u70b9\\n\n @param child: Child object","docstring_summary":"\u6dfb\u52a0\u4e00\u4e2achild\u8282\u70b9\\n","docstring_tokens":["\u6dfb\u52a0\u4e00\u4e2achild\u8282\u70b9","\\","n"],"function":"def addChild(self,child):\n '''\u6dfb\u52a0\u4e00\u4e2achild\u8282\u70b9\\n\n @param child: Child object\n '''\n key = child.getName()\n if self._childs.has_key(key):\n raise \"child node %s exists\"% key\n self._childs[key] = child","function_tokens":["def","addChild","(","self",",","child",")",":","key","=","child",".","getName","(",")","if","self",".","_childs",".","has_key","(","key",")",":","raise","\"child node %s exists\"","%","key","self",".","_childs","[","key","]","=","child"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/distributed\/manager.py#L23-L30"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/distributed\/manager.py","language":"python","identifier":"ChildsManager.dropChild","parameters":"(self,child)","argument_list":"","return_statement":"","docstring":"\u5220\u9664\u4e00\u4e2achild \u8282\u70b9\\n\n @param child: Child Object","docstring_summary":"\u5220\u9664\u4e00\u4e2achild \u8282\u70b9\\n","docstring_tokens":["\u5220\u9664\u4e00\u4e2achild","\u8282\u70b9","\\","n"],"function":"def dropChild(self,child):\n '''\u5220\u9664\u4e00\u4e2achild \u8282\u70b9\\n\n @param child: Child Object \n '''\n key = child.getName()\n try:\n del self._childs[key]\n except Exception,e:\n log.msg(str(e))","function_tokens":["def","dropChild","(","self",",","child",")",":","key","=","child",".","getName","(",")","try",":","del","self",".","_childs","[","key","]","except","Exception",",","e",":","log",".","msg","(","str","(","e",")",")"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/distributed\/manager.py#L32-L40"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/distributed\/manager.py","language":"python","identifier":"ChildsManager.dropChildByID","parameters":"(self,childId)","argument_list":"","return_statement":"","docstring":"\u5220\u9664\u4e00\u4e2achild \u8282\u70b9\\n\n @param childId: Child ID","docstring_summary":"\u5220\u9664\u4e00\u4e2achild \u8282\u70b9\\n","docstring_tokens":["\u5220\u9664\u4e00\u4e2achild","\u8282\u70b9","\\","n"],"function":"def dropChildByID(self,childId):\n '''\u5220\u9664\u4e00\u4e2achild \u8282\u70b9\\n\n @param childId: Child ID \n '''\n try:\n del self._childs[childId]\n except Exception,e:\n log.msg(str(e))","function_tokens":["def","dropChildByID","(","self",",","childId",")",":","try",":","del","self",".","_childs","[","childId","]","except","Exception",",","e",":","log",".","msg","(","str","(","e",")",")"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/distributed\/manager.py#L42-L49"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/distributed\/manager.py","language":"python","identifier":"ChildsManager.callChild","parameters":"(self,childname,*args,**kw)","argument_list":"","return_statement":"return child.callbackChild(*args,**kw)","docstring":"\u8c03\u7528\u5b50\u8282\u70b9\u7684\u63a5\u53e3\\n\n @param childname: str \u5b50\u8282\u70b9\u7684\u540d\u79f0","docstring_summary":"\u8c03\u7528\u5b50\u8282\u70b9\u7684\u63a5\u53e3\\n","docstring_tokens":["\u8c03\u7528\u5b50\u8282\u70b9\u7684\u63a5\u53e3","\\","n"],"function":"def callChild(self,childname,*args,**kw):\n '''\u8c03\u7528\u5b50\u8282\u70b9\u7684\u63a5\u53e3\\n\n @param childname: str \u5b50\u8282\u70b9\u7684\u540d\u79f0\n '''\n child = self.getChild(childname)\n if not child:\n log.err(\"child %s doesn't exists\"%childname)\n return\n return child.callbackChild(*args,**kw)","function_tokens":["def","callChild","(","self",",","childname",",","*","args",",","*","*","kw",")",":","child","=","self",".","getChild","(","childname",")","if","not","child",":","log",".","err","(","\"child %s doesn't exists\"","%","childname",")","return","return","child",".","callbackChild","(","*","args",",","*","*","kw",")"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/distributed\/manager.py#L51-L59"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/distributed\/manager.py","language":"python","identifier":"ChildsManager.callChildNotForResult","parameters":"(self,childname,*args,**kw)","argument_list":"","return_statement":"","docstring":"\u8c03\u7528\u5b50\u8282\u70b9\u7684\u63a5\u53e3\\n\n @param childname: str \u5b50\u8282\u70b9\u7684\u540d\u79f0","docstring_summary":"\u8c03\u7528\u5b50\u8282\u70b9\u7684\u63a5\u53e3\\n","docstring_tokens":["\u8c03\u7528\u5b50\u8282\u70b9\u7684\u63a5\u53e3","\\","n"],"function":"def callChildNotForResult(self,childname,*args,**kw):\n '''\u8c03\u7528\u5b50\u8282\u70b9\u7684\u63a5\u53e3\\n\n @param childname: str \u5b50\u8282\u70b9\u7684\u540d\u79f0\n '''\n child = self._childs.get(childname,None)\n if not child:\n log.err(\"child %s doesn't exists\"%childname)\n return\n child.callbackChildNotForResult(*args,**kw)","function_tokens":["def","callChildNotForResult","(","self",",","childname",",","*","args",",","*","*","kw",")",":","child","=","self",".","_childs",".","get","(","childname",",","None",")","if","not","child",":","log",".","err","(","\"child %s doesn't exists\"","%","childname",")","return","child",".","callbackChildNotForResult","(","*","args",",","*","*","kw",")"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/distributed\/manager.py#L61-L69"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/distributed\/manager.py","language":"python","identifier":"ChildsManager.getChildBYSessionId","parameters":"(self, session_id)","argument_list":"","return_statement":"return None","docstring":"\u6839\u636esessionID\u83b7\u53d6child\u8282\u70b9\u4fe1\u606f","docstring_summary":"\u6839\u636esessionID\u83b7\u53d6child\u8282\u70b9\u4fe1\u606f","docstring_tokens":["\u6839\u636esessionID\u83b7\u53d6child\u8282\u70b9\u4fe1\u606f"],"function":"def getChildBYSessionId(self, session_id):\n \"\"\"\u6839\u636esessionID\u83b7\u53d6child\u8282\u70b9\u4fe1\u606f\n \"\"\"\n for child in self._childs.values():\n if child._transport.transport.sessionno == session_id:\n return child\n return None","function_tokens":["def","getChildBYSessionId","(","self",",","session_id",")",":","for","child","in","self",".","_childs",".","values","(",")",":","if","child",".","_transport",".","transport",".","sessionno","==","session_id",":","return","child","return","None"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/distributed\/manager.py#L71-L77"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/distributed\/node.py","language":"python","identifier":"BilateralClientProtocol.setProxyReference","parameters":"(self,pr)","argument_list":"","return_statement":"","docstring":"\u8bbe\u7f6e\u4ee3\u7406\u63a5\u53e3\u63d0\u4f9b\u5bf9\u8c61","docstring_summary":"\u8bbe\u7f6e\u4ee3\u7406\u63a5\u53e3\u63d0\u4f9b\u5bf9\u8c61","docstring_tokens":["\u8bbe\u7f6e\u4ee3\u7406\u63a5\u53e3\u63d0\u4f9b\u5bf9\u8c61"],"function":"def setProxyReference(self,pr):\n \"\"\"\u8bbe\u7f6e\u4ee3\u7406\u63a5\u53e3\u63d0\u4f9b\u5bf9\u8c61\n \"\"\"\n self.reference = pr","function_tokens":["def","setProxyReference","(","self",",","pr",")",":","self",".","reference","=","pr"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/distributed\/node.py#L18-L21"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/distributed\/node.py","language":"python","identifier":"BilateralClientProtocol.getRemoteMethod","parameters":"(self, _name)","argument_list":"","return_statement":"return method","docstring":"\u91cd\u5199\u83b7\u53d6\u63a5\u53e3\u5bf9\u8c61\u7684\u65b9\u6cd5\uff0c\u4ece\u4ee3\u7406\u63a5\u53e3\u63d0\u4f9b\u5bf9\u8c61\u4e2d\u83b7\u53d6","docstring_summary":"\u91cd\u5199\u83b7\u53d6\u63a5\u53e3\u5bf9\u8c61\u7684\u65b9\u6cd5\uff0c\u4ece\u4ee3\u7406\u63a5\u53e3\u63d0\u4f9b\u5bf9\u8c61\u4e2d\u83b7\u53d6","docstring_tokens":["\u91cd\u5199\u83b7\u53d6\u63a5\u53e3\u5bf9\u8c61\u7684\u65b9\u6cd5\uff0c\u4ece\u4ee3\u7406\u63a5\u53e3\u63d0\u4f9b\u5bf9\u8c61\u4e2d\u83b7\u53d6"],"function":"def getRemoteMethod(self, _name):\n \"\"\"\u91cd\u5199\u83b7\u53d6\u63a5\u53e3\u5bf9\u8c61\u7684\u65b9\u6cd5\uff0c\u4ece\u4ee3\u7406\u63a5\u53e3\u63d0\u4f9b\u5bf9\u8c61\u4e2d\u83b7\u53d6\n \"\"\"\n method = getattr(self.reference, \"remote_%s\"%_name)\n return method","function_tokens":["def","getRemoteMethod","(","self",",","_name",")",":","method","=","getattr","(","self",".","reference",",","\"remote_%s\"","%","_name",")","return","method"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/distributed\/node.py#L23-L27"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/distributed\/node.py","language":"python","identifier":"BilateralClientFactory.doconnectionLost","parameters":"(self)","argument_list":"","return_statement":"","docstring":"node\u8282\u70b9\u7aef\u5f00\u540e\u7684\u5904\u7406","docstring_summary":"node\u8282\u70b9\u7aef\u5f00\u540e\u7684\u5904\u7406","docstring_tokens":["node\u8282\u70b9\u7aef\u5f00\u540e\u7684\u5904\u7406"],"function":"def doconnectionLost(self):\n \"\"\"node\u8282\u70b9\u7aef\u5f00\u540e\u7684\u5904\u7406\n \"\"\"\n if self.ro:\n self.ro.reconnect()","function_tokens":["def","doconnectionLost","(","self",")",":","if","self",".","ro",":","self",".","ro",".","reconnect","(",")"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/distributed\/node.py#L42-L46"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/distributed\/node.py","language":"python","identifier":"RemoteObject.__init__","parameters":"(self,name,timeout=600)","argument_list":"","return_statement":"","docstring":"\u521d\u59cb\u5316\u8fdc\u7a0b\u8c03\u7528\u5bf9\u8c61\n @param port: int \u8fdc\u7a0b\u5206\u5e03\u670d\u7684\u7aef\u53e3\u53f7\n @param rootaddr: \u6839\u8282\u70b9\u670d\u52a1\u5668\u5730\u5740","docstring_summary":"\u521d\u59cb\u5316\u8fdc\u7a0b\u8c03\u7528\u5bf9\u8c61","docstring_tokens":["\u521d\u59cb\u5316\u8fdc\u7a0b\u8c03\u7528\u5bf9\u8c61"],"function":"def __init__(self,name,timeout=600):\n '''\u521d\u59cb\u5316\u8fdc\u7a0b\u8c03\u7528\u5bf9\u8c61\n @param port: int \u8fdc\u7a0b\u5206\u5e03\u670d\u7684\u7aef\u53e3\u53f7\n @param rootaddr: \u6839\u8282\u70b9\u670d\u52a1\u5668\u5730\u5740\n '''\n self._name = name\n self._factory = BilateralClientFactory(self)\n self._reference = ProxyReference()\n self._addr = None\n self._timeout = timeout","function_tokens":["def","__init__","(","self",",","name",",","timeout","=","600",")",":","self",".","_name","=","name","self",".","_factory","=","BilateralClientFactory","(","self",")","self",".","_reference","=","ProxyReference","(",")","self",".","_addr","=","None","self",".","_timeout","=","timeout"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/distributed\/node.py#L53-L62"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/distributed\/node.py","language":"python","identifier":"RemoteObject.setName","parameters":"(self,name)","argument_list":"","return_statement":"","docstring":"\u8bbe\u7f6e\u8282\u70b9\u7684\u540d\u79f0","docstring_summary":"\u8bbe\u7f6e\u8282\u70b9\u7684\u540d\u79f0","docstring_tokens":["\u8bbe\u7f6e\u8282\u70b9\u7684\u540d\u79f0"],"function":"def setName(self,name):\n '''\u8bbe\u7f6e\u8282\u70b9\u7684\u540d\u79f0'''\n self._name = name","function_tokens":["def","setName","(","self",",","name",")",":","self",".","_name","=","name"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/distributed\/node.py#L64-L66"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/distributed\/node.py","language":"python","identifier":"RemoteObject.getName","parameters":"(self)","argument_list":"","return_statement":"return self._name","docstring":"\u83b7\u53d6\u8282\u70b9\u7684\u540d\u79f0","docstring_summary":"\u83b7\u53d6\u8282\u70b9\u7684\u540d\u79f0","docstring_tokens":["\u83b7\u53d6\u8282\u70b9\u7684\u540d\u79f0"],"function":"def getName(self):\n '''\u83b7\u53d6\u8282\u70b9\u7684\u540d\u79f0'''\n return self._name","function_tokens":["def","getName","(","self",")",":","return","self",".","_name"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/distributed\/node.py#L68-L70"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/distributed\/node.py","language":"python","identifier":"RemoteObject.connect","parameters":"(self,addr)","argument_list":"","return_statement":"","docstring":"\u521d\u59cb\u5316\u8fdc\u7a0b\u8c03\u7528\u5bf9\u8c61","docstring_summary":"\u521d\u59cb\u5316\u8fdc\u7a0b\u8c03\u7528\u5bf9\u8c61","docstring_tokens":["\u521d\u59cb\u5316\u8fdc\u7a0b\u8c03\u7528\u5bf9\u8c61"],"function":"def connect(self,addr):\n '''\u521d\u59cb\u5316\u8fdc\u7a0b\u8c03\u7528\u5bf9\u8c61'''\n self._addr = addr\n reactor.connectTCP(addr[0], addr[1], self._factory)\n self.takeProxy()","function_tokens":["def","connect","(","self",",","addr",")",":","self",".","_addr","=","addr","reactor",".","connectTCP","(","addr","[","0","]",",","addr","[","1","]",",","self",".","_factory",")","self",".","takeProxy","(",")"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/distributed\/node.py#L72-L76"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/distributed\/node.py","language":"python","identifier":"RemoteObject.reconnect","parameters":"(self,addr=())","argument_list":"","return_statement":"","docstring":"\u91cd\u65b0\u8fde\u63a5","docstring_summary":"\u91cd\u65b0\u8fde\u63a5","docstring_tokens":["\u91cd\u65b0\u8fde\u63a5"],"function":"def reconnect(self,addr=()):\n '''\u91cd\u65b0\u8fde\u63a5'''\n if addr:\n self.connect(addr)\n else:\n self.connect(self._addr)","function_tokens":["def","reconnect","(","self",",","addr","=","(",")",")",":","if","addr",":","self",".","connect","(","addr",")","else",":","self",".","connect","(","self",".","_addr",")"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/distributed\/node.py#L78-L83"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/distributed\/node.py","language":"python","identifier":"RemoteObject.addServiceChannel","parameters":"(self,service)","argument_list":"","return_statement":"","docstring":"\u8bbe\u7f6e\u5f15\u7528\u5bf9\u8c61","docstring_summary":"\u8bbe\u7f6e\u5f15\u7528\u5bf9\u8c61","docstring_tokens":["\u8bbe\u7f6e\u5f15\u7528\u5bf9\u8c61"],"function":"def addServiceChannel(self,service):\n '''\u8bbe\u7f6e\u5f15\u7528\u5bf9\u8c61'''\n self._reference.addService(service)","function_tokens":["def","addServiceChannel","(","self",",","service",")",":","self",".","_reference",".","addService","(","service",")"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/distributed\/node.py#L85-L87"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/distributed\/node.py","language":"python","identifier":"RemoteObject.takeProxy","parameters":"(self)","argument_list":"","return_statement":"","docstring":"\u50cf\u8fdc\u7a0b\u670d\u52a1\u7aef\u53d1\u9001\u4ee3\u7406\u901a\u9053\u5bf9\u8c61","docstring_summary":"\u50cf\u8fdc\u7a0b\u670d\u52a1\u7aef\u53d1\u9001\u4ee3\u7406\u901a\u9053\u5bf9\u8c61","docstring_tokens":["\u50cf\u8fdc\u7a0b\u670d\u52a1\u7aef\u53d1\u9001\u4ee3\u7406\u901a\u9053\u5bf9\u8c61"],"function":"def takeProxy(self):\n '''\u50cf\u8fdc\u7a0b\u670d\u52a1\u7aef\u53d1\u9001\u4ee3\u7406\u901a\u9053\u5bf9\u8c61\n '''\n self._factory._protocol.setProxyReference(self._reference)\n deferedRemote = self._factory.getRootObject(timeout=self._timeout)\n deferedRemote.callRemoteNotForResult('takeProxy',self._name)","function_tokens":["def","takeProxy","(","self",")",":","self",".","_factory",".","_protocol",".","setProxyReference","(","self",".","_reference",")","deferedRemote","=","self",".","_factory",".","getRootObject","(","timeout","=","self",".","_timeout",")","deferedRemote",".","callRemoteNotForResult","(","'takeProxy'",",","self",".","_name",")"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/distributed\/node.py#L89-L94"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/distributed\/node.py","language":"python","identifier":"RemoteObject.callRemote","parameters":"(self,commandId,*args,**kw)","argument_list":"","return_statement":"return deferedRemote.callRemoteForResult('callTarget',commandId,*args,**kw)","docstring":"\u9ed8\u8ba4\u8fdc\u7a0b\u8c03\u7528\uff0c\u7b49\u5f85\u7ed3\u679c\u653e\u56de","docstring_summary":"\u9ed8\u8ba4\u8fdc\u7a0b\u8c03\u7528\uff0c\u7b49\u5f85\u7ed3\u679c\u653e\u56de","docstring_tokens":["\u9ed8\u8ba4\u8fdc\u7a0b\u8c03\u7528\uff0c\u7b49\u5f85\u7ed3\u679c\u653e\u56de"],"function":"def callRemote(self,commandId,*args,**kw):\n \"\"\"\u9ed8\u8ba4\u8fdc\u7a0b\u8c03\u7528\uff0c\u7b49\u5f85\u7ed3\u679c\u653e\u56de\n \"\"\"\n deferedRemote = self._factory.getRootObject(timeout=self._timeout)\n return deferedRemote.callRemoteForResult('callTarget',commandId,*args,**kw)","function_tokens":["def","callRemote","(","self",",","commandId",",","*","args",",","*","*","kw",")",":","deferedRemote","=","self",".","_factory",".","getRootObject","(","timeout","=","self",".","_timeout",")","return","deferedRemote",".","callRemoteForResult","(","'callTarget'",",","commandId",",","*","args",",","*","*","kw",")"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/distributed\/node.py#L96-L100"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/distributed\/node.py","language":"python","identifier":"RemoteObject.callRemoteForResult","parameters":"(self,commandId,*args,**kw)","argument_list":"","return_statement":"return deferedRemote.callRemoteForResult('callTarget',commandId,*args,**kw)","docstring":"\u8fdc\u7a0b\u8c03\u7528\uff0c\u5e76\u7b49\u5f85\u7ed3\u679c\u653e\u56de","docstring_summary":"\u8fdc\u7a0b\u8c03\u7528\uff0c\u5e76\u7b49\u5f85\u7ed3\u679c\u653e\u56de","docstring_tokens":["\u8fdc\u7a0b\u8c03\u7528\uff0c\u5e76\u7b49\u5f85\u7ed3\u679c\u653e\u56de"],"function":"def callRemoteForResult(self,commandId,*args,**kw):\n '''\u8fdc\u7a0b\u8c03\u7528\uff0c\u5e76\u7b49\u5f85\u7ed3\u679c\u653e\u56de\n '''\n deferedRemote = self._factory.getRootObject(timeout=self._timeout)\n return deferedRemote.callRemoteForResult('callTarget',commandId,*args,**kw)","function_tokens":["def","callRemoteForResult","(","self",",","commandId",",","*","args",",","*","*","kw",")",":","deferedRemote","=","self",".","_factory",".","getRootObject","(","timeout","=","self",".","_timeout",")","return","deferedRemote",".","callRemoteForResult","(","'callTarget'",",","commandId",",","*","args",",","*","*","kw",")"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/distributed\/node.py#L102-L106"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/distributed\/node.py","language":"python","identifier":"RemoteObject.callRemoteNotForResult","parameters":"(self,commandId,*args,**kw)","argument_list":"","return_statement":"return deferedRemote.callRemoteNotForResult('callTarget',commandId,*args,**kw)","docstring":"\u8fdc\u7a0b\u8c03\u7528,\u4e0d\u9700\u8981\u7ed3\u679c\u653e\u56de","docstring_summary":"\u8fdc\u7a0b\u8c03\u7528,\u4e0d\u9700\u8981\u7ed3\u679c\u653e\u56de","docstring_tokens":["\u8fdc\u7a0b\u8c03\u7528","\u4e0d\u9700\u8981\u7ed3\u679c\u653e\u56de"],"function":"def callRemoteNotForResult(self,commandId,*args,**kw):\n '''\u8fdc\u7a0b\u8c03\u7528,\u4e0d\u9700\u8981\u7ed3\u679c\u653e\u56de\n '''\n deferedRemote = self._factory.getRootObject(timeout=self._timeout)\n return deferedRemote.callRemoteNotForResult('callTarget',commandId,*args,**kw)","function_tokens":["def","callRemoteNotForResult","(","self",",","commandId",",","*","args",",","*","*","kw",")",":","deferedRemote","=","self",".","_factory",".","getRootObject","(","timeout","=","self",".","_timeout",")","return","deferedRemote",".","callRemoteNotForResult","(","'callTarget'",",","commandId",",","*","args",",","*","*","kw",")"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/distributed\/node.py#L108-L112"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/netconnect\/connection.py","language":"python","identifier":"Connection.__init__","parameters":"(self, _conn)","argument_list":"","return_statement":"","docstring":"id \u8fde\u63a5\u7684ID\n transport \u8fde\u63a5\u7684\u901a\u9053","docstring_summary":"id \u8fde\u63a5\u7684ID\n transport \u8fde\u63a5\u7684\u901a\u9053","docstring_tokens":["id","\u8fde\u63a5\u7684ID","transport","\u8fde\u63a5\u7684\u901a\u9053"],"function":"def __init__(self, _conn):\n '''\n id \u8fde\u63a5\u7684ID\n transport \u8fde\u63a5\u7684\u901a\u9053\n '''\n self.id = _conn.transport.sessionno\n self.instance = _conn","function_tokens":["def","__init__","(","self",",","_conn",")",":","self",".","id","=","_conn",".","transport",".","sessionno","self",".","instance","=","_conn"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/netconnect\/connection.py#L11-L17"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/netconnect\/connection.py","language":"python","identifier":"Connection.loseConnection","parameters":"(self)","argument_list":"","return_statement":"","docstring":"\u65ad\u5f00\u4e0e\u5ba2\u6237\u7aef\u7684\u8fde\u63a5","docstring_summary":"\u65ad\u5f00\u4e0e\u5ba2\u6237\u7aef\u7684\u8fde\u63a5","docstring_tokens":["\u65ad\u5f00\u4e0e\u5ba2\u6237\u7aef\u7684\u8fde\u63a5"],"function":"def loseConnection(self):\n '''\u65ad\u5f00\u4e0e\u5ba2\u6237\u7aef\u7684\u8fde\u63a5\n '''\n self.instance.transport.close()","function_tokens":["def","loseConnection","(","self",")",":","self",".","instance",".","transport",".","close","(",")"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/netconnect\/connection.py#L19-L22"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/netconnect\/connection.py","language":"python","identifier":"Connection.safeToWriteData","parameters":"(self,topicID,msg)","argument_list":"","return_statement":"","docstring":"\u53d1\u9001\u6d88\u606f","docstring_summary":"\u53d1\u9001\u6d88\u606f","docstring_tokens":["\u53d1\u9001\u6d88\u606f"],"function":"def safeToWriteData(self,topicID,msg):\n \"\"\"\u53d1\u9001\u6d88\u606f\n \"\"\"\n self.instance.safeToWriteData(msg,topicID)","function_tokens":["def","safeToWriteData","(","self",",","topicID",",","msg",")",":","self",".","instance",".","safeToWriteData","(","msg",",","topicID",")"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/netconnect\/connection.py#L24-L27"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/netconnect\/datapack.py","language":"python","identifier":"DataPackProtoc.__init__","parameters":"(self,HEAD_0 = 0,HEAD_1=0,HEAD_2=0,HEAD_3=0,protoVersion= 0,serverVersion=0)","argument_list":"","return_statement":"","docstring":"\u521d\u59cb\u5316\n @param HEAD_0: int \u534f\u8bae\u59340\n @param HEAD_1: int \u534f\u8bae\u59341\n @param HEAD_2: int \u534f\u8bae\u59342\n @param HEAD_3: int \u534f\u8bae\u59343\n @param protoVersion: int \u534f\u8bae\u5934\u7248\u672c\u53f7\n @param serverVersion: int \u670d\u52a1\u7248\u672c\u53f7","docstring_summary":"\u521d\u59cb\u5316","docstring_tokens":["\u521d\u59cb\u5316"],"function":"def __init__(self,HEAD_0 = 0,HEAD_1=0,HEAD_2=0,HEAD_3=0,protoVersion= 0,serverVersion=0):\n '''\u521d\u59cb\u5316\n @param HEAD_0: int \u534f\u8bae\u59340\n @param HEAD_1: int \u534f\u8bae\u59341\n @param HEAD_2: int \u534f\u8bae\u59342\n @param HEAD_3: int \u534f\u8bae\u59343\n @param protoVersion: int \u534f\u8bae\u5934\u7248\u672c\u53f7\n @param serverVersion: int \u670d\u52a1\u7248\u672c\u53f7\n '''\n self.HEAD_0 = HEAD_0\n self.HEAD_1 = HEAD_1\n self.HEAD_2 = HEAD_2\n self.HEAD_3 = HEAD_3\n self.protoVersion = protoVersion\n self.serverVersion = serverVersion","function_tokens":["def","__init__","(","self",",","HEAD_0","=","0",",","HEAD_1","=","0",",","HEAD_2","=","0",",","HEAD_3","=","0",",","protoVersion","=","0",",","serverVersion","=","0",")",":","self",".","HEAD_0","=","HEAD_0","self",".","HEAD_1","=","HEAD_1","self",".","HEAD_2","=","HEAD_2","self",".","HEAD_3","=","HEAD_3","self",".","protoVersion","=","protoVersion","self",".","serverVersion","=","serverVersion"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/netconnect\/datapack.py#L24-L38"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/netconnect\/datapack.py","language":"python","identifier":"DataPackProtoc.getHeadlength","parameters":"(self)","argument_list":"","return_statement":"return 17","docstring":"\u83b7\u53d6\u6570\u636e\u5305\u7684\u957f\u5ea6","docstring_summary":"\u83b7\u53d6\u6570\u636e\u5305\u7684\u957f\u5ea6","docstring_tokens":["\u83b7\u53d6\u6570\u636e\u5305\u7684\u957f\u5ea6"],"function":"def getHeadlength(self):\n \"\"\"\u83b7\u53d6\u6570\u636e\u5305\u7684\u957f\u5ea6\n \"\"\"\n return 17","function_tokens":["def","getHeadlength","(","self",")",":","return","17"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/netconnect\/datapack.py#L58-L61"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/netconnect\/datapack.py","language":"python","identifier":"DataPackProtoc.unpack","parameters":"(self,dpack)","argument_list":"","return_statement":"return {'result':True,'command':command,'length':length}","docstring":"\u89e3\u5305","docstring_summary":"\u89e3\u5305","docstring_tokens":["\u89e3\u5305"],"function":"def unpack(self,dpack):\n '''\u89e3\u5305\n '''\n try:\n ud = struct.unpack('!sssss3I',dpack)\n except struct.error,de:\n log.err(de,traceback.format_exc())\n return {'result':False,'command':0,'length':0}\n HEAD_0 = ord(ud[0])\n HEAD_1 = ord(ud[1])\n HEAD_2 = ord(ud[2])\n HEAD_3 = ord(ud[3])\n protoVersion = ord(ud[4])\n serverVersion = ud[5]\n length = ud[6]-4\n command = ud[7]\n if HEAD_0 <>self.HEAD_0 or HEAD_1<>self.HEAD_1 or\\\n HEAD_2<>self.HEAD_2 or HEAD_3<>self.HEAD_3 or\\\n protoVersion<>self.protoVersion or serverVersion<>self.serverVersion:\n return {'result':False,'command':0,'length':0}\n return {'result':True,'command':command,'length':length}","function_tokens":["def","unpack","(","self",",","dpack",")",":","try",":","ud","=","struct",".","unpack","(","'!sssss3I'",",","dpack",")","except","struct",".","error",",","de",":","log",".","err","(","de",",","traceback",".","format_exc","(",")",")","return","{","'result'",":","False",",","'command'",":","0",",","'length'",":","0","}","HEAD_0","=","ord","(","ud","[","0","]",")","HEAD_1","=","ord","(","ud","[","1","]",")","HEAD_2","=","ord","(","ud","[","2","]",")","HEAD_3","=","ord","(","ud","[","3","]",")","protoVersion","=","ord","(","ud","[","4","]",")","serverVersion","=","ud","[","5","]","length","=","ud","[","6","]","-","4","command","=","ud","[","7","]","if","HEAD_0","<>","self",".","HEAD_0","or","HEAD_1","<>","self",".","HEAD_1","or","HEAD_2","<>","self",".","HEAD_2","or","HEAD_3","<>","self",".","HEAD_3","or","protoVersion","<>","self",".","protoVersion","or","serverVersion","<>","self",".","serverVersion",":","return","{","'result'",":","False",",","'command'",":","0",",","'length'",":","0","}","return","{","'result'",":","True",",","'command'",":","command",",","'length'",":","length","}"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/netconnect\/datapack.py#L63-L83"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/netconnect\/datapack.py","language":"python","identifier":"DataPackProtoc.pack","parameters":"(self,command,response)","argument_list":"","return_statement":"return data","docstring":"\u6253\u5305\u6570\u636e\u5305","docstring_summary":"\u6253\u5305\u6570\u636e\u5305","docstring_tokens":["\u6253\u5305\u6570\u636e\u5305"],"function":"def pack(self,command,response):\n '''\u6253\u5305\u6570\u636e\u5305\n '''\n HEAD_0 = chr(self.HEAD_0)\n HEAD_1 = chr(self.HEAD_1)\n HEAD_2 = chr(self.HEAD_2)\n HEAD_3 = chr(self.HEAD_3)\n protoVersion = chr(self.protoVersion)\n serverVersion = self.serverVersion\n length = response.__len__()+4\n commandID = command\n data = struct.pack('!sssss3I',HEAD_0,HEAD_1,HEAD_2,HEAD_3,\\\n protoVersion,serverVersion,length,commandID)\n data = data + response\n return data","function_tokens":["def","pack","(","self",",","command",",","response",")",":","HEAD_0","=","chr","(","self",".","HEAD_0",")","HEAD_1","=","chr","(","self",".","HEAD_1",")","HEAD_2","=","chr","(","self",".","HEAD_2",")","HEAD_3","=","chr","(","self",".","HEAD_3",")","protoVersion","=","chr","(","self",".","protoVersion",")","serverVersion","=","self",".","serverVersion","length","=","response",".","__len__","(",")","+","4","commandID","=","command","data","=","struct",".","pack","(","'!sssss3I'",",","HEAD_0",",","HEAD_1",",","HEAD_2",",","HEAD_3",",","protoVersion",",","serverVersion",",","length",",","commandID",")","data","=","data","+","response","return","data"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/netconnect\/datapack.py#L85-L99"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/netconnect\/manager.py","language":"python","identifier":"ConnectionManager.__init__","parameters":"(self)","argument_list":"","return_statement":"","docstring":"\u521d\u59cb\u5316\n @param _connections: dict {connID:conn Object}","docstring_summary":"\u521d\u59cb\u5316","docstring_tokens":["\u521d\u59cb\u5316"],"function":"def __init__(self):\n '''\u521d\u59cb\u5316\n @param _connections: dict {connID:conn Object}\n '''\n self._connections = {}","function_tokens":["def","__init__","(","self",")",":","self",".","_connections","=","{","}"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/netconnect\/manager.py#L17-L21"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/netconnect\/manager.py","language":"python","identifier":"ConnectionManager.getNowConnCnt","parameters":"(self)","argument_list":"","return_statement":"return len(self._connections.items())","docstring":"\u83b7\u53d6\u5f53\u524d\u8fde\u63a5\u6570\u91cf","docstring_summary":"\u83b7\u53d6\u5f53\u524d\u8fde\u63a5\u6570\u91cf","docstring_tokens":["\u83b7\u53d6\u5f53\u524d\u8fde\u63a5\u6570\u91cf"],"function":"def getNowConnCnt(self):\n '''\u83b7\u53d6\u5f53\u524d\u8fde\u63a5\u6570\u91cf'''\n return len(self._connections.items())","function_tokens":["def","getNowConnCnt","(","self",")",":","return","len","(","self",".","_connections",".","items","(",")",")"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/netconnect\/manager.py#L23-L25"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/netconnect\/manager.py","language":"python","identifier":"ConnectionManager.addConnection","parameters":"(self, conn)","argument_list":"","return_statement":"","docstring":"\u52a0\u5165\u4e00\u6761\u8fde\u63a5\n @param _conn: Conn object","docstring_summary":"\u52a0\u5165\u4e00\u6761\u8fde\u63a5","docstring_tokens":["\u52a0\u5165\u4e00\u6761\u8fde\u63a5"],"function":"def addConnection(self, conn):\n '''\u52a0\u5165\u4e00\u6761\u8fde\u63a5\n @param _conn: Conn object\n '''\n _conn = Connection(conn)\n if self._connections.has_key(_conn.id):\n raise Exception(\"\u7cfb\u7edf\u8bb0\u5f55\u51b2\u7a81\")\n self._connections[_conn.id] = _conn","function_tokens":["def","addConnection","(","self",",","conn",")",":","_conn","=","Connection","(","conn",")","if","self",".","_connections",".","has_key","(","_conn",".","id",")",":","raise","Exception","(","\"\u7cfb\u7edf\u8bb0\u5f55\u51b2\u7a81\")","","self",".","_connections","[","_conn",".","id","]","=","_conn"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/netconnect\/manager.py#L27-L34"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/netconnect\/manager.py","language":"python","identifier":"ConnectionManager.dropConnectionByID","parameters":"(self, connID)","argument_list":"","return_statement":"","docstring":"\u66f4\u52a0\u8fde\u63a5\u7684id\u5220\u9664\u8fde\u63a5\u5b9e\u4f8b\n @param connID: int \u8fde\u63a5\u7684id","docstring_summary":"\u66f4\u52a0\u8fde\u63a5\u7684id\u5220\u9664\u8fde\u63a5\u5b9e\u4f8b","docstring_tokens":["\u66f4\u52a0\u8fde\u63a5\u7684id\u5220\u9664\u8fde\u63a5\u5b9e\u4f8b"],"function":"def dropConnectionByID(self, connID):\n '''\u66f4\u52a0\u8fde\u63a5\u7684id\u5220\u9664\u8fde\u63a5\u5b9e\u4f8b\n @param connID: int \u8fde\u63a5\u7684id\n '''\n try:\n del self._connections[connID]\n except Exception as e:\n log.msg(str(e))","function_tokens":["def","dropConnectionByID","(","self",",","connID",")",":","try",":","del","self",".","_connections","[","connID","]","except","Exception","as","e",":","log",".","msg","(","str","(","e",")",")"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/netconnect\/manager.py#L36-L43"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/netconnect\/manager.py","language":"python","identifier":"ConnectionManager.getConnectionByID","parameters":"(self, connID)","argument_list":"","return_statement":"return self._connections.get(connID,None)","docstring":"\u6839\u636eID\u83b7\u53d6\u4e00\u6761\u8fde\u63a5\n @param connID: int \u8fde\u63a5\u7684id","docstring_summary":"\u6839\u636eID\u83b7\u53d6\u4e00\u6761\u8fde\u63a5","docstring_tokens":["\u6839\u636eID\u83b7\u53d6\u4e00\u6761\u8fde\u63a5"],"function":"def getConnectionByID(self, connID):\n \"\"\"\u6839\u636eID\u83b7\u53d6\u4e00\u6761\u8fde\u63a5\n @param connID: int \u8fde\u63a5\u7684id\n \"\"\"\n return self._connections.get(connID,None)","function_tokens":["def","getConnectionByID","(","self",",","connID",")",":","return","self",".","_connections",".","get","(","connID",",","None",")"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/netconnect\/manager.py#L45-L49"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/netconnect\/manager.py","language":"python","identifier":"ConnectionManager.loseConnection","parameters":"(self,connID)","argument_list":"","return_statement":"","docstring":"\u6839\u636e\u8fde\u63a5ID\u4e3b\u52a8\u7aef\u53e3\u4e0e\u5ba2\u6237\u7aef\u7684\u8fde\u63a5","docstring_summary":"\u6839\u636e\u8fde\u63a5ID\u4e3b\u52a8\u7aef\u53e3\u4e0e\u5ba2\u6237\u7aef\u7684\u8fde\u63a5","docstring_tokens":["\u6839\u636e\u8fde\u63a5ID\u4e3b\u52a8\u7aef\u53e3\u4e0e\u5ba2\u6237\u7aef\u7684\u8fde\u63a5"],"function":"def loseConnection(self,connID):\n \"\"\"\u6839\u636e\u8fde\u63a5ID\u4e3b\u52a8\u7aef\u53e3\u4e0e\u5ba2\u6237\u7aef\u7684\u8fde\u63a5\n \"\"\"\n conn = self.getConnectionByID(connID)\n if conn:\n conn.loseConnection()\n self.dropConnectionByID(connID)","function_tokens":["def","loseConnection","(","self",",","connID",")",":","conn","=","self",".","getConnectionByID","(","connID",")","if","conn",":","conn",".","loseConnection","(",")","self",".","dropConnectionByID","(","connID",")"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/netconnect\/manager.py#L51-L57"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/netconnect\/manager.py","language":"python","identifier":"ConnectionManager.pushObject","parameters":"(self,topicID , msg, sendList)","argument_list":"","return_statement":"","docstring":"\u4e3b\u52a8\u63a8\u9001\u6d88\u606f","docstring_summary":"\u4e3b\u52a8\u63a8\u9001\u6d88\u606f","docstring_tokens":["\u4e3b\u52a8\u63a8\u9001\u6d88\u606f"],"function":"def pushObject(self,topicID , msg, sendList):\n \"\"\"\u4e3b\u52a8\u63a8\u9001\u6d88\u606f\n \"\"\"\n for target in sendList:\n try:\n conn = self.getConnectionByID(target)\n if conn:\n conn.safeToWriteData(topicID,msg)\n except Exception,e:\n log.err(e,traceback.format_exc())","function_tokens":["def","pushObject","(","self",",","topicID",",","msg",",","sendList",")",":","for","target","in","sendList",":","try",":","conn","=","self",".","getConnectionByID","(","target",")","if","conn",":","conn",".","safeToWriteData","(","topicID",",","msg",")","except","Exception",",","e",":","log",".","err","(","e",",","traceback",".","format_exc","(",")",")"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/netconnect\/manager.py#L59-L68"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/netconnect\/protoc.py","language":"python","identifier":"LiberateProtocol.connectionMade","parameters":"(self)","argument_list":"","return_statement":"","docstring":"\u8fde\u63a5\u5efa\u7acb\u5904\u7406","docstring_summary":"\u8fde\u63a5\u5efa\u7acb\u5904\u7406","docstring_tokens":["\u8fde\u63a5\u5efa\u7acb\u5904\u7406"],"function":"def connectionMade(self):\n '''\u8fde\u63a5\u5efa\u7acb\u5904\u7406\n '''\n address = self.transport.getAddress()\n log.msg('Client %d login in.[%s,%d]'%(self.transport.sessionno,\\\n address[0],address[1]))\n self.factory.connmanager.addConnection(self)\n self.factory.doConnectionMade(self)","function_tokens":["def","connectionMade","(","self",")",":","address","=","self",".","transport",".","getAddress","(",")","log",".","msg","(","'Client %d login in.[%s,%d]'","%","(","self",".","transport",".","sessionno",",","address","[","0","]",",","address","[","1","]",")",")","self",".","factory",".","connmanager",".","addConnection","(","self",")","self",".","factory",".","doConnectionMade","(","self",")"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/netconnect\/protoc.py#L18-L25"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/netconnect\/protoc.py","language":"python","identifier":"LiberateProtocol.connectionLost","parameters":"(self,reason)","argument_list":"","return_statement":"","docstring":"\u8fde\u63a5\u65ad\u5f00\u5904\u7406","docstring_summary":"\u8fde\u63a5\u65ad\u5f00\u5904\u7406","docstring_tokens":["\u8fde\u63a5\u65ad\u5f00\u5904\u7406"],"function":"def connectionLost(self,reason):\n '''\u8fde\u63a5\u65ad\u5f00\u5904\u7406\n '''\n log.msg('Client %d login out.'%(self.transport.sessionno))\n self.factory.doConnectionLost(self)\n self.factory.connmanager.dropConnectionByID(self.transport.sessionno)","function_tokens":["def","connectionLost","(","self",",","reason",")",":","log",".","msg","(","'Client %d login out.'","%","(","self",".","transport",".","sessionno",")",")","self",".","factory",".","doConnectionLost","(","self",")","self",".","factory",".","connmanager",".","dropConnectionByID","(","self",".","transport",".","sessionno",")"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/netconnect\/protoc.py#L27-L32"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/netconnect\/protoc.py","language":"python","identifier":"LiberateProtocol.safeToWriteData","parameters":"(self,data,command)","argument_list":"","return_statement":"","docstring":"\u7ebf\u7a0b\u5b89\u5168\u7684\u5411\u5ba2\u6237\u7aef\u53d1\u9001\u6570\u636e\n @param data: str \u8981\u5411\u5ba2\u6237\u7aef\u5199\u7684\u6570\u636e","docstring_summary":"\u7ebf\u7a0b\u5b89\u5168\u7684\u5411\u5ba2\u6237\u7aef\u53d1\u9001\u6570\u636e","docstring_tokens":["\u7ebf\u7a0b\u5b89\u5168\u7684\u5411\u5ba2\u6237\u7aef\u53d1\u9001\u6570\u636e"],"function":"def safeToWriteData(self,data,command):\n '''\u7ebf\u7a0b\u5b89\u5168\u7684\u5411\u5ba2\u6237\u7aef\u53d1\u9001\u6570\u636e\n @param data: str \u8981\u5411\u5ba2\u6237\u7aef\u5199\u7684\u6570\u636e\n '''\n if data is None:\n return\n senddata = self.factory.produceResult(command,data)\n self.transport.sendall(senddata)","function_tokens":["def","safeToWriteData","(","self",",","data",",","command",")",":","if","data","is","None",":","return","senddata","=","self",".","factory",".","produceResult","(","command",",","data",")","self",".","transport",".","sendall","(","senddata",")"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/netconnect\/protoc.py#L34-L41"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/netconnect\/protoc.py","language":"python","identifier":"LiberateProtocol.dataReceived","parameters":"(self, data)","argument_list":"","return_statement":"","docstring":"\u6570\u636e\u5230\u8fbe\u5904\u7406\n @param data: str \u5ba2\u6237\u7aef\u4f20\u9001\u8fc7\u6765\u7684\u6570\u636e","docstring_summary":"\u6570\u636e\u5230\u8fbe\u5904\u7406","docstring_tokens":["\u6570\u636e\u5230\u8fbe\u5904\u7406"],"function":"def dataReceived(self, data):\n \n '''\u6570\u636e\u5230\u8fbe\u5904\u7406\n @param data: str \u5ba2\u6237\u7aef\u4f20\u9001\u8fc7\u6765\u7684\u6570\u636e\n '''\n length = self.factory.dataprotocl.getHeadlength()#\u83b7\u53d6\u534f\u8bae\u5934\u7684\u957f\u5ea6\n self.buff += data\n while self.buff.__len__() >= length: \n unpackdata = self.factory.dataprotocl.unpack(self.buff[:length])\n if not unpackdata.get('result'):\n log.msg('illegal data package --')\n self.factory.connmanager.loseConnection(self.transport.sessionno)\n break\n command = unpackdata.get('command')\n rlength = unpackdata.get('length')\n request = self.buff[length:length+rlength]\n if request.__len__()< rlength:\n log.msg('some data lose')\n break\n self.buff = self.buff[length+rlength:]\n response = self.factory.doDataReceived(self,command,request)\n if not response:\n continue\n self.safeToWriteData(response, command)","function_tokens":["def","dataReceived","(","self",",","data",")",":","length","=","self",".","factory",".","dataprotocl",".","getHeadlength","(",")","#\u83b7\u53d6\u534f\u8bae\u5934\u7684\u957f\u5ea6","self",".","buff","+=","data","while","self",".","buff",".","__len__","(",")",">=","length",":","unpackdata","=","self",".","factory",".","dataprotocl",".","unpack","(","self",".","buff","[",":","length","]",")","if","not","unpackdata",".","get","(","'result'",")",":","log",".","msg","(","'illegal data package --'",")","self",".","factory",".","connmanager",".","loseConnection","(","self",".","transport",".","sessionno",")","break","command","=","unpackdata",".","get","(","'command'",")","rlength","=","unpackdata",".","get","(","'length'",")","request","=","self",".","buff","[","length",":","length","+","rlength","]","if","request",".","__len__","(",")","<","rlength",":","log",".","msg","(","'some data lose'",")","break","self",".","buff","=","self",".","buff","[","length","+","rlength",":","]","response","=","self",".","factory",".","doDataReceived","(","self",",","command",",","request",")","if","not","response",":","continue","self",".","safeToWriteData","(","response",",","command",")"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/netconnect\/protoc.py#L43-L66"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/netconnect\/protoc.py","language":"python","identifier":"LiberateFactory.__init__","parameters":"(self,dataprotocl=DataPackProtoc())","argument_list":"","return_statement":"","docstring":"\u521d\u59cb\u5316","docstring_summary":"\u521d\u59cb\u5316","docstring_tokens":["\u521d\u59cb\u5316"],"function":"def __init__(self,dataprotocl=DataPackProtoc()):\n '''\u521d\u59cb\u5316\n '''\n protocols.ServerFactory.__init__(self)\n self.service = None\n self.connmanager = ConnectionManager()\n self.dataprotocl = dataprotocl","function_tokens":["def","__init__","(","self",",","dataprotocl","=","DataPackProtoc","(",")",")",":","protocols",".","ServerFactory",".","__init__","(","self",")","self",".","service","=","None","self",".","connmanager","=","ConnectionManager","(",")","self",".","dataprotocl","=","dataprotocl"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/netconnect\/protoc.py#L73-L79"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/netconnect\/protoc.py","language":"python","identifier":"LiberateFactory.doConnectionMade","parameters":"(self,conn)","argument_list":"","return_statement":"","docstring":"\u5f53\u8fde\u63a5\u5efa\u7acb\u65f6\u7684\u5904\u7406","docstring_summary":"\u5f53\u8fde\u63a5\u5efa\u7acb\u65f6\u7684\u5904\u7406","docstring_tokens":["\u5f53\u8fde\u63a5\u5efa\u7acb\u65f6\u7684\u5904\u7406"],"function":"def doConnectionMade(self,conn):\n '''\u5f53\u8fde\u63a5\u5efa\u7acb\u65f6\u7684\u5904\u7406'''\n pass","function_tokens":["def","doConnectionMade","(","self",",","conn",")",":","pass"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/netconnect\/protoc.py#L86-L88"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/netconnect\/protoc.py","language":"python","identifier":"LiberateFactory.doConnectionLost","parameters":"(self,conn)","argument_list":"","return_statement":"","docstring":"\u8fde\u63a5\u65ad\u5f00\u65f6\u7684\u5904\u7406","docstring_summary":"\u8fde\u63a5\u65ad\u5f00\u65f6\u7684\u5904\u7406","docstring_tokens":["\u8fde\u63a5\u65ad\u5f00\u65f6\u7684\u5904\u7406"],"function":"def doConnectionLost(self,conn):\n '''\u8fde\u63a5\u65ad\u5f00\u65f6\u7684\u5904\u7406'''\n pass","function_tokens":["def","doConnectionLost","(","self",",","conn",")",":","pass"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/netconnect\/protoc.py#L90-L92"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/netconnect\/protoc.py","language":"python","identifier":"LiberateFactory.addServiceChannel","parameters":"(self,service)","argument_list":"","return_statement":"","docstring":"\u6dfb\u52a0\u670d\u52a1\u901a\u9053","docstring_summary":"\u6dfb\u52a0\u670d\u52a1\u901a\u9053","docstring_tokens":["\u6dfb\u52a0\u670d\u52a1\u901a\u9053"],"function":"def addServiceChannel(self,service):\n '''\u6dfb\u52a0\u670d\u52a1\u901a\u9053'''\n self.service = service","function_tokens":["def","addServiceChannel","(","self",",","service",")",":","self",".","service","=","service"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/netconnect\/protoc.py#L94-L96"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/netconnect\/protoc.py","language":"python","identifier":"LiberateFactory.doDataReceived","parameters":"(self,conn,commandID,data)","argument_list":"","return_statement":"return response","docstring":"\u6570\u636e\u5230\u8fbe\u65f6\u7684\u5904\u7406","docstring_summary":"\u6570\u636e\u5230\u8fbe\u65f6\u7684\u5904\u7406","docstring_tokens":["\u6570\u636e\u5230\u8fbe\u65f6\u7684\u5904\u7406"],"function":"def doDataReceived(self,conn,commandID,data):\n '''\u6570\u636e\u5230\u8fbe\u65f6\u7684\u5904\u7406'''\n response = self.service.callTarget(commandID,conn,data)\n return response","function_tokens":["def","doDataReceived","(","self",",","conn",",","commandID",",","data",")",":","response","=","self",".","service",".","callTarget","(","commandID",",","conn",",","data",")","return","response"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/netconnect\/protoc.py#L98-L101"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/netconnect\/protoc.py","language":"python","identifier":"LiberateFactory.produceResult","parameters":"(self,command,response)","argument_list":"","return_statement":"return self.dataprotocl.pack(command,response)","docstring":"\u4ea7\u751f\u5ba2\u6237\u7aef\u9700\u8981\u7684\u6700\u7ec8\u7ed3\u679c\n @param response: str \u5206\u5e03\u5f0f\u5ba2\u6237\u7aef\u83b7\u53d6\u7684\u7ed3\u679c","docstring_summary":"\u4ea7\u751f\u5ba2\u6237\u7aef\u9700\u8981\u7684\u6700\u7ec8\u7ed3\u679c","docstring_tokens":["\u4ea7\u751f\u5ba2\u6237\u7aef\u9700\u8981\u7684\u6700\u7ec8\u7ed3\u679c"],"function":"def produceResult(self,command,response):\n '''\u4ea7\u751f\u5ba2\u6237\u7aef\u9700\u8981\u7684\u6700\u7ec8\u7ed3\u679c\n @param response: str \u5206\u5e03\u5f0f\u5ba2\u6237\u7aef\u83b7\u53d6\u7684\u7ed3\u679c\n '''\n return self.dataprotocl.pack(command,response)","function_tokens":["def","produceResult","(","self",",","command",",","response",")",":","return","self",".","dataprotocl",".","pack","(","command",",","response",")"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/netconnect\/protoc.py#L103-L107"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/netconnect\/protoc.py","language":"python","identifier":"LiberateFactory.loseConnection","parameters":"(self,connID)","argument_list":"","return_statement":"","docstring":"\u4e3b\u52a8\u7aef\u53e3\u4e0e\u5ba2\u6237\u7aef\u7684\u8fde\u63a5","docstring_summary":"\u4e3b\u52a8\u7aef\u53e3\u4e0e\u5ba2\u6237\u7aef\u7684\u8fde\u63a5","docstring_tokens":["\u4e3b\u52a8\u7aef\u53e3\u4e0e\u5ba2\u6237\u7aef\u7684\u8fde\u63a5"],"function":"def loseConnection(self,connID):\n \"\"\"\u4e3b\u52a8\u7aef\u53e3\u4e0e\u5ba2\u6237\u7aef\u7684\u8fde\u63a5\n \"\"\"\n self.connmanager.loseConnection(connID)","function_tokens":["def","loseConnection","(","self",",","connID",")",":","self",".","connmanager",".","loseConnection","(","connID",")"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/netconnect\/protoc.py#L109-L112"} {"nwo":"9miao\/G-Firefly","sha":"8fbeeb3ef9782600560be48228c91cfb8f5ff87d","path":"gfirefly\/gfirefly\/netconnect\/protoc.py","language":"python","identifier":"LiberateFactory.pushObject","parameters":"(self,topicID , msg, sendList)","argument_list":"","return_statement":"","docstring":"\u670d\u52a1\u7aef\u5411\u5ba2\u6237\u7aef\u63a8\u6d88\u606f\n @param topicID: int \u6d88\u606f\u7684\u4e3b\u9898id\u53f7\n @param msg: \u6d88\u606f\u7684\u7c7b\u5bb9\uff0cprotobuf\u7ed3\u6784\u7c7b\u578b\n @param sendList: \u63a8\u5411\u7684\u76ee\u6807\u5217\u8868(\u5ba2\u6237\u7aefid \u5217\u8868)","docstring_summary":"\u670d\u52a1\u7aef\u5411\u5ba2\u6237\u7aef\u63a8\u6d88\u606f","docstring_tokens":["\u670d\u52a1\u7aef\u5411\u5ba2\u6237\u7aef\u63a8\u6d88\u606f"],"function":"def pushObject(self,topicID , msg, sendList):\n '''\u670d\u52a1\u7aef\u5411\u5ba2\u6237\u7aef\u63a8\u6d88\u606f\n @param topicID: int \u6d88\u606f\u7684\u4e3b\u9898id\u53f7\n @param msg: \u6d88\u606f\u7684\u7c7b\u5bb9\uff0cprotobuf\u7ed3\u6784\u7c7b\u578b\n @param sendList: \u63a8\u5411\u7684\u76ee\u6807\u5217\u8868(\u5ba2\u6237\u7aefid \u5217\u8868)\n '''\n self.connmanager.pushObject(topicID, msg, sendList)","function_tokens":["def","pushObject","(","self",",","topicID",",","msg",",","sendList",")",":","self",".","connmanager",".","pushObject","(","topicID",",","msg",",","sendList",")"],"url":"https:\/\/github.com\/9miao\/G-Firefly\/blob\/8fbeeb3ef9782600560be48228c91cfb8f5ff87d\/gfirefly\/gfirefly\/netconnect\/protoc.py#L114-L120"}