def recipe_get(backend, recipe): """ Get the latest files for this recipe. """ recipe_root_dir = DKRecipeDisk.find_recipe_root_dir() if recipe_root_dir is None: if recipe is None: raise click.ClickException("\nPlease change to a recipe folder or provide a recipe name arguement") # raise click.ClickException('You must be in a Recipe folder') kitchen_root_dir = DKKitchenDisk.is_kitchen_root_dir() if not kitchen_root_dir: raise click.ClickException("\nPlease change to a recipe folder or a kitchen root dir.") recipe_name = recipe start_dir = DKKitchenDisk.find_kitchen_root_dir() else: recipe_name = DKRecipeDisk.find_recipe_name() if recipe is not None: if recipe_name != recipe: raise click.ClickException("\nThe recipe name argument '%s' is inconsistent with the current directory '%s'" % (recipe, recipe_root_dir)) start_dir = recipe_root_dir kitchen_name = Backend.get_kitchen_name_soft() click.secho("%s - Getting the latest version of Recipe '%s' in Kitchen '%s'" % (get_datetime(), recipe_name, kitchen_name), fg='green') check_and_print(DKCloudCommandRunner.get_recipe(backend.dki, kitchen_name, recipe_name, start_dir))
def file_update_all(backend, message, dryrun): """ Update all of the changed files for this Recipe """ kitchen = DKCloudCommandRunner.which_kitchen_name() if kitchen is None: raise click.ClickException('You must be in a Kitchen') recipe_dir = DKRecipeDisk.find_recipe_root_dir() if recipe_dir is None: raise click.ClickException('You must be in a Recipe folder') recipe = DKRecipeDisk.find_recipe_name() if dryrun: click.secho( '%s - Display all changed files in Recipe (%s) in Kitchen(%s) with message (%s)' % (get_datetime(), recipe, kitchen, message), fg='green') else: click.secho( '%s - Updating all changed files in Recipe (%s) in Kitchen(%s) with message (%s)' % (get_datetime(), recipe, kitchen, message), fg='green') check_and_print( DKCloudCommandRunner.update_all_files(backend.dki, kitchen, recipe, recipe_dir, message, dryrun))
def recipe_get(backend, recipe): """ Get the latest files for this recipe. """ recipe_root_dir = DKRecipeDisk.find_recipe_root_dir() if recipe_root_dir is None: if recipe is None: raise click.ClickException( "\nPlease change to a recipe folder or provide a recipe name arguement" ) # raise click.ClickException('You must be in a Recipe folder') kitchen_root_dir = DKKitchenDisk.is_kitchen_root_dir() if not kitchen_root_dir: raise click.ClickException( "\nPlease change to a recipe folder or a kitchen root dir.") recipe_name = recipe start_dir = DKKitchenDisk.find_kitchen_root_dir() else: recipe_name = DKRecipeDisk.find_recipe_name() if recipe is not None: if recipe_name != recipe: raise click.ClickException( "\nThe recipe name argument '%s' is inconsistent with the current directory '%s'" % (recipe, recipe_root_dir)) start_dir = recipe_root_dir kitchen_name = Backend.get_kitchen_name_soft() click.secho( "%s - Getting the latest version of Recipe '%s' in Kitchen '%s'" % (get_datetime(), recipe_name, kitchen_name), fg='green') check_and_print( DKCloudCommandRunner.get_recipe(backend.dki, kitchen_name, recipe_name, start_dir))
def recipe_conflicts(backend): """ See if there are any unresolved conflicts for this recipe. """ recipe_dir = DKRecipeDisk.find_recipe_root_dir() if recipe_dir is None: raise click.ClickException('You must be in a Recipe folder.') click.secho("%s - Checking for conflicts on Recipe '%s'" % ( get_datetime(),recipe_name)) recipe_name = DKRecipeDisk.find_recipe_name() check_and_print(DKCloudCommandRunner.get_unresolved_conflicts(recipe_name, recipe_dir))
def recipe_conflicts(backend): """ See if there are any unresolved conflicts for this recipe. """ recipe_dir = DKRecipeDisk.find_recipe_root_dir() if recipe_dir is None: raise click.ClickException('You must be in a Recipe folder.') recipe_name = DKRecipeDisk.find_recipe_name() click.secho("%s - Checking for conflicts on Recipe '%s'" % (get_datetime(), recipe_name)) recipe_name = DKRecipeDisk.find_recipe_name() check_and_print( DKCloudCommandRunner.get_unresolved_conflicts(recipe_name, recipe_dir))
def recipe_status(backend): """ Compare local recipe to remote recipe for the current recipe. """ kitchen = DKCloudCommandRunner.which_kitchen_name() if kitchen is None: raise click.ClickException('You are not in a Kitchen') recipe_dir = DKRecipeDisk.find_recipe_root_dir() if recipe_dir is None: raise click.ClickException('You must be in a Recipe folder') recipe_name = DKRecipeDisk.find_recipe_name() click.secho("%s - Getting the status of Recipe '%s' in Kitchen '%s'\n\tversus directory '%s'" % ( get_datetime(), recipe_name, kitchen, recipe_dir), fg='green') check_and_print(DKCloudCommandRunner.recipe_status(backend.dki, kitchen, recipe_name, recipe_dir))
def recipe_status(backend): """ Compare local recipe to remote recipe for the current recipe. """ kitchen = DKCloudCommandRunner.which_kitchen_name() if kitchen is None: raise click.ClickException('You are not in a Kitchen') recipe_dir = DKRecipeDisk.find_recipe_root_dir() if recipe_dir is None: raise click.ClickException('You must be in a Recipe folder') recipe_name = DKRecipeDisk.find_recipe_name() click.secho( "%s - Getting the status of Recipe '%s' in Kitchen '%s'\n\tversus directory '%s'" % (get_datetime(), recipe_name, kitchen, recipe_dir), fg='green') check_and_print( DKCloudCommandRunner.recipe_status(backend.dki, kitchen, recipe_name, recipe_dir))
def file_update_all(backend, message, dryrun): """ Update all of the changed files for this Recipe """ kitchen = DKCloudCommandRunner.which_kitchen_name() if kitchen is None: raise click.ClickException('You must be in a Kitchen') recipe_dir = DKRecipeDisk.find_recipe_root_dir() if recipe_dir is None: raise click.ClickException('You must be in a Recipe folder') recipe = DKRecipeDisk.find_recipe_name() if dryrun: click.secho('%s - Display all changed files in Recipe (%s) in Kitchen(%s) with message (%s)' % (get_datetime(), recipe, kitchen, message), fg='green') else: click.secho('%s - Updating all changed files in Recipe (%s) in Kitchen(%s) with message (%s)' % (get_datetime(), recipe, kitchen, message), fg='green') check_and_print(DKCloudCommandRunner.update_all_files(backend.dki, kitchen, recipe, recipe_dir, message, dryrun))
def get_recipe_name(recipe): in_recipe = DKRecipeDisk.find_recipe_name() if recipe is None and in_recipe is None: raise click.ClickException("You must provide a recipe name or be in a recipe folder.") elif recipe is not None and in_recipe is not None: raise click.ClickException( "Please provide a recipe parameter or change directory to a recipe folder, not both.\nYou are in Recipe '%s'" % in_recipe) if in_recipe is not None: use_recipe = in_recipe else: use_recipe = recipe return "ok", use_recipe
def file_resolve(backend, filepath): """ Mark a conflicted file as resolved, so that a merge can be completed """ recipe = DKRecipeDisk.find_recipe_name() if recipe is None: raise click.ClickException('You must be in a recipe folder.') click.secho("%s - Resolving conflicts" % get_datetime()) for file_to_resolve in filepath: if not os.path.exists(file_to_resolve): raise click.ClickException('%s does not exist' % file_to_resolve) check_and_print(DKCloudCommandRunner.resolve_conflict(file_to_resolve))
def file_delete(backend, kitchen, recipe, message, filepath): """ Delete a Recipe file. Provide the file name and path to the file name, relative to the recipe root """ err_str, use_kitchen = Backend.get_kitchen_from_user(kitchen) if use_kitchen is None: raise click.ClickException(err_str) if recipe is None: recipe = DKRecipeDisk.find_recipe_name() if recipe is None: raise click.ClickException('You must be in a recipe folder, or provide a recipe name.') click.secho('%s - Deleting (%s) in Recipe (%s) in kitchen(%s) with message (%s)' % (get_datetime(), filepath, recipe, use_kitchen, message), fg='green') check_and_print(DKCloudCommandRunner.delete_file(backend.dki, use_kitchen, recipe, message, filepath))
def file_add(backend, kitchen, recipe, message, filepath): """ Add a newly created file to a Recipe """ err_str, use_kitchen = Backend.get_kitchen_from_user(kitchen) if use_kitchen is None: raise click.ClickException(err_str) if recipe is None: recipe = DKRecipeDisk.find_recipe_name() if recipe is None: raise click.ClickException('You must be in a recipe folder, or provide a recipe name.') click.secho('%s - Adding File (%s) to Recipe (%s) in kitchen(%s) with message (%s)' % (get_datetime(), filepath, recipe, use_kitchen, message), fg='green') check_and_print(DKCloudCommandRunner.add_file(backend.dki, use_kitchen, recipe, message, filepath))
def get_recipe_name(recipe): in_recipe = DKRecipeDisk.find_recipe_name() if recipe is None and in_recipe is None: raise click.ClickException( "You must provide a recipe name or be in a recipe folder.") elif recipe is not None and in_recipe is not None: raise click.ClickException( "Please provide a recipe parameter or change directory to a recipe folder, not both.\nYou are in Recipe '%s'" % in_recipe) if in_recipe is not None: use_recipe = in_recipe else: use_recipe = recipe return "ok", use_recipe
def recipe_compile(backend, kitchen, recipe, variation): """ Apply variables to a Recipe """ err_str, use_kitchen = Backend.get_kitchen_from_user(kitchen) if use_kitchen is None: raise click.ClickException(err_str) if recipe is None: recipe = DKRecipeDisk.find_recipe_name() if recipe is None: raise click.ClickException('You must be in a recipe folder, or provide a recipe name.') click.secho('%s - Get the Compiled OrderRun of Recipe %s.%s in Kitchen %s' % (get_datetime(), recipe, variation, use_kitchen), fg='green') check_and_print(DKCloudCommandRunner.get_compiled_serving(backend.dki, use_kitchen, recipe, variation))
def order_run(backend, kitchen, recipe, variation, node): """ Run an order: cook a recipe variation """ err_str, use_kitchen = Backend.get_kitchen_from_user(kitchen) if use_kitchen is None: raise click.ClickException(err_str) if recipe is None: recipe = DKRecipeDisk.find_recipe_name() if recipe is None: raise click.ClickException('You must be in a recipe folder, or provide a recipe name.') msg = '%s - Create an Order:\n\tKitchen: %s\n\tRecipe: %s\n\tVariation: %s\n' % (get_datetime(), use_kitchen, recipe, variation) if node is not None: msg += '\tNode: %s\n' % node click.secho(msg, fg='green') check_and_print(DKCloudCommandRunner.create_order(backend.dki, use_kitchen, recipe, variation, node))
def file_delete(backend, kitchen, recipe, message, filepath): """ Delete a Recipe file. Provide the file name and path to the file name, relative to the recipe root """ err_str, use_kitchen = Backend.get_kitchen_from_user(kitchen) if use_kitchen is None: raise click.ClickException(err_str) if recipe is None: recipe = DKRecipeDisk.find_recipe_name() if recipe is None: raise click.ClickException( 'You must be in a recipe folder, or provide a recipe name.') click.secho( '%s - Deleting (%s) in Recipe (%s) in kitchen(%s) with message (%s)' % (get_datetime(), filepath, recipe, use_kitchen, message), fg='green') check_and_print( DKCloudCommandRunner.delete_file(backend.dki, use_kitchen, recipe, message, filepath))
def file_add(backend, kitchen, recipe, message, filepath): """ Add a newly created file to a Recipe """ err_str, use_kitchen = Backend.get_kitchen_from_user(kitchen) if use_kitchen is None: raise click.ClickException(err_str) if recipe is None: recipe = DKRecipeDisk.find_recipe_name() if recipe is None: raise click.ClickException( 'You must be in a recipe folder, or provide a recipe name.') click.secho( '%s - Adding File (%s) to Recipe (%s) in kitchen(%s) with message (%s)' % (get_datetime(), filepath, recipe, use_kitchen, message), fg='green') check_and_print( DKCloudCommandRunner.add_file(backend.dki, use_kitchen, recipe, message, filepath))
def recipe_compile(backend, kitchen, recipe, variation): """ Apply variables to a Recipe """ err_str, use_kitchen = Backend.get_kitchen_from_user(kitchen) if use_kitchen is None: raise click.ClickException(err_str) if recipe is None: recipe = DKRecipeDisk.find_recipe_name() if recipe is None: raise click.ClickException( 'You must be in a recipe folder, or provide a recipe name.') click.secho( '%s - Get the Compiled OrderRun of Recipe %s.%s in Kitchen %s' % (get_datetime(), recipe, variation, use_kitchen), fg='green') check_and_print( DKCloudCommandRunner.get_compiled_serving(backend.dki, use_kitchen, recipe, variation))
def order_run(backend, kitchen, recipe, variation, node): """ Run an order: cook a recipe variation """ err_str, use_kitchen = Backend.get_kitchen_from_user(kitchen) if use_kitchen is None: raise click.ClickException(err_str) if recipe is None: recipe = DKRecipeDisk.find_recipe_name() if recipe is None: raise click.ClickException( 'You must be in a recipe folder, or provide a recipe name.') msg = '%s - Create an Order:\n\tKitchen: %s\n\tRecipe: %s\n\tVariation: %s\n' % ( get_datetime(), use_kitchen, recipe, variation) if node is not None: msg += '\tNode: %s\n' % node click.secho(msg, fg='green') check_and_print( DKCloudCommandRunner.create_order(backend.dki, use_kitchen, recipe, variation, node))