當前位置: 首頁>>代碼示例>>Python>>正文


Python GraphNode.initclasstypeobj方法代碼示例

本文整理匯總了Python中graphnodes.GraphNode.initclasstypeobj方法的典型用法代碼示例。如果您正苦於以下問題:Python GraphNode.initclasstypeobj方法的具體用法?Python GraphNode.initclasstypeobj怎麽用?Python GraphNode.initclasstypeobj使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在graphnodes.GraphNode的用法示例。


在下文中一共展示了GraphNode.initclasstypeobj方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: dbsetup

# 需要導入模塊: from graphnodes import GraphNode [as 別名]
# 或者: from graphnodes.GraphNode import initclasstypeobj [as 別名]
def dbsetup(readonly=False):
    'Set up our connection to Neo4j'
    ourstore = Store(neo4j.GraphDatabaseService(), uniqueindexmap={}, classkeymap={})
    CMAinit(None, readonly=readonly, use_network=False)
    for classname in GraphNode.classmap:
        GraphNode.initclasstypeobj(ourstore, classname)
    return ourstore
開發者ID:borgified,項目名稱:testroot,代碼行數:9,代碼來源:assimcli.py

示例2: setup

# 需要導入模塊: from graphnodes import GraphNode [as 別名]
# 或者: from graphnodes.GraphNode import initclasstypeobj [as 別名]
 def setup(dbhost='localhost', dbport=7474, dburl=None, querypath=None):
     '''
     Program to set up for running our REST server.
     We do these things:
         - Attach to the database
         - Initialize our type objects so things like ClientQuery will work...
         - Load the queries into the database from flat files
             Not sure if doing this here makes the best sense, but it
             works, and currently we're the only one who cares about them
             so it seems reasonable -- at the moment ;-)
             Also we're most likely to iterate changing on those relating to the
             REST server, so fixing them just by restarting the REST server seems
             to make a lot of sense (at the moment)
         - Remember the set of queries in the 'allqueries' hash table
     '''
     if dburl is None:
         dburl = ('http://%s:%d/db/data/' % (dbhost, dbport))
     print >> sys.stderr, 'CREATING Graph("%s")' % dburl
     neodb = neo4j.Graph(dburl)
     qstore = Store(neodb, None, None)
     print GraphNode.classmap
     for classname in GraphNode.classmap:
         GraphNode.initclasstypeobj(qstore, classname)
     print "LOADING TREE!"
     if querypath is None:
         querypath = "/home/alanr/monitor/src/queries"
     queries = ClientQuery.load_tree(qstore, querypath)
     for q in queries:
         allqueries[q.queryname] = q
     qstore.commit()
     for q in allqueries:
         allqueries[q].bind_store(qstore)
開發者ID:Alan-R,項目名稱:assimilation-persistent-events,代碼行數:34,代碼來源:hello.py

示例3: __init__

# 需要導入模塊: from graphnodes import GraphNode [as 別名]
# 或者: from graphnodes.GraphNode import initclasstypeobj [as 別名]
 def __init__(self, io, host='localhost', port=7474, cleanoutdb=False, debug=False
 ,       retries=300, readonly=False, encryption_required=False, use_network=True):
     'Initialize and construct a global database instance'
     #print >> sys.stderr, 'CALLING NEW initglobal'
     CMAdb.log = logging.getLogger('cma')
     CMAdb.debug = debug
     CMAdb.io = io
     from hbring import HbRing
     syslog = logging.handlers.SysLogHandler(address='/dev/log'
     ,       facility=logging.handlers.SysLogHandler.LOG_DAEMON)
     syslog.setFormatter(logging.Formatter('%(name)s %(levelname)s: %(message)s'))
     CMAdb.log.addHandler(syslog)
     CMAdb.log.setLevel(logging.DEBUG)
     url = ('http://%s:%d/db/data/' % (host, port))
     #print >> sys.stderr, 'CREATING GraphDatabaseService("%s")' % url
     neodb = neo4j.GraphDatabaseService(url)
     self.db = neodb
     if cleanoutdb:
         CMAdb.log.info('Re-initializing the NEO4j database')
         self.delete_all()
     self.db = neodb
     CMAdb.use_network = use_network
     trycount=0
     while True:
         try:
             CMAdb.cdb = CMAdb(db=neodb)
             # Neo4j started.  All is well with the world.
             break
         except (RuntimeError, IOError, py2neo.exceptions.ClientError) as exc:
             print >> sys.stderr, 'TRYING AGAIN [[%s]...[%s]' % (url, str(exc))
             trycount += 1
             if trycount > retries:
                 print >> sys.stderr, ('Neo4j still not started - giving up.')
                 CMAdb.log.critical('Neo4j still not started - giving up.')
                 raise RuntimeError('Neo4j not running - giving up [%s]' % str(exc))
             if (trycount % 60) == 1:
                 print >> sys.stderr, ('Waiting for Neo4j [%s] to start [%s].' % (url, str(exc)))
                 CMAdb.log.warning('Waiting for Neo4j [%s] to start [%s].' % (url, str(exc)))
             # Let's try again in a second...
             time.sleep(1)
     Store.debug = debug
     Store.log = CMAdb.log
     CMAdb.store = Store(neodb, CMAconsts.uniqueindexes, CMAconsts.classkeymap
     ,   readonly=readonly)
     if not readonly:
         for classname in GraphNode.classmap:
             GraphNode.initclasstypeobj(CMAdb.store, classname)
         from transaction import Transaction
         CMAdb.transaction = Transaction(encryption_required=encryption_required)
         #print >> sys.stderr,  'CMAdb:', CMAdb
         #print >> sys.stderr,  'CMAdb.store(cmadb.py):', CMAdb.store
         CMAdb.TheOneRing = CMAdb.store.load_or_create(HbRing, name='The_One_Ring'
         ,           ringtype= HbRing.THEONERING)
         CMAdb.transaction.commit_trans(io)
         #print >> sys.stderr, 'COMMITTING Store'
         #print >> sys.stderr, 'Transaction Commit results:', CMAdb.store.commit()
         CMAdb.store.commit()
         #print >> sys.stderr, 'Store COMMITTED'
     else:
         CMAdb.transaction = None
開發者ID:borgified,項目名稱:testroot,代碼行數:62,代碼來源:cmainit.py

示例4: dbsetup

# 需要導入模塊: from graphnodes import GraphNode [as 別名]
# 或者: from graphnodes.GraphNode import initclasstypeobj [as 別名]
def dbsetup(readonly=False, url=None):
    'Set up our connection to Neo4j'
    if url is None:
        url = 'localhost.com:7474'
    Neo4jCreds().authenticate(url)
    ourstore = Store(neo4j.Graph(), uniqueindexmap={}, classkeymap={})
    CMAinit(DummyIO(), readonly=readonly, use_network=False)
    for classname in GraphNode.classmap:
        GraphNode.initclasstypeobj(ourstore, classname)
    CMAdb.store = ourstore
    return ourstore
開發者ID:carrieao,項目名稱:assimilation-official,代碼行數:13,代碼來源:assimcli.py

示例5: ClientQuery

# 需要導入模塊: from graphnodes import GraphNode [as 別名]
# 或者: from graphnodes.GraphNode import initclasstypeobj [as 別名]
            }
        }
    }
    '''
    q3 = ClientQuery('ipowners', metadata3)

    Neo4jCreds().authenticate()
    neodb = neo4j.Graph()
    neodb.delete_all()

    umap  = {'ClientQuery': True}
    ckmap = {'ClientQuery': {'index': 'ClientQuery', 'kattr':'queryname', 'value':'None'}}

    qstore = Store(neodb, uniqueindexmap=umap, classkeymap=ckmap)
    for classname in GraphNode.classmap:
        GraphNode.initclasstypeobj(qstore, classname)

    print "LOADING TREE!"

    queries = ClientQuery.load_tree(qstore, "%s/../queries" % (os.path.dirname(sys.argv[0])))
    qlist = [q for q in queries]
    qstore.commit()
    print "%d node TREE LOADED!" % len(qlist)
    qe2 = qstore.load_or_create(ClientQuery, queryname='list')
    qe2.bind_store(qstore)
    testresult = ''
    for s in qe2.execute(None, idsonly=False, expandJSON=True):
        testresult += s
    print 'RESULT', testresult
    # Test out a command line query
    for s in qe2.cmdline_exec(None):
開發者ID:h4ck3rm1k3,項目名稱:assimilation-official,代碼行數:33,代碼來源:query.py


注:本文中的graphnodes.GraphNode.initclasstypeobj方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。