Ejemplo n.º 1
0
def main():
    socket.setdefaulttimeout(60)
    mainDir = "/run/media/soldier/eea1ee1d-e5c4-4534-9e0b-24308315e271/pynews"
    tweetsDir = os.path.join(mainDir, "stream", "tweets")
    logger.info("Start app")
    model = None
    try:
        gui = Gui()
        mgr = StreamMgr(tweetsDir)
        model = Model(gui, stream=mgr.restore(lastOnly=False), mainDir=mainDir)
    except BaseException:
        logger.exception("Cannot start app")
        if model:
            model.stop()
        sys.exit(1)
        return
    gui.run()
    model.stop()
    logger.info("Exit app")
Ejemplo n.º 2
0
import os
from save import Manager


if __name__ == "__main__":
    mainDir="/media/eea1ee1d-e5c4-4534-9e0b-24308315e271/pynews"
    tweetsDir = os.path.join(mainDir, "stream", "tweets")
    mgr = Manager(tweetsDir)
    stream = mgr.restore(lastOnly=True)
    all = 0
    text = 0
    url = 0
    for t in stream:
        all += 1
        if 'text' in t:
            text += 1
            entities = t['entities']
            if 'urls' in entities and entities['urls'] or 'media' in entities and entities['media']:
                url+=1

    print("ALL: %d TEXT: %d URL: %d" % (all, text, url))

Ejemplo n.º 3
0
# -*- coding: utf-8 *-*
import os
from logger import logger
from save import Manager as StreamMgr

mainDir="/media/eea1ee1d-e5c4-4534-9e0b-24308315e271/tweets-test"
mgr = StreamMgr(mainDir)
s = mgr.restore(lastOnly=False)
c = -1
for t in s:
    #logger.info(t)
    c += 1
    if "retweeted_status" in t and t[u"retweeted_status"][u"retweet_count"] > 0 and len(t[u"retweeted_status"][u"entities"][u"urls"]) > 0:
        urls = t[u"retweeted_status"][u"entities"][u"urls"]
        logger.info(str(t[u"retweeted_status"][u"retweet_count"]) + " " + str([url["expanded_url"] for url in urls if url["expanded_url"]]))
    if c % 1000 == 0:
        logger.info("Done: " + str(c))