Exemplo n.º 1
0
def apm_luna_atom_package(package_name, package_address):
    with working_directory(packages_path):
        output = run_process('git', 'clone', package_address, package_name)
        print(output)
        with working_directory(package_name):
            output2 = run_apm('install', '.')
            print(output2)
Exemplo n.º 2
0
def copy_studio(package_path, gui_url, frontend_args):
    if gui_url:
        try:
            print("copy studio from url")
            r = requests.get(gui_url)
            z = zipfile.ZipFile(io.BytesIO(r.content))
            z.extractall(package_path)
        except:
            print("Can not download gui from given url")
            print("Building Luna Studio")
            stack_build.build_ghcjs(frontend_args, dev_mode=True)
            atom_prepare.run(dev_mode=True)
            print("Preparing gui package")
            os.makedirs(dist_package_folder, exist_ok=True)
            with zipfile.ZipFile(gui_package_path, 'w') as zf:
                with working_directory(studio_folder):
                    for dirname, subdirs, files in os.walk('./'):
                        for filename in files:
                            zf.write(os.path.join(dirname, filename))

    else:
        print("Building Luna Studio")
        stack_build.build_ghcjs(frontend_args, dev_mode=True)
        atom_prepare.run(dev_mode=True)
    dir_util.copy_tree(studio_atom_source_path, package_path)
Exemplo n.º 3
0
def link_resources ():
    with working_directory(ap.prep_path('../dist/bin')):
        os.makedirs('main/resources', exist_ok=True)
        for src_path2 in glob('public/luna-studio/resources/*'):
            dst_path = os.path.join('main/resources', os.path.basename(src_path2))
            if os.path.isfile(dst_path):
                os.remove(dst_path)
            if os.path.isfile(src_path2):
                create_symlink_or_copy(dst_path, src_path2)
Exemplo n.º 4
0
def link_main_bin ():
    with working_directory(ap.prep_path('../dist/bin')):
        os.makedirs('main', exist_ok=True)
        for src_path in glob('public/luna-studio/*'):
            dst_path = os.path.join('main', os.path.basename(src_path))
            if os.path.isfile(dst_path):
                os.remove(dst_path)
            if os.path.isfile(src_path):
                    os.symlink(os.path.relpath(src_path,'main/'), dst_path)
Exemplo n.º 5
0
def build_runner(runner_args):
    with working_directory(runner_dir):
        print ("build runner")
        runnerPath = runner_dir + '/src/StudioRunner.hs'
        hostPath = runner_dir + '/src/System/Host.hs'
        resPath = runner_dir + '/../resources/my.res'
        if system.windows():
            subprocess.check_output(['stack', 'build'])
            os.system('stack exec ghc -- ' + runnerPath + ' ' + hostPath + ' ' + resPath + ' -optl -mwindows')

        subprocess.check_output(['stack', 'build'] + runner_args)
    mv_runner(runner_dir)
Exemplo n.º 6
0
def init_apm(gui_url, frontend_args, link):
    package_path = atom_home_path + '/packages/' + studio_package_name
    print("Initializing APM in: {}".format(package_path))
    oniguruma_package_path = package_path + '/node_modules/oniguruma'
    if link:
        with working_directory(studio_atom_source_path):
            print('Installing Luna Studio')
            output = run_apm('install', '.')
            print(output)
            print('Linking Luna Studio')
            output2 = run_apm('link', '.')
            print(output2)
    else:
        os.makedirs(package_path, exist_ok=True)
        copy_studio(package_path, gui_url, frontend_args)
        dir_util.copy_tree(oniguruma_path, oniguruma_package_path)
        with working_directory(package_path):
            print('Installing Luna Studio')
            output = run_apm('install', '.')
            print(output)
        dir_util.remove_tree(oniguruma_package_path)
        dir_util.copy_tree(oniguruma_path, oniguruma_package_path)
Exemplo n.º 7
0
def build_backend(backend_args):
    with working_directory(backend_dir):
        # subprocess.check_output(['stack', 'build', 'luna-empire', '--test', '--no-run-tests'])
        sys_opts = ['--ghc-options=-fexternal-interpreter'
                    ] if system.windows() else []
        # Note: -fno-omit-interface-pragmas is specific to our backend stack.yaml project.
        # It adds -fomit-interface-pragmas option that negatively affects performance.
        # This script wants to create a fully-optimized build, so we need to overwtite the flag.
        #
        # TODO: this behaviour should be eventually optional and script should be usable
        # for building development packages (that also care about build-speed).
        args = sys_opts + backend_args + [
            '--ghc-options=-fno-omit-interface-pragmas'
        ]
        subprocess.check_output(['stack', 'build'] + args)
Exemplo n.º 8
0
def run(traffic, bench, trace_file_name, max_cycles, num_nodes, routing,
        selection, data_packet_injection_rate, aco_selection_alpha,
        reinforcement_factor):
    dir = working_directory(traffic, bench, max_cycles, num_nodes, routing,
                            selection, data_packet_injection_rate,
                            aco_selection_alpha, reinforcement_factor)

    stats_file_name = dir + '/stats.json'
    if os.path.isfile(stats_file_name):
        print('Stats file exists, skipped: ' + stats_file_name)
        return

    os.system('rm -fr ' + dir)
    os.system('mkdir -p ' + dir)

    cmd_run = '~/go/bin/heo -d=' + dir + ' -t=' + traffic + ' -tf=' + trace_file_name \
              + ' -c=' + str(max_cycles) + ' -n=' + str(num_nodes) + ' -r=' + routing + ' -s=' + selection \
              + ' -di=' + str(data_packet_injection_rate) + ' -ai=' + str(ant_packet_injection_rate) \
              + ' -sa=' + str(aco_selection_alpha) + ' -rf=' + str(reinforcement_factor)
    print(cmd_run)
    os.system(cmd_run)
Exemplo n.º 9
0
Arquivo: analyze.py Projeto: mcai/heo
         lambda r: r.stats['SimulationTimeInSeconds']),
        ('Throughput', lambda r: r.stats['Throughput']),
        ('Average Packet Delay', lambda r: r.stats['AveragePacketDelay']),
        ('Payload Throughput', lambda r: r.stats['PayloadThroughput']),
        ('Average Payload Packet Delay',
         lambda r: r.stats['AveragePayloadPacketDelay']),
    ])


for data_packet_injection_rate in synthesized_data_packet_injection_rate_range:
    results = []

    for traffic in synthesized_traffic_range:
        results.append(
            parse_result(working_directory(traffic, '', max_cycles, num_nodes,
                                           'XY', 'Random',
                                           data_packet_injection_rate, -1, -1),
                         bench=traffic))
        results.append(
            parse_result(working_directory(traffic, '', max_cycles, num_nodes,
                                           'OddEven', 'BufferLevel',
                                           data_packet_injection_rate, -1, -1),
                         bench=traffic))

        for aco_selection_alpha in aco_selection_alpha_range:
            for reinforcement_factor in reinforcement_factor_range:
                results.append(
                    parse_result(working_directory(traffic, '', max_cycles,
                                                   num_nodes, 'OddEven', 'ACO',
                                                   data_packet_injection_rate,
                                                   aco_selection_alpha,
Exemplo n.º 10
0
def build_ghcjs(frontend_args, dev_mode):
    with working_directory(frontend_dir):
        if dev_mode:
            subprocess.check_output(['stack', 'build'] + frontend_args)
Exemplo n.º 11
0
def build_backend(backend_args):
    with working_directory(backend_dir):
        subprocess.check_output(['stack', 'build', 'luna-empire', '--test', '--no-run-tests'])
        subprocess.check_output(['stack', 'build'] + backend_args)
Exemplo n.º 12
0
def apm_luna_local_atom_package(package_name, package_path):
    with working_directory(package_path):
        output2 = run_apm('install', '.')
        print(output2)
        output3 = run_apm('link', '.')
        print(output3)
Exemplo n.º 13
0
def build_backend(backend_args):
    with working_directory(backend_dir):
        subprocess.check_output(['stack', 'build'] + backend_args)