Exemplo n.º 1
0
def call_get(index):
    loop = int(lis[index + 1])
    for number in range(loop):
        if lis[index] == "get":
            print "\n..................Going to GET Device Information..............."
            mysql_py.mysql_Truncate_Table("DM_GET")
            #time.sleep(3)
            #print "Available Devices for GET"
            Discover_List = mysql_py.mysql_Fetch_Discover()
            if len(Discover_List) > 0:
                for inputHandle in Discover_List:

                    #	inputHandle = raw_input("input handle to get data : ")
                    #	print "GET the device Information for Handle: ",inputHandle
                    #	time.sleep(10)
                    fun.VITA_DM_Get(inputHandle, fun.user_get_callback)
                    time.sleep(5)
                    mysql_py.mysql_Fetch_Handle("DM_GET", inputHandle)
            #	time.sleep(5)
            else:

                raise Exception(
                    "Error:No resource found for getting device info")
        else:

            print "..................wrong get  called ................."
            sys.exit(0)
Exemplo n.º 2
0
def call_observe(index):
    loop = int(lis[index + 1])
    print "************************************"
    print "            Observe called      "
    print "************************************"
    mysql_py.mysql_Truncate_Table("DM_Observe")
    for number in range(loop):
        if lis[index] == "observe":
            Discover_List = mysql_py.mysql_Fetch_Discover()
            if len(Discover_List) > 0:
                for inputHandle in Discover_List:
                    #mysql_py.mysql_Delet_old_Observe(inputHandle)
                    #time.sleep(10)
                    print "\n observe called for Handle :", inputHandle
                    fun.VITA_DM_Observe(inputHandle, fun.user_observe_callback,
                                        0)
                    time.sleep(5)
                    mysql_py.mysql_Fetch_Handle("DM_Observe", inputHandle)
            else:

                raise Exception("No resources for observe" + str(lis))
        else:
            print "..................wrong observe  called ................."
            VITA_TL_Send(W_Observe)
            sys.exit(0)
Exemplo n.º 3
0
def call_put(index):
    loop = int(lis[index + 1])
    Put_fail = []
    for number in range(loop):
        if lis[index] == "put":
            print "*************************************"
            print "             PUT DATA                "
            print "*************************************"

            test = True
            Discover_List = mysql_py.mysql_Fetch_Discover()
            if len(Discover_List) > 0:
                for inputHandle in Discover_List:
                    print "DM_GET before PUT for Handle : ", inputHandle
                    mysql_py.mysql_Fetch_Handle("DM_GET", inputHandle)
                    print "........................................."
                    print "Putting data for handle : ", inputHandle
                    key = "power"
                    valuetype = "i"
                    value = mysql_py.mysql_fetech_value(inputHandle)

                    print "change", key, "=", value, "to", key, "=", value + 50
                    value = value + 50
                    #print "type ", type(value)
                    fun.put_data(inputHandle, key, valuetype, value, "NULL")
                    time.sleep(3)
                    mysql_py.mysql_Delete_Handle("DM_GET", inputHandle)
                    time.sleep(2)
                    fun.VITA_DM_Get(inputHandle, fun.user_get_callback)
                    time.sleep(4)
                    print "DM_GET after PUT for Handle :", inputHandle
                    key_val = mysql_py.mysql_Fetch_Handle(
                        "DM_GET", inputHandle)
                    if (key_val == None):
                        print 'val is none'
                        key_val = '0'
                    #print type(key_val),key_val, type(value), value
                    if (int(key_val) == value):
                        test = True
                        pass
                    else:
                        Put_fail.append(inputHandle)
                        test = False
                    time.sleep(2)
                if (test):
                    print "put sucess on all resources"
                else:

                    print "put failed on ", Put_fail
                    raise Exception("put failed on resources" + str(lis))

            else:

                raise Exception("No Resource found to put" + str(lis))
        else:
            print "..................wrong get  called ................."
            VITA_TL_Send(W_Put)
            sys.exit(0)