Esempio n. 1
0
def update(args):
    """Run all modules"""

    exit_codes = []

    # Start time of update
    update_start = time.time()

    # Clean output/content directory if flag is set
    if args.clean:
        generate.clean_website()

    # Grab shared resources and stix data
    if args.build:
        get_stix_data(args)
        generate.grab_resources()

    # Generate index markdown
    if args.build:
        generate.index_md_gen()

    # Generate group markdowns
    if args.build:
        if 'groups' in args.build:
            generate.group_md_gen()

    # Software markdown generation
    if args.build:
        if 'software' in args.build:
            generate.software_md_gen()

    # Generate technique markdowns
    if args.build:
        if 'techniques' in args.build:
            generate.technique_md_gen()

    # Generate matrix markdowns
    if args.build:
        if 'matrices' in args.build:
            generate.matrix_md_gen()

    # Generate tactic markdowns
    if args.build:
        if 'tactics' in args.build:
            generate.tactic_md_gen()

    # Generate mitigation markdowns
    if args.build:
        if 'mitigations' in args.build:
            generate.mitigation_md_gen()

    # Generate contribute markdowns
    if args.build:
        if 'contribute' in args.build:
            generate.contribute_md_gen()

    # Generate resources markdowns
    if args.build:
        if 'resources' in args.build:
            generate.resources_md_gen()

    # Generate redirects markdowns
    if args.build:
        if 'redirects' in args.build:
            generate.redirects_md_gen()

    # Generate Index
    if args.build:
        if 'search' in args.build:
            generate.generate_search_index()

    # Deploy previous version
    if args.build:
        if 'prev_versions' in args.build:
            generate.previous_versions_gen()

    # Pelican update
    if args.build:
        generate.pelican_content()
        # Remove unwanted files created by pelican
        generate.remove_unwanted_output()

    if args.build:
        build_end = time.time()
        build_time = build_end - update_start

    # Tests
    if (args.build and
        (sorted(args.build) == sorted(config.build_defaults))) or args.tests:
        # Start time of tests update
        test_start = time.time()
        exit_codes = tests.run_tests(args)
        test_end = time.time()
        test_time = test_end - test_start

    if args.build and ((sorted(args.build) == sorted(config.build_defaults))
                       or args.tests):
        util.progress_bar("TOTAL Build Time", build_time)
        util.progress_bar("TOTAL Test Time", test_time)

    update_end = time.time()
    util.progress_bar("TOTAL Update Time", update_end - update_start)

    if not args.override_exit_status:
        handle_exit(exit_codes)
Esempio n. 2
0
def update(args):
    """Run all modules"""

    exit_codes = []

    # Start time of update
    update_start = time.time()

    # Clean output/content directory if flag is set
    if args.clean:
        generate.clean_website()    

    # Grab shared resources and stix data
    if args.build:
        get_stix_data(args)
        generate.grab_resources()

    # Set website path with subdirectory
    if args.subdirectory:
        config.set_subdirectory(args.subdirectory)

    # Generate index markdown
    if args.build:
        generate.index_md_gen()
        generate.tour_gen()

    # Generate group markdowns
    if args.build:
        if 'groups' in args.build:
            generate.group_md_gen()

    # Software markdown generation
    if args.build:
        if 'software' in args.build:
            generate.software_md_gen()

    # Generate technique markdowns
    if args.build:
        if 'techniques' in args.build:
            generate.technique_md_gen()

    # Generate matrix markdowns
    if args.build:
        if 'matrices' in args.build:
            generate.matrix_md_gen()

    # Generate tactic markdowns
    if args.build:
        if 'tactics' in args.build:
            generate.tactic_md_gen()

    # Generate mitigation markdowns
    if args.build:
        if 'mitigations' in args.build:
            generate.mitigation_md_gen()

    # Generate contribute markdowns
    if args.build:
        if 'contribute' in args.build:
            generate.contribute_md_gen()
    
    # Generate resources markdowns
    if args.build:
        if 'resources' in args.build:
            generate.resources_md_gen()
        
    # Generate redirects markdowns
    if args.build:
        if 'redirects' in args.build:
            generate.redirects_md_gen()

    # Set website path with subdirectory
    if args.subdirectory:
        config.set_subdirectory(args.subdirectory)

    # Deploy versions
    if args.build:
        if 'versions' in args.build:
    	    generate.previous_versions_gen()

    # Pelican update
    if args.build:
        generate.pelican_content()
        # Remove unwanted files created by pelican
        generate.remove_unwanted_output()

    # Generate search index
    # note: this should come basically last in the build process
    # because it parses the content of the output directory to build the index
    if args.build:
        if 'search' in args.build:
    	    generate.generate_search_index()
    
    # Preserve current version
    if args.build:
        if 'versions' in args.build:
            generate.deploy_current_version()

    # Replace output directory links with subdirectory
    if args.subdirectory:
        generate.subdirectory_gen()

    if args.build:
        build_end = time.time()
        build_time = build_end - update_start
    
    # Tests
    if (args.build and (sorted(args.build) == sorted(config.build_defaults))) or args.tests:
        # Start time of tests update
        test_start = time.time()
        exit_codes = tests.run_tests(args)
        test_end = time.time()
        test_time = test_end - test_start
    
    if args.build and ((sorted(args.build) == sorted(config.build_defaults)) or args.tests):
        util.progress_bar("TOTAL Build Time", build_time)
        util.progress_bar("TOTAL Test Time", test_time)
    
    update_end = time.time()
    util.progress_bar("TOTAL Update Time", update_end - update_start)

    if not args.override_exit_status:
        handle_exit(exit_codes)