Example #1
0
def getA(dbr_hdl, tuple_name, match_template, group, buffer_size=None):
    out_size = ffi.new('int64_t*')
    if buffer_size is None :
        buffer_size=[128]
    out_size[0] = buffer_size[0]
    out_buffer = createBuf('char[]', out_size[0])
    tag = libdatabroker.dbrGetA(dbr_hdl, ffi.from_buffer(out_buffer), out_size, tuple_name.encode(), match_template.encode(), group.encode())
    buffer_size[0] = out_size[0]
    return tag, out_buffer # pickle.loads(out_buffer[:]) 
Example #2
0
def directory(dbr_hdl, match_template, group, count, size):
    tbuf = createBuf('char[]', size)
    rsize = ffi.new('int64_t*')
    retval = libdatabroker.dbrDirectory(dbr_hdl, match_template.encode(),
                                        group.encode(), count,
                                        ffi.from_buffer(tbuf),
                                        ffi.cast('const size_t', size), rsize)
    result_buffer = (tbuf[0:rsize[0]].decode().split('\n'))
    return result_buffer, rsize[0], retval
Example #3
0
def readA(dbr_hdl, tuple_name, match_template, group, flag=DBR_FLAGS_NONE, buffer_size=None):
    out_size = ffi.new('int64_t*')
    if buffer_size is None :
        buffer_size=[128]
    out_size[0] = buffer_size[0]
    out_buffer = createBuf('char[]', out_size[0])
    tag = libdatabroker.dbrReadA(dbr_hdl, ffi.from_buffer(out_buffer), out_size, tuple_name.encode(), match_template.encode(), group.encode(), flags)
    buffer_size[0] = out_size[0]
    return tag, out_buffer 
Example #4
0
def get(dbr_hdl, tuple_name, match_template, group, flag, buffer_size=None):
    out_size = ffi.new('int64_t*')
    if buffer_size is None :
        buffer_size=[128]
    out_size[0] = buffer_size[0]
    out_buffer = createBuf('char[]', out_size[0])
    retval = libdatabroker.dbrGet(dbr_hdl, ffi.from_buffer(out_buffer), out_size, tuple_name.encode(), match_template.encode(), group.encode(), flag)
    if retval != 0:
        return None, retval
    buffer_size[0] = out_size[0]
    result = None
    try:
        result = pickle.loads(out_buffer[:])
    except:
        result = out_buffer[:].decode()
    return result, retval
Example #5
0
 # Unless required by applicable law or agreed to in writing, software
 # distributed under the License is distributed on an "AS IS" BASIS,
 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 # See the License for the specific language governing permissions and
 # limitations under the License.
 #
import os
import sys

from _dbr_interface import ffi
from dbr_module import dbr


dbr_name = "DBRtestname"
level = dbr.DBR_PERST_VOLATILE_SIMPLE
group_list = ffi.new('DBR_GroupList_t')
dbr_hdl = ffi.new('DBR_Handle_t*')
dbr_hdl = dbr.dbrCreate(dbr_name, level, group_list)
group = '0'

# query the CDB to see if successful
dbr_state = ffi.new('DBR_State_t*')
res = dbr.dbrQuery(dbr_hdl, dbr_state, dbr.DBR_STATE_MASK_ALL)

test_in = "Hello World!"
res = dbr.dbrPut(dbr_hdl, test_in, "testTup", group)
res = dbr.dbrPut(dbr_hdl, "Goodbye", "testTup", group)

print 'Put ' + test_in + ' and Goodbye' 
out_size = ffi.new('int64_t*')
out_size[0] = 1024
Example #6
0
def createBuf(buftype, bufsize):
    retval = ffi.buffer(ffi.new(buftype, bufsize))
    return retval
Example #7
0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
import os
import sys

from _dbr_interface import ffi
from dbr_module import dbr

dbr_name = "DBRtestname"
level = dbr.DBR_PERST_VOLATILE_SIMPLE
group_list = ffi.new('DBR_GroupList_t')
dbr_hdl = ffi.new('DBR_Handle_t*')
dbr_hdl = dbr.create(dbr_name, level, group_list)
group = dbr.DBR_GROUP_EMPTY

# query the DB to see if successful
dbr_state = ffi.new('DBR_State_t*')
res = dbr.query(dbr_hdl, dbr_state, dbr.DBR_STATE_MASK_ALL)

test_in = "Hello World!"
res = dbr.put(dbr_hdl, test_in, "testTup", group)
res = dbr.put(dbr_hdl, "Goodbye!", "testTup", group)

print('Put ' + test_in + ' and Goodbye!')
group_t = 0
value, res = dbr.read(dbr_hdl, "testTup", "", group, dbr.DBR_FLAGS_NOWAIT)