def import_data(self): if len(sys.argv) < 2: self.logger.logln("no product") return product = sys.argv[1] start_id = 0 if len(sys.argv) >= 3: start_id = int(sys.argv[2]) recreate_index = True if len(sys.argv) >= 4: if sys.argv[3] == "1" or sys.argv[3] == "True" or sys.argv[3] == "true": recreate_index = True else: recreate_index = False dates = [] if len(sys.argv) <= 4: dates.append( str(datetime.now().date()) ) else: i = 4 while i < len(sys.argv): dates.append( str(sys.argv[i]) ) i += 1 if len(dates) == 0: self.logger.logln("no dates") return kibana = Kibana(self.logger.logln) for date in dates: kibana.import_data(date, product, start_id, recreate_index)
def import_data(self): if len(sys.argv) < 2: self.logger.logln("no product") return product = sys.argv[1] start_id = 0 if len(sys.argv) >= 3: start_id = int(sys.argv[2]) recreate_index = True if len(sys.argv) >= 4: if sys.argv[3] == "1" or sys.argv[3] == "True" or sys.argv[ 3] == "true": recreate_index = True else: recreate_index = False dates = [] if len(sys.argv) <= 4: dates.append(str(datetime.now().date())) else: i = 4 while i < len(sys.argv): dates.append(str(sys.argv[i])) i += 1 if len(dates) == 0: self.logger.logln("no dates") return kibana = Kibana(self.logger.logln) for date in dates: kibana.import_data(date, product, start_id, recreate_index)
def import_data(self): try: #yesterday = '2016-10-22' yesterday = date.today() - timedelta(1) names = self._read_config() kibana = Kibana(self.logger.logln) for name in names: kibana.import_data(str(yesterday), name, 0, True) self.logger.logln("SUCCESS.") except BaseException as e: exc_type, exc_value, exc_traceback = sys.exc_info() self.logger.logln("Exception " + str(e)) for line in traceback.format_tb(exc_traceback): self.logger.log(line)
def loop(self): if self.date == datetime.now().date(): self.logger.logln("sleep" + str(datetime.today().time())) sleep(60 * 60) return if self.time > datetime.today().time(): self.logger.logln("sleep" + str(datetime.today().time())) sleep(60 * 60) return kibana = Kibana() recreate_index = True for product in self.products: kibana.import_data(str(self.date), product, 0, recreate_index) recreate_index = False self.date = datetime.today().date()
def loop(self): if self.date == datetime.now().date(): self.logger.logln("sleep"+str(datetime.today().time())) sleep(60*60) return if self.time > datetime.today().time(): self.logger.logln("sleep"+str(datetime.today().time())) sleep(60*60) return kibana = Kibana() recreate_index = True for product in self.products: kibana.import_data( str(self.date), product, 0, recreate_index ) recreate_index = False self.date = datetime.today().date()
def import_data(self): try: cur_time = gmtime(time() - 1*60*60 + 10) names = self._read_config() kibana = Kibana(self.logger.logln) kibana.set_beg_time( strftime('%H:00:00', cur_time) ) kibana.set_end_time( strftime('%H:59:59', cur_time) ) recreate_index = True if int(strftime('%H')) < 10: kibana.set_beg_time( None ) else: recreate_index = False for name in names: kibana.import_data( str(date.today()), name, 0, recreate_index ) self.logger.logln("SUCCESS.") except BaseException as e: exc_type, exc_value, exc_traceback = sys.exc_info() self.logger.logln("Exception " + str(e)) for line in traceback.format_tb(exc_traceback): self.logger.log(line)