Beispiel #1
0
HighPhrases = {}
HotPhrases = {}
BurstingPhrases = {}

while True:
    try:
        Time = time.time()
        T = int(Time)
        high = C.highvalue(limit=100)
        hot = C.realtime_hot_phrases()
        bursting = C.realtime_bursting_phrases()

        print 'new'
        for V in high['values']:
            HighPhrases[V] = True
            DB.high_phrase(V.split('bit.ly/')[1],T)
            print V, T

        for P in hot:
            phrase = P['phrase']
            HotPhrases[phrase] = sum(map(lambda x:x['visitors'],P['ghashes']))
            DB.hot_phrase(phrase,T,HotPhrases[phrase])
            print phrase, T, HotPhrases[phrase]

        for P in bursting:
            phrase = P['phrase']
            BurstingPhrases[phrase] = sum(map(lambda x:x['visitors'],P['ghashes']))
            DB.bursting_phrase(phrase,T,BurstingPhrases[phrase],P['mean'],P['rate'],P['std'])
            print phrase, T, BurstingPhrases[phrase], P['mean'], P['rate'], P['std']

        time.sleep(5*60-(time.time()-Time))
Beispiel #2
0
DB = Database("crontracking.db")

HighPhrases = {}
HotPhrases = {}
BurstingPhrases = {}

try:
    T = int(time.time())
    high = C.highvalue(limit=100)
    hot = C.realtime_hot_phrases()
    bursting = C.realtime_bursting_phrases()

    print "new"
    for V in high["values"]:
        HighPhrases[V] = True
        DB.high_phrase(V.split("bit.ly/")[1], T)
        print V, T

    for P in hot:
        phrase = P["phrase"]
        HotPhrases[phrase] = sum(map(lambda x: x["visitors"], P["ghashes"]))
        DB.hot_phrase(phrase, T, HotPhrases[phrase])
        print phrase, T, HotPhrases[phrase]

    for P in bursting:
        phrase = P["phrase"]
        BurstingPhrases[phrase] = sum(map(lambda x: x["visitors"], P["ghashes"]))
        DB.bursting_phrase(phrase, T, BurstingPhrases[phrase], P["mean"], P["rate"], P["std"])
        print phrase, T, BurstingPhrases[phrase], P["mean"], P["rate"], P["std"]

except Exception, er:
Beispiel #3
0
HighPhrases = {}
HotPhrases = {}
BurstingPhrases = {}
errors = 0

while True:
    try:
        high = C.highvalue(limit=100)
        hot = C.realtime_hot_phrases()
        bursting = C.realtime_bursting_phrases()

        print 'new'
        for V in high['values']:
            HighPhrases[V] = True
            DB.high_phrase(V.split('bit.ly/')[1],time.time())
            print V, time.time()

        for P in hot:
            phrase = P['phrase']
            HotPhrases[phrase] = sum(map(lambda x:x['visitors'],P['ghashes']))
            DB.hot_phrase(phrase,time.time(),HotPhrases[phrase])
            print phrase, time.time(), HotPhrases[phrase]

        for P in bursting:
            phrase = P['phrase']
            BurstingPhrases[phrase] = sum(map(lambda x:x['visitors'],P['ghashes']))
            DB.bursting_phrase(phrase,time.time(),BurstingPhrases[phrase],P['mean'],P['rate'],P['std'])
            print phrase, time.time(), BurstingPhrases[phrase], P['mean'], P['rate'], P['std']

        errors = 0