def notifier(): artists_list = get_grouplist() data = get_today_data(artists_list) for item in data: print(item) additional_second = 0 while len(data) > 0: event_timedelta = data[0][1] event_timedelta += datetime.timedelta(seconds=additional_second) event_time = get_time(event_timedelta) print('Next event time:', event_time) def job(event_time=event_time): print('Event at {}'.format(event_time)) send_notification(data[0]) return schedule.CancelJob schedule.every().day.at(event_time).do(job).tag('kpop-release') while True: schedule.run_pending_tag('kpop-release') time.sleep(1) if len(schedule.jobs) == 2: # jobs with 'run' tag break data.pop(0) additional_second += 5
def run_prediction(pickup_addr_latlong, dropoff_addr_latlong, passenger_count, predict_type): if predict_type == "fare": print("\nfare\n") pred_df = create_predict_dataframe(pickup_addr_latlong, dropoff_addr_latlong, passenger_count, "fare") print(pred_df.head()) fare = get_fare(pred_df) print( "Running prediction from pickup: {} tp dropoff: {} for {} passengers" .format(pickup_addr_latlong, dropoff_addr_latlong, passenger_count)) return fare else: print("\nfare\n") pred_df = create_predict_dataframe(pickup_addr_latlong, dropoff_addr_latlong, passenger_count, "time") print(pred_df.head()) time = get_time(pred_df) time = float(time) / 60.0 return time ## call return 10
def chat_broadcasting(received_json): print(received_json) message = transform_html_keywords(received_json) if (len(message[0]) > 240): emit( 'chat response', { 'data': [ 'the message is too long, please retype a shorter one.', 'system', get_time() ] }) return add_a_chat_message(message) emit('chat response', {'data': message}, broadcast=True)
async def api_blog_edit(id, request, *, name, summary, content): check_admin(request) if not name or not name.strip(): raise APIValueError('name', '标题不能为空') if not summary or not summary.strip(): raise APIValueError('summary', '摘要不能为空') if not content or not content.strip(): raise APIValueError('content', '内容不能为空') blog = Blog(user_id=request.__user__.id, user_name=request.__user__.name, user_image=request.__user__.image, name=name.strip(), summary=summary.strip(), content=content.strip()) sql = 'UPDATE `blogs` SET `name` = "%s", `summary` = "%s", `content` = "%s", `update_time` = "%s" WHERE `id` = %s'\ % (name.strip(), summary.strip(), content.strip(), get_time(), id) print(sql) await blog.sql_execute(sql) return blog
def connect(): emit('chat response', {'data': ['welcome to chart3!', 'system', get_time()]})
def chat_broadcasting(received_json): print (received_json) message = transform_html_keywords(received_json) if (len(message[0])>240): emit('chat response', {'data':['the message is too long, please retype a shorter one.', 'system', get_time()]}) return add_a_chat_message(message) emit('chat response', {'data':message}, broadcast = True)
def connect(): emit('chat response', {'data':['welcome to chart3!','system', get_time()]})