def get_stock_index(self, name): today = stockutils.get_date().split('-') start = stockconfig.FIG_START_DAY.split('-') start_year = string.atoi(start[0]) start_jidu = (string.atoi(start[1]) + 2) / 3 end_year = string.atoi(today[0]) end_jidu = (string.atoi(today[1]) + 2) / 3 index = [] while True: data = self.__get_stock_index_jidu(name, start_year, start_jidu) index.extend(data) if(start_year == end_year) and (start_jidu == end_jidu): break; start_year, start_jidu = stockutils.next_jidu(start_year, start_jidu) return index
def get_stock_index(self, name): today = stockutils.get_date().split('-') start = stockconfig.FIG_START_DAY.split('-') start_year = string.atoi(start[0]) start_jidu = (string.atoi(start[1]) + 2) / 3 end_year = string.atoi(today[0]) end_jidu = (string.atoi(today[1]) + 2) / 3 index = [] while True: data = self.__get_stock_index_jidu(name, start_year, start_jidu) index.extend(data) if (start_year == end_year) and (start_jidu == end_jidu): break start_year, start_jidu = stockutils.next_jidu( start_year, start_jidu) return index
def looper(self): last_jidu_update_day = '0000-00-00' task_list = [] while self.started == True: today = stockutils.get_date() last = self.db.get_last_update_day() if cmp(today, last): next = self.__get_next_day(last) if next != '': update_jidu = False current_jidu = self.__is_same_jidu(next, today) same_jidu = self.__is_same_jidu(next, last_jidu_update_day) if current_jidu == True or same_jidu == False: list = self.parser.get_stock_list() task_list = self.__splite_task(list) last_jidu_update_day = next update_jidu = True self.__real_update(task_list, next, update_jidu) self.db.update_last_update_day(next) else: time.sleep(1800) else: time.sleep(1800)