def main_function():
    # check we are in the correct folder and complain and exit if we are not
    check_cwd()

    # get a list of header files
    headers = get_headers()
    # get a list of source files
    sources = get_sources()

    # keep only pathname with tests_filename.cpp in them
    sources = keep_tests(sources)

    # extract names for mtl classes and functions from the test files
    documentation = generate_documentation(sources)

    output_filename = '../docs/listing.md'

    # keep a crc32 hash from the file before modification
    crc32_before = crc32(output_filename)

    # write the generated documentation
    with open(output_filename, 'w', encoding='utf-8', newline='\n') as in_file:
        for line in documentation:
            in_file.write((line + '\n'))

    # keep a crc32 hash from the file after modification
    crc32_after = crc32(output_filename)

    # if the file changed
    if crc32_before != crc32_after:
        print('Finished generating documentation. The ', end='')
        print('output is stored in {}.'.format(output_filename[3:]))
    # if the file didn't change
    else:
        print('No changes to the documentation file.')
Beispiel #2
0
import subprocess
import shutil
import tabulate
import argparse
from common import cpp_compile, run_source, get_sources, score, problem_name, temp_in, temp_out, temp_ok
from sys import stdout

if __name__ == '__main__':
    parser = argparse.ArgumentParser(description='Get scores')
    parser.add_argument('people', type=str, nargs='*')
    parser.add_argument('--all', dest='all', action='store_true')
    args = parser.parse_args()
    if not args.all and args.people == []:
        parser.print_help()
        exit(0)
    SOURCES = get_sources()
    if not args.all:
        SOURCES = list(set(SOURCES) & set(args.people))

    for source in SOURCES:
        cpp_compile(source)

    try:
        shutil.rmtree('./tmp', ignore_errors=False)
    except:
        pass
    os.mkdir('./tmp')

    TESTS = [
        test.name[:-3] for test in os.scandir('./teste')
        if test.name[-3:] == '.in'
Beispiel #3
0
import subprocess
import shutil
import random
import argparse
from common import get_sources, run_source, score, compile_all, cpp_compile, problem_name


if __name__ == '__main__':
    parser = argparse.ArgumentParser(description='Get scores')
    parser.add_argument('people', type=str, nargs='*')
    parser.add_argument('--all', dest='all', action='store_true')
    args = parser.parse_args()
    if not args.all and args.people == []:
        parser.print_help()
        exit(0)
    Sources = get_sources()
    if not args.all:
        Sources = list(set(Sources) & set(args.people))
    for source in Sources:
        cpp_compile(source)

    TESTS = int(input("TESTS = "))
    MAXN = int(input("MAXN = "))
    MAXV = int(input("MAXV = "))
    REALMAXV = int(input("REALMAXV = "))

    try:
        shutil.rmtree('./tmp', ignore_errors=False)
    except:
        pass
    os.mkdir('./tmp')
Beispiel #4
0
import subprocess
import shutil
import random
import argparse
from common import get_sources, run_source, score, compile_all, cpp_compile, problem_name


if __name__ == '__main__':
    parser = argparse.ArgumentParser(description='Get scores')
    parser.add_argument('people', type=str, nargs='*')
    parser.add_argument('--all', dest='all', action='store_true')
    args = parser.parse_args()
    if not args.all and args.people == []:
        parser.print_help()
        exit(0)
    Sources = get_sources()
    if not args.all:
        Sources = list(set(Sources) & set(args.people))
    for source in Sources:
        cpp_compile(source)

    TESTS = int(input("TESTS = "))
    MAXN = int(input("MAXN = "))
    MAXK = int(input("MAXK = "))
    MAXX = int(input("MAXX = "))
    MAXY = int(input("MAXY = "))
    MAXPART = int(input("MAXPART = "))
    MAXV = int(input("MAXV = "))
    try:
        shutil.rmtree('./tmp', ignore_errors=False)
    except:
Beispiel #5
0
def main_function():
    '''
    The main function for the script.
    '''
    # the desired line length
    line_length = 100

    # check we are in the correct folder and complain and exit if we are not
    check_cwd()

    # get a list of header files
    headers = get_headers()
    # get a list of source files
    sources = get_sources()

    # get all the header files beyond the desired line length
    longer_headers = check_line_length(headers, line_length)
    # get all the source files beyond the desired line length
    longer_sources = check_line_length(sources, line_length)

    # get all header files that have improperly formatted comments
    bad_comment_headers = check_comments_space(headers)
    # get all source files that have improperly formatted comments
    bad_comment_sources = check_comments_space(sources)

    # get all header files that don't have a newline as their last line
    no_newline_headers = check_newline_end(headers)
    # get all source files that don't have a newline as their last line
    no_newline_sources = check_newline_end(sources)

    if len(longer_headers) > 0 or len(longer_sources) > 0:
        if len(longer_headers) > 0:
            # print the number of header files containing lines beyond the
            # desired length
            print('\n----------------------------------------------', end='')
            print('-------------------------')
            print('There are ', end='')
            print('{} header files (.hpp) with'.format(len(longer_headers)),
                  end='')
            print(' lines longer than {} characters :'.format(line_length))
            print('------------------------------------------------', end='')
            print('-----------------------')

            for filename, lines in longer_headers:
                print('In {} lines '.format(filename), end='')
                for line in lines:
                    print('{}, '.format(line), end='')
                print('\b\b. ')

        if len(longer_sources) > 0:
            # print the number of source files containing lines beyond the
            # desired length
            print('\n----------------------------------------------', end='')
            print('-------------------------')
            print('There are ', end='')
            print('{} source files (.cpp) with'.format(len(longer_sources)),
                  end='')
            print(' lines longer than {} characters :'.format(line_length))
            print('--------------------------------------------------', end='')
            print('---------------------')

            for filename, lines in longer_sources:
                print('In {} lines '.format(filename), end='')
                for line in lines:
                    print('{}, '.format(line), end='')
                print('\b\b.')

        if len(bad_comment_headers) > 0 or len(bad_comment_sources) > 0:
            # divider between the printing files with lines beyond desired
            # length and printing files with improperly formatted comments
            print('\n\n')
            print('=================================================', end='')
            print('======================\n\n')

    # --------
    if len(bad_comment_headers) > 0 or len(bad_comment_sources) > 0:
        if len(bad_comment_headers) > 0:
            # print the number of header files containing improperly formatted
            # comments
            print('\n-----------------------------------------------', end='')
            print('---------------------')
            print('There are ', end='')
            print(len(bad_comment_headers), end='')
            print(' header files (.hpp) with improperly formatted comments :')
            print('--------------------------------------------', end='')
            print('------------------------')

            for filename, lines in bad_comment_headers:
                print('In {} lines '.format(filename), end='')
                for line in lines:
                    print('{}, '.format(line), end='')
                print('\b\b. ')

        if len(bad_comment_sources) > 0:
            # print the number of source files containing improperly formatted
            # comments
            print('\n----------------------------------------------', end='')
            print('----------------------')
            print('There are ', end='')
            print(len(bad_comment_sources), end='')
            print(' source files (.cpp) with improperly formatted comments :')
            print('--------------------------------------------', end='')
            print('------------------------')

            for filename, lines in bad_comment_sources:
                print('In {} lines '.format(filename), end='')
                for line in lines:
                    print('{}, '.format(line), end='')
                print('\b\b. ')

        if len(bad_comment_headers) > 0 or len(bad_comment_sources) > 0:
            # divider
            print('\n\n')
            print('=================================================', end='')
            print('======================\n\n')

    # --------
    if len(no_newline_headers) > 0 or len(no_newline_sources) > 0:
        if len(no_newline_headers) > 0:
            # print the number of header files that are missing a newline
            # as their last line
            print('--------------------------------------------', end='')
            print('-----------------------------------')
            print('There are {} '.format(len(no_newline_headers)), end='')
            print('header files (.hpp) missing a newline', end='')
            print(' as their last line.')
            print('--------------------------------------------', end='')
            print('-----------------------------------')
            for no_nl_header in no_newline_headers:
                print('The header file {} '.format(no_nl_header), end='')
                print('is missing a newline as its last line.')
            print()

        if len(no_newline_sources) > 0:
            # print the number of source files that are missing a newline
            # as their last line
            print('--------------------------------------------', end='')
            print('-----------------------------------')
            print('There are {} '.format(len(no_newline_sources)), end='')
            print('source files (.cpp) missing a newline', end='')
            print(' as their last line.')
            print('--------------------------------------------', end='')
            print('-----------------------------------')
            for no_nl_source in no_newline_sources:
                print('The source file {} '.format(no_nl_source), end='')
                print('is missing a newline as its last line.')

    # if everything is fine, print a message to inform the user
    longer_files = len(longer_headers) == 0 and len(longer_sources) == 0
    bad_comments = len(bad_comment_headers) == 0
    bad_comments = bad_comments and len(bad_comment_sources) == 0
    no_newlines = len(no_newline_headers) == 0
    no_newlines = no_newlines and len(no_newline_sources) == 0
    if longer_files and bad_comments and no_newlines:
        print('All files checked. No errors detected.')
        env=os.environ, stdout=subprocess.PIPE, shell=True)


if __name__ == '__main__':
    parser = argparse.ArgumentParser(description='dump kafka metrics')
    parser.add_argument('-i', dest='interval', default=1000, type=int, help='interval in ms')

    args = parser.parse_args()
    try:
        with open('.current_run') as f:
            run_info = json.load(f)
    except FileNotFoundError:
        sys.exit('Error: it seems hgw is not running')

    topics = {
        'src': common.get_sources(run_info['dir']),
        'dest': [d['id'] for d in common.get_destinations(run_info['dir'])]
    }
    metric = 'kafka.server:type=BrokerTopicMetrics,name=MessagesInPerSec,topic={}'

    # let's find the output dir (name is incremented each time)
    last_run = -1

    base_output_dir = 'metrics_d{dir}_a{avg}_sp{src_partitions}_dp{dst_partitions}_ndisp{disp_num}'.format(**run_info)
    for f in os.listdir('.'):
        r = re.match(r'{}_([0-9]+)'.format(base_output_dir), f)  # retrieving previous run dir
        last_run = int(r.group(1)) if r and int(r.group(1)) > last_run else last_run

    output_dir = '{}_{}'.format(base_output_dir, last_run + 1)
    os.mkdir(output_dir)
    print('dumping data on {}'.format(output_dir))
Beispiel #7
0
import os
import subprocess
import shutil
import random
import argparse
from common import get_sources, run_source, check_diff, compile_all, cpp_compile

if __name__ == '__main__':
    parser = argparse.ArgumentParser(description='Get scores')
    parser.add_argument('people', type=str, nargs='*')
    parser.add_argument('--all', dest='all', action='store_true')
    args = parser.parse_args()
    if not args.all and args.people == []:
        parser.print_help()
        exit(0)
    SOURCES = get_sources()
    if not args.all:
        SOURCES = list(set(SOURCES) & set(args.people))
    for source in SOURCES:
        cpp_compile(source)

    TESTS = int(input("TESTS = "))
    MAXM = int(input("MAXM = "))
    MAXDIGIT = int(input("MAXDIGIT = "))
    MAXK = int(input("MAXK = "))
    P = float(input("P = "))
    try:
        shutil.rmtree('./tmp', ignore_errors=False)
    except:
        pass
    os.mkdir('./tmp')