def insertfunf(data, internalDataStore, token):
    funfresult = {}
    motiondata = []
    print '\n======================\nextractAndInsertData:'
    print data
    print '\n======================\n'

    for object in data:
            if object['probe'] == 'motion':
                motiondata.append(object)

    #pdb.set_trace()
    #calls function with only motion data to calculate activity
    #activitydata is dictionary of all ActivityProbe instances
    activitydata = getmotiondata.ondatareceived(motiondata)


    activityresult = {}
    #insert activitydata
    for object in activitydata:
        #pdb.set_trace()

        try:
            internalDataStore.saveData(object, 'funf')
            activityresult = {'status':'ok', 'entries_inserted': 1}
        except Exception as e:
            print "\n\nException from os_connector on pds: %s\n" %e
            funfresult = {'success':False, 'error_message':e.message}
    for object in data:

            funfdata = getfunfdata.getfunfdata(object)

            try:
                internalDataStore.saveData(funfdata, 'funf')
                funfresult = {'status':'ok', 'entries_inserted':1}
            except Exception as e:
                print "\n\nException from os_connector on pds: %s\n" %e
                funfresult = {'success':False, 'error_message':e.message}
    return funfresult
dataset/ETHPy150Open HumanDynamics/openPDS/openpds/connectors/opensense/views.py/insertfunf/original