Beispiel #1
0
def serializeConfig(server, minRow, frags):
    cfg = Properties()
    cfg.set('server', server)
    if minRow is not None:
        cfg.set('minRow', minRow)
    for i, f in enumerate(frags):
        cfg.set('tables.i%d' % i, f)
    o = StringIO()
    cfg.dump(o, noSpace=True)
    return o.getvalue()
Beispiel #2
0
def serializeConfig(server, minRow, frags):
    cfg = Properties()
    cfg.set('server', server)
    if minRow is not None:
        cfg.set('minRow', minRow)
    for i,f in enumerate(frags):
        cfg.set('tables.i%d' % i, f)
    o = StringIO()
    cfg.dump(o, noSpace=True)
    return o.getvalue()
Beispiel #3
0
def updateLocations(meta, port):
    import pykdi
    from util.props import Properties
    from cStringIO import StringIO
    from util.zero import zeroDecode

    # Open META table
    metaTable = pykdi.Table(meta)

    # Go through 'config' cells, extract 'server' variable, and write
    # 'location' cells
    for row,col,time,val in metaTable.scan('column = "config"'):
        table,dummy,last = zeroDecode(row)
        cfg = Properties(StringIO(val))
        loc = 'kdi://%s:%s/%s' % (cfg.get('server'), port, table)
        metaTable.set(row, 'location', time, loc)
    
    # Sync changes
    metaTable.sync()
Beispiel #4
0
def parseConfig(s):
    cfg = Properties()
    cfg.load(StringIO(s))
    server = cfg.get('server')
    minRow = cfg.get('minRow', None)
    frags = []
    for key in cfg:
        if key in ('server', 'minRow'):
            continue
        if not key.startswith('tables.'):
            raise RuntimeError('unknown key: %s' % key)
        frags.append((key, cfg.get(key)))
    frags.sort()
    frags = [val for key, val in frags]
    return server, minRow, frags
Beispiel #5
0
def parseConfig(s):
    cfg = Properties()
    cfg.load(StringIO(s))
    server = cfg.get('server')
    minRow = cfg.get('minRow', None)
    frags = []
    for key in cfg:
        if key in ('server', 'minRow'):
            continue
        if not key.startswith('tables.'):
            raise RuntimeError('unknown key: %s' % key)
        frags.append((key, cfg.get(key)))
    frags.sort()
    frags = [ val for key,val in frags ]
    return server, minRow, frags