def active_serving_watcher(backend, kitchen, period): """ Watches all cooking Recipes in a Kitchen Provide the kitchen name as an argument or be in a Kitchen folder. """ err_str, use_kitchen = Backend.get_kitchen_from_user(kitchen) if use_kitchen is None: raise click.ClickException(err_str) click.secho('%s - Watching Active OrderRun Changes in Kitchen %s' % (get_datetime(), use_kitchen), fg='green') DKCloudCommandRunner.watch_active_servings(backend.dki, use_kitchen, period) while True: try: DKCloudCommandRunner.join_active_serving_watcher_thread_join() if not DKCloudCommandRunner.watcher_running(): break except KeyboardInterrupt: print 'KeyboardInterrupt' exit_gracefully(None, None) exit(0)
def exit_gracefully(signum, frame): # print 'exit_gracefully' # restore the original signal handler as otherwise evil things will happen # in raw_input when CTRL+C is pressed, and our signal handler is not re-entrant DKCloudCommandRunner.stop_watcher() # print 'exit_gracefully stopped watcher' signal(SIGINT, original_sigint) question = False if question is True: try: if input("\nReally quit? (y/n)> ").lower().startswith('y'): exit(1) except (KeyboardInterrupt, SystemExit): print("Ok ok, quitting") exit(1) else: print("Ok ok, quitting now") DKCloudCommandRunner.join_active_serving_watcher_thread_join() exit(1) # restore the exit gracefully handler here signal(SIGINT, exit_gracefully)
def exit_gracefully(signum, frame): # print 'exit_gracefully' # restore the original signal handler as otherwise evil things will happen # in raw_input when CTRL+C is pressed, and our signal handler is not re-entrant DKCloudCommandRunner.stop_watcher() # print 'exit_gracefully stopped watcher' signal(SIGINT, original_sigint) question = False if question is True: try: if raw_input("\nReally quit? (y/n)> ").lower().startswith('y'): exit(1) except (KeyboardInterrupt, SystemExit): print("Ok ok, quitting") exit(1) else: print("Ok ok, quitting now") DKCloudCommandRunner.join_active_serving_watcher_thread_join() exit(1) # restore the exit gracefully handler here signal(SIGINT, exit_gracefully)
def active_serving_watcher(backend, kitchen, period): """ Watches all cooking Recipes in a Kitchen Provide the kitchen name as an argument or be in a Kitchen folder. """ err_str, use_kitchen = Backend.get_kitchen_from_user(kitchen) if use_kitchen is None: raise click.ClickException(err_str) click.secho('%s - Watching Active OrderRun Changes in Kitchen %s' % (get_datetime(), use_kitchen), fg='green') DKCloudCommandRunner.watch_active_servings(backend.dki, use_kitchen, period) while True: try: DKCloudCommandRunner.join_active_serving_watcher_thread_join() if not DKCloudCommandRunner.watcher_running(): break except KeyboardInterrupt: print('KeyboardInterrupt') exit_gracefully(None, None) exit(0)