Esempio n. 1
0
    def dispatch(self):
        kldms = self.fetch_kldms()
        if len(kldms) == 2:
            self.kldms = kldms
        # data_tmp = {'wclx': 1, 'score': 0, 'bkcc': 1, 'kldm': 1, 'years': 15, 'type': 'score'}
        for kldm in self.kldms:
            self.minscore[str(kldm)] = -1
        if self.recover:
            with open(self.prefix + '_undo_jobs_old', 'r') as job_saver:
                job_saver = LinkSaver(self.prefix + '_undo_jobs_old', 'r')
                lines = job_saver.readlines()
                job_saver.close()
                for l in lines:
                    self.add_main_job(eval(l))
                print 'recover %d jobs' % len(lines)
        else:
            bkccs = [1, 2]  # 本科,专科
            for kldm in self.kldms:
                for bkcc in bkccs:
                    for score in range(self.highscore, -1, -1):
                        data = {
                            'wclx': 1,
                            'score': score,
                            'bkcc': bkcc,
                            'kldm': kldm,
                            'years': 15
                        }
                        self.add_main_job({'data': data, 'type': 'score'})

        time.sleep(2)
        self.wait_q()
        self.add_job(None)
Esempio n. 2
0
    def dispatch(self):
        kldms = self.fetch_kldms()
        if len(kldms) == 2:
            self.kldms[0] = str(kldms[0])
            self.kldms[1] = str(kldms[1])
        # data_tmp = {'wclx': 1, 'score': 0, 'bkcc': 1, 'kldm': 1, 'years': 15, 'type': 'score'}
        for kldm in self.kldms:
            self.min_score_arr[str(kldm)] = -1
        if self.recover:
            job_saver = LinkSaver(self.prefix + '_undo_jobs_old', 'r')
            lines = job_saver.readlines()
            job_saver.close()
            for l in lines:
                self.add_main_job(eval(l.strip()))
            print 'recover %d jobs' % len(lines)
        else:
            bkccs = [1, 2]  # 本科,专科
            mid_score = self.min_score + (self.highscore -
                                          self.min_score) * 3 / 4
            for score in range(
                    0,
                    max(self.highscore - mid_score,
                        mid_score - self.min_score)):
                up_score = mid_score + score
                down_score = mid_score - score - 1
                for kldm in self.kldms:
                    for bkcc in bkccs:
                        if up_score <= self.highscore:
                            data = {
                                'wclx': 1,
                                'score': up_score,
                                'bkcc': bkcc,
                                'kldm': kldm,
                                'years': 15
                            }
                            self.add_main_job({'data': data, 'type': 'score'})
                        if down_score >= self.min_score and down_score > 0:
                            data = {
                                'wclx': 1,
                                'score': down_score,
                                'bkcc': bkcc,
                                'kldm': kldm,
                                'years': 15
                            }
                            self.add_main_job({'data': data, 'type': 'score'})

        time.sleep(2)
        self.wait_q()
        self.add_job(None)