Exemplo n.º 1
0
    def run(self):
        # Daemona kapanma emri verilirse dongu sona erecek. Kapanma emri
        # verilip verilmedigini RUNFILE'in varligindan anliyoruz. Dosya varsa
        # calismaya devam et.
        while exists(RUNFILE):
            global cnn
            global crs
            try:
                (cnn, crs) = f.refresh_psql_connection(cnn, crs)
                sql = """
                update task set islive = 1 where id = %s;
                """
                par = (TID,)
                crs.execute(sql, par)
                cnn.commit()
            except:
                cnn.rollback()
                if DEBUG:
                    raise

            try:
                stream.statuses.filter(track=KEYWORD)
            except Exception as err:
                if DEBUG:
                    raise
                else:
                    sys.stderr.write('%s\n' % (err))
            time.sleep(.5)
Exemplo n.º 2
0
    def run(self):
        # Daemona kapanma emri verilirse dongu sona erecek. Kapanma emri
        # verilip verilmedigini RUNFILE'in varligindan anliyoruz. Dosya varsa
        # calismaya devam et.
        while exists(RUNFILE):
            cnn = crs = None
            try:

                (cnn, crs) = f.refresh_psql_connection(cnn, crs)
                for (keyword, tid) in get_tasklist(crs):
                    try:
                        sql = """
                        update task set isended = 2 where id = %s;
                        """
                        par = (tid, )
                        crs.execute(sql, par)
                        cnn.commit()
                    except:
                        cnn.rollback()
                    taskStart(keyword, tid)


            except Exception as err:
                if DEBUG:
                    raise
                else:
                    sys.stderr.write('%s\n' % (err))
            time.sleep(.5)
Exemplo n.º 3
0
    def on_success(self, data):
        global cnn
        global crs
        (cnn, crs) = f.refresh_psql_connection(cnn, crs)
        try:

            sql = """
            insert into tweet_stream (task, tweet ,isread) values (%s,%s,0)
            """
            par = (TID, json.dumps(data))
            crs.execute(sql, par)
            cnn.commit()
        except:
            cnn.rollback()
            if DEBUG:
                raise
            pass
Exemplo n.º 4
0
    def run(self):
        # Daemona kapanma emri verilirse dongu sona erecek. Kapanma emri
        # verilip verilmedigini RUNFILE'in varligindan anliyoruz. Dosya varsa
        # calismaya devam et.
        while exists(RUNFILE):
            cnn = crs = None
            try:

                (cnn, crs) = f.refresh_psql_connection(cnn, crs)
                for (keyword, tid) in get_tasklist(crs):
                    taskStart(keyword, tid)


            except Exception as err:
                if DEBUG:
                    raise
                else:
                    sys.stderr.write('%s\n' % (err))
            time.sleep(.5)