示例#1
0
文件: bot_cctv11.py 项目: I0T/EPGT
def main():
    run_queue = Queue(50)

    processes = [
        Process(target=run_task, args=(run_queue, )) for i in range(20)
    ]
    for p in processes:
        p.daemon = True
        p.start()

    signal.signal(signal.SIGTERM, SignalTERM)

    db = getDb()
    channel_list = db.query(
        'SELECT * FROM channel where code="cctv11" ORDER BY id').fetchall()
    channel_len = len(channel_list)
    i = 1
    for channel in channel_list:
        while run_queue.full():
            # 若任务队列已满,则等待
            time.sleep(3)
        config = channel['config']
        try:
            config = json.loads(config)
            run_queue.put({'code': channel['code'], 'config': config})
            print 'Queue: %s/%s' % (i, channel_len)
            i = i + 1
        except:
            print 'error'
            print config

    for i in range(20):
        run_queue.put("STOP")
    for p in processes:
        p.join()
示例#2
0
文件: bot-zjws.py 项目: I0T/EPGT
def main():
    run_queue = Queue(50)
    
    processes = [Process(target=run_task, args=(run_queue,))
                     for i in range(20)]
    for p in processes:
        p.daemon = True
        p.start()
    
    signal.signal(signal.SIGTERM, SignalTERM)

    db = getDb()
    channel_list = db.query('SELECT * FROM channel where where id = 833 ORDER BY id').fetchall()
    channel_len = len(channel_list)
    i = 1
    for channel in channel_list:
        while run_queue.full():
            # 若任务队列已满,则等待
            time.sleep(3)
        config = channel['config']
        try:
            config = json.loads(config)
            run_queue.put({'code': channel['code'], 'config': config, 'type': channel['type'], 'province': channel['province'], 'city': channel['city']})
            print 'Queue: %s/%s' % (i, channel_len)
            i = i + 1
        except:
            print 'error'
            print config

    for i in range(20):
        run_queue.put("STOP")
    for p in processes:
        p.join()
示例#3
0
 def __init__(self, channel_code, config, type, province, city):
     self.channel_code = channel_code
     self.config = config
     self.channel_type = []
     if type:
         self.channel_type.append(type)
     if province:
         self.channel_type.append(province)
     if city:
         self.channel_type.append(city)
     self.db = getDb()
     self.init_mongo()
示例#4
0
文件: bot_one.py 项目: I0T/EPGT
def main():
    channel_code = ''
    for argv in sys.argv:
        argva = argv.split("=")
        if (argva[0] == "-channel_id"):
            channel_code = argva[1]

    if channel_code == '':
        print "error"
        sys.exit()

    run_queue = Queue(50)

    processes = [
        Process(target=run_task, args=(run_queue, )) for i in range(20)
    ]
    for p in processes:
        p.daemon = True
        p.start()

    signal.signal(signal.SIGTERM, SignalTERM)

    db = getDb()
    channel_list = db.query('SELECT * FROM channel where id="' + channel_code +
                            '" ORDER BY id').fetchall()
    channel_len = len(channel_list)
    i = 1
    for channel in channel_list:
        while run_queue.full():
            # 若任务队列已满,则等待
            time.sleep(3)
        config = channel['config']
        try:
            config = json.loads(config)
            run_queue.put({
                'code': channel['code'],
                'config': config,
                'type': channel['type'],
                'province': channel['province'],
                'city': channel['city']
            })
            print 'Queue: %s/%s' % (i, channel_len)
            i = i + 1
        except:
            print 'error'
            print config

    for i in range(20):
        run_queue.put("STOP")
    for p in processes:
        p.join()
示例#5
0
文件: wiki_bot.py 项目: I0T/EPGT
    def __init__(self, tvsou_id, name):
        self.tvsou_id = tvsou_id
        self.dir_id = self.getDirId()
        self.name = ''
        self.oname = ''

        name = name.decode('gb18030', 'ignore').encode('utf-8')
        names = name.split(',', 1)
        self.name = names[0].strip()
        if len(names) > 1:
            self.oname = names[1]

        self.db = getDb()
        self.wiki_id = '';
示例#6
0
文件: wiki_bot.py 项目: I0T/EPGT
    def __init__(self, tvsou_id, name):
        self.tvsou_id = tvsou_id
        self.dir_id = self.getDirId()
        self.name = ''
        self.oname = ''

        name = name.decode('gb18030', 'ignore').encode('utf-8')
        names = name.split(',', 1)
        self.name = names[0].strip()
        if len(names) > 1:
            self.oname = names[1]

        self.db = getDb()
        self.wiki_id = ''
示例#7
0
 def __init__(self, channel_code, config):
     self.channel_code = channel_code
     self.config = config
     self.db = getDb()
     self.init_mongo()
示例#8
0
文件: sina_actor.py 项目: I0T/EPGT
 def __init__(self):
     self.db = getDb()
     self.init_mongo()
示例#9
0
文件: sina_actor.py 项目: I0T/EPGT
 def __init__(self):
     self.db = getDb()
     self.init_mongo()
示例#10
0
文件: base_test.py 项目: I0T/EPGT
 def __init__(self, channel_code, config):
     self.channel_code = channel_code
     self.config = config
     self.db = getDb()
     self.init_mongo()