コード例 #1
0
ファイル: tasks.py プロジェクト: RogerTangos/openPDS
def deleteUnusedProfiles():
    profiles = Profile.objects.all()
    start = getStartTime(60, False)

    for profile in profiles:
        dbName = profile.getDBName()
        collection = connection[dbName]["funf"]
        
        if collection.find({"time": { "$gte": start}}).count() == 0:
            connection.drop_database(dbName)
            profile.delete()
コード例 #2
0
ファイル: tasks.py プロジェクト: RogerTangos/openPDS
def recentProbeCounts():
    profiles = Profile.objects.all()
    startTime = getStartTime(1, False)
    
    for profile in profiles:
        ids = getInternalDataStore(profile, "", "Living Lab", "")
        probes = ["ActivityProbe", "SimpleLocationProbe", "CallLogProbe", "SmsProbe", "WifiProbe", "BluetoothProbe"]
        answer = {}
        for probe in probes:
            data = ids.getData(probe, startTime, None)
            answer[probe] = data.count()
        ids.saveAnswer("RecentProbeCounts", answer)
コード例 #3
0
ファイル: tasks.py プロジェクト: RogerTangos/openPDS
def dumpFunfData():
    profiles = Profile.objects.all()
    outputConnection = sqlite3.connect("oms_pds/static/dump.db")
    c = outputConnection.cursor()
    c.execute("CREATE TABLE IF NOT EXISTS funf (user_id integer, key text, time real, value text, PRIMARY KEY (user_id, key, time) on conflict ignore)")
    startTime = getStartTime(3, False)#max(1378008000, startTimeRow[0]) if startTimeRow is not None else 1378008000
    for profile in profiles:
        dbName = profile.getDBName()
        funf = connection[dbName]["funf"]
        user = int(profile.id)
        c.executemany("INSERT INTO funf VALUES (?,?,?,?)", [(user,d["key"][d["key"].rfind(".")+1:],d["time"],"%s"%d["value"]) for d in funf.find({"time": {"$gte": startTime}}) if d["key"] is not None])

    outputConnection.commit()
    outputConnection.close()
コード例 #4
0
ファイル: gfsa_tasks.py プロジェクト: RogerTangos/openPDS
def recentGfsaScore(ids):
	startTime = getStartTime(7, False)
	answer = {}
	for probe in probes:
	    probePrettyName=probesPrettyNames[probe]
	    try:
            	data = ids.getData(probe, startTime, None)
		dataList = [d["value"]["timestamp"] for d in data]
		dataList.sort()
		maxDate = dataList.pop()
		maxDateISO=datetime.datetime.fromtimestamp(maxDate)
            	answer[probePrettyName] = maxDateISO.strftime("%d %B %Y %I:%M%p")#onvert to string
	    except Exception, ex:
		#print "error: {}".format(ex)
           	answer[probePrettyName] = "None"
コード例 #5
0
def recentProbeCounts():
    profiles = Profile.objects.all()
    startTime = getStartTime(1, False)

    for profile in profiles:
        ids = getInternalDataStore(profile, "", "Living Lab", "")
        probes = [
            "ActivityProbe", "SimpleLocationProbe", "CallLogProbe", "SmsProbe",
            "WifiProbe", "BluetoothProbe"
        ]
        answer = {}
        for probe in probes:
            data = ids.getData(probe, startTime, None)
            answer[probe] = data.count()
        ids.saveAnswer("RecentProbeCounts", answer)
コード例 #6
0
def dumpFunfData():
    profiles = Profile.objects.all()
    outputConnection = sqlite3.connect("oms_pds/static/dump.db")
    c = outputConnection.cursor()
    c.execute(
        "CREATE TABLE IF NOT EXISTS funf (user_id integer, key text, time real, value text, PRIMARY KEY (user_id, key, time) on conflict ignore)"
    )
    startTime = getStartTime(
        3, False
    )  #max(1378008000, startTimeRow[0]) if startTimeRow is not None else 1378008000
    for profile in profiles:
        dbName = profile.getDBName()
        funf = connection[dbName]["funf"]
        user = int(profile.id)
        c.executemany("INSERT INTO funf VALUES (?,?,?,?)",
                      [(user, d["key"][d["key"].rfind(".") + 1:], d["time"],
                        "%s" % d["value"])
                       for d in funf.find({"time": {
                           "$gte": startTime
                       }}) if d["key"] is not None])

    outputConnection.commit()
    outputConnection.close()