def main():

    #for test purpose only
    time_now = datetime.now()
    today = time_now.weekday()
    curr_min = time_now.minute
    my_file = open('data2/noline3/2018-03-23-09-18-00.txt', 'r')
    message = my_file.read()
    stock_pred = StockPrediction()
    print("loading config file...")
    config_obj = ConfigManager()
    print("config_obj loaded")
    sched = Scheduler()
    sched.start()
    #    sched.add_cron_job(schedul_kill, month='1-12', day_of_week=str(today), hour='0-23', minute=curr_min+4, second=time_now.second+4)
    sched.add_cron_job(schedul_kill,
                       year=2018,
                       month=config_obj.get_sch_listener_killer_month(),
                       day_of_week=config_obj.get_sch_listener_killer_day(),
                       hour=config_obj.get_sch_listener_killer_hour(),
                       minute=config_obj.get_sch_listener_killer_minute(),
                       second=config_obj.get_sch_listener_killer_second())

    print('pulling from kafka ...')
    while True:
        sys.stdout.flush()
        json_stock_prediction = stock_pred.run(
            message, 0.5)  # TODO: decide what todo with output
        time.sleep(5)
Exemplo n.º 2
0
def main():
    td = TDClient(apikey=config.API_KEY)

    print('Running Initial Historical Fetch!')

    fetchHistoricalData(td)

    print("Scheduling Fetch Loop!")
    sched = BlockingScheduler()
    sched.add_job(fetchHistoricalData,
                  'cron',
                  args=[td],
                  minute='0-59',
                  second='25')
    sched.start()
Exemplo n.º 3
0
def main():
    print('Running Initial Historical Fetch!')

    fetchTicker()

    dropTables()

    fetchHistoricalData()

    print("Scheduling Fetch Loop!")
    sched = BlockingScheduler()
    sched.add_job(fetchHistoricalData,
                  'cron',
                  args=[],
                  minute='0-59',
                  second='*/5')
    sched.start()
Exemplo n.º 4
0
def main():
    setup()
    curr_min = datetime.now().minute
    # curr_time=int(time.time())
    #  today= datetime.now().weekday()
    #   curr_hour=datetime.now().hour
    sched = Scheduler()
    sched.start()  # start the scheduler

    #sched.add_cron_job(schedul_func, month='1-12', day_of_week=str((today+6)%7), hour=3, minute=15)
    #for test
    sched.add_cron_job(sche_get_from_elastic,
                       month='1-12',
                       day_of_week='0-6',
                       hour='0-23',
                       minute=curr_min + 1,
                       second=4)

    #
    #    #1. scheduler to collect latest news from elasticsearch and store them(Saturdays -2 A.M.)
    #    sched.add_cron_job(sche_get_from_elastic, month='1-12', day_of_week='5', hour='2', minute=1, second=1)
    #
    #    #2. scheduler to clean the news and create training data:news, stockChanges(is automatically collected by separate running process)(Saturdays -2:30 A.M.)
    #    sched.add_cron_job(sche_clean_news_create_train_data, month='1-12', day_of_week='5', hour='2', minute=30, second=1)
    #
    #    #3. scheduler to train a new model and store in dated folder(Saturdays -3 A.M.)
    #    sched.add_cron_job(sche_train_new_model, month='1-12', day_of_week='5', hour='3', minute=1, second=1)
    #
    #    #4. scheduler to delete the pre model and load new process having the latest model(Saturdays -5 A.M.)
    #    sched.add_cron_job(sche_delPre_runLatest, month='1-12', day_of_week='5', hour='5', minute=1, second=1)

    while True:
        sys.stdout.flush()
        #json_stock_prediction =stock_pred.run(message, 0.5)
        #        with open('json_stock_prediction.json','w') as outfile:
        #            json.dump(json_stock_prediction,outfile, indent=4, sort_keys=True)
        time.sleep(5)
Exemplo n.º 5
0
def print_event(name):
    print 'Execute Schedule---->>>>>:', time.time(), name



if __name__ == '__main__':


    print 'START:', time.time()


    # Start the scheduler
    sched = Scheduler()

    sched.start()
    # Store the job in a variable in case we want to cancel it
    job = sched.add_date_job(print_event, t1, ['T1---->'])
    job = sched.add_date_job(print_event, t2, ['T2---->'])
    job = sched.add_date_job(print_event, t3, ['T3---->'])
    job = sched.add_date_job(print_event, t5, ['T5---->'])

    print('schedule list--->:'),sched.get_jobs()

    while True:
        logger.info('This is the main thread.')
        #print('schedule list:'),sched.print_jobs()
        logger.info(sched.get_jobs())
        time.sleep(2)
    # while True:
    #     time.sleep(1)
Exemplo n.º 6
0
                msg += f"в {flight.destination_city}-{flight.destination_airport} за {flight.price} рублей.\n"
                msg += f"Даты: {flight.out_date} ({flight.out_date_weekday})"
                msg += f"- {flight.return_date} ({flight.return_date_weekday}).\n "
                msg += f"Продолжительность {flight.duration_days} д"

                if msg not in msg_cache:
                    data_pack["notification_manager"].send_sms(message=msg)
                    msg_cache.append(msg)


message_cache = []
sched = BlockingScheduler()


def checkflighs_short():
    search_flights(data_package, "short", message_cache)


def checkflights_long():
    search_flights(data_package, "long", message_cache)


def healthcheck():
    notification_manager.send_sms("💟")


sched.add_job(checkflighs_short, 'interval', minutes=5)
sched.add_job(checkflights_long, 'interval', minutes=3)
sched.add_job(healthcheck, 'interval', hours=1)
sched.start()