def download_awr(ctx, output, username, password, project_id): set_parameter_value(ctx, "awr-kw-export-file", output) click.echo("running 'kw-dl-awr' command with:") click.echo("awr_kw_export_file = " + output) awr_cloud_project = get_awr_cloud_project(password, username, project_id) awr_cloud_project.fetch_keywords() rows = [["", "", kw] for kw in awr_cloud_project._keywords] save_csv(output, rows, ["","","keyphrases"]) click.echo("Wrote file '%s'" % output)
def upload_awr(gen_kw_file, username, password, project_id): click.echo("running 'assign_groups' command with:") click.echo("gen-kw-file = " + gen_kw_file) # choose AWR cloud project awr_cloud_project = get_awr_cloud_project(password, username, project_id) # read generated keyphrases file keyphrases, assignations = read_assignations(gen_kw_file) # upload keyphrases confirm_continue("You are going to add %s keyphrases in AWR Cloud. Are you sure ?" % len(keyphrases)) awr_cloud_project.add_keywords(keyphrases) awr_cloud_project.fetch_keywords() # assign groups in AWR cloud confirm_continue("You are going to assign %s groups in AWR Cloud. Are you sure ?" % len(assignations)) assigned_groups = set() awr_cloud_project.fetch_groups() for group, keyphrases in assignations.iteritems(): awr_cloud_project.assign_to_group(keyphrases, group) assigned_groups.add(group) # delete unused groups awr_cloud_project.fetch_groups() unused_groups = awr_cloud_project.determine_unused_groups(assigned_groups) group_list_display = ",\n".join( [ "- " + group.name for group in unused_groups ] ) if (len(unused_groups)!=0): confirm_continue("After assignations, the following %s groups remain unused:\n%s\nDo you want to delete them from AWR Cloud ?" % (len(unused_groups), group_list_display)) awr_cloud_project.delete_groups(unused_groups) click.echo("Successfully imported keywords and groups in AWR Cloud")