Beispiel #1
0
    def run(self):
        self.is_windows = re.match('windows', self.builder_name)
        try:
            show_cmd = "cat" if not self.is_windows else "type"
            native_yaml_path = self.yaml_path
            if self.is_windows:
                native_yaml_path = native_yaml_path.replace('/', '\\')
            cmd = yield self.makeRemoteShellCommand(
                command=[show_cmd, native_yaml_path],
                collectStdout=True
            )
            yield self.runCommand(cmd)

            result = cmd.results()
            if result != util.SUCCESS:
                raise Exception("Command failed with return code: {}" .format(
                    str(cmd.rc)
                ))
            else:
                config = yaml.safe_load(cmd.stdout)
                builder_config = config[self.builder_name]

                commands = None
                env = self.environment
                env += envs.Environment(config.get('env', {}))
                if isinstance(builder_config, collections.Mapping):
                    commands = builder_config['commands']
                    env += envs.Environment(builder_config.get('env', {}))
                else:
                    commands = builder_config

                dynamic_steps = [
                    self.make_step(command, env) for command in commands
                ]
        except Exception as e:  # Bad step configuration, fail build
            # Capture the exception and re-raise with a friendly message
            raise Exception("Bad step configuration for {}: {}".format(
                self.builder_name,
                str(e)
            ))

        pkill_step = [self.make_pkill_step("servo")]
        self.add_steps(pkill_step + dynamic_steps)

        defer.returnValue(result)
Beispiel #2
0
    def make_step(self, command, env):
        step_kwargs = {}
        step_env = env

        command = command.split(' ')

        step_kwargs['command'] = command
        if self.is_windows:
            step_env += envs.Environment({
                # Set home directory, to avoid adding `cd` command every time
                'HOME':
                r'C:\buildbot\slave\{}\build'.format(self.builder_name),
            })

        step_desc = []
        step_class = steps.ShellCommand
        args = iter(command)
        for arg in args:
            if arg == './mach' or arg == 'mach.bat':
                mach_arg = next(args)
                step_desc = [mach_arg]

                # Change Step class to capture warnings as needed
                # (steps.Compile and steps.Test catch warnings)
                if re.match('build(-.*)?', mach_arg):
                    step_class = steps.Compile
                elif re.match('package', mach_arg):
                    step_class = steps.Compile
                elif re.match('test-.*', mach_arg):
                    step_class = steps.Test

                # Provide credentials where necessary
                if re.match('upload-nightly', mach_arg):
                    step_kwargs['logEnviron'] = False
                    step_env += envs.upload_nightly

            # Capture any logfiles
            elif re.match('--log-.*', arg):
                logfile = next(args)
                if 'logfiles' not in step_kwargs:
                    step_kwargs['logfiles'] = {}
                step_kwargs['logfiles'][logfile] = logfile

            else:
                step_desc += [arg]

        if step_class != steps.ShellCommand:
            step_kwargs['description'] = "running"
            step_kwargs['descriptionDone'] = "ran"
            step_kwargs['descriptionSuffix'] = " ".join(step_desc)

        step_kwargs['env'] = step_env
        return step_class(**step_kwargs)
Beispiel #3
0
    g = gene_functions.Gaps3(x, y)

    velocity = [0, 0]
    dna = [0.29087740586878064]

    for j in range(2):
        velocity[j] = g.input0()[j] * dna[0]
                      # g.input1()[j] * dna[1] + \
                      # g.input4()[j] * dna[2]
    print(velocity)

            # print('velocity', velocity)

    e = environments.Environment(solids=[pe.Circle(static=True),
                            pe.Circle(radius=1, pos=i, velocity=velocity)],
                    g_type='nonuniform',
                    g_strength=10)


    # run the physics engine until either the termination condition is reached (termination function has to be put into the physics_engine.py
    runtime = pe.run_physics_engine(.2, e, 100)
    # print('runtime', runtime)

    # if the simulation exceeds the time limit before the termination condition is reached, or way too quickly, the organism's fitness will be virtually 0
    if runtime >= 100 or runtime <= .2 * 10:
        print('fitness', 0)
    else:
        # fitness function, tries to minimize velocity while maximizing time spent before crashing back down to planet, uses normalized quantities
        velocity_magnitude = pe.distance(velocity, [0, 0])

        norm_runtime = (runtime - .2 * 10) / (100 - .2 * 10)
Beispiel #4
0
    def make_step(self, command):
        step_kwargs = {}
        step_env = copy.deepcopy(self.environment)

        command = command.split(' ')

        # Add `bash -l` before every command on Windows GNU builders
        bash_args = ["bash", "-l"] if self.is_win_gnu else []
        step_kwargs['command'] = bash_args + command
        if self.is_windows:
            step_env += envs.Environment({
                # Set home directory, to avoid adding `cd` command every time
                'HOME':
                r'C:\buildbot\slave\{}\build'.format(self.builder_name),
            })

        step_desc = []
        step_class = steps.ShellCommand
        args = iter(command)
        for arg in args:
            # Change Step class to capture warnings as needed
            # (steps.Compile and steps.Test catch warnings)
            if arg == './mach' or arg == 'mach.bat':
                mach_arg = next(args)
                step_desc = [mach_arg]
                if re.match('build(-.*)?', mach_arg):
                    step_class = steps.Compile
                elif re.match('package', mach_arg):
                    step_class = steps.Compile
                elif re.match('test-.*', mach_arg):
                    step_class = steps.Test

            # Capture any logfiles
            elif re.match('--log-.*', arg):
                logfile = next(args)
                if 'logfiles' not in step_kwargs:
                    step_kwargs['logfiles'] = {}
                step_kwargs['logfiles'][logfile] = logfile

            # Provide environment variables for s3cmd
            elif (arg == './etc/ci/upload_nightly.sh'
                  or arg == r'.\etc\ci\upload_nightly.sh'):
                step_kwargs['logEnviron'] = False
                step_env += envs.upload_nightly
                if self.is_windows:
                    # s3cmd on Windows GNU does not work in MINGW
                    step_env['MSYSTEM'] = 'MSYS'
                    step_env['PATH'] = ';'.join([
                        r'C:\msys64\usr\bin',
                        r'C:\Windows\system32',
                        r'C:\Windows',
                        r'C:\Windows\System32\Wbem',
                        r'C:\Windows\System32\WindowsPowerShell\v1.0',
                        r'C:\Program Files\Amazon\cfn-bootstrap',
                    ])

            else:
                step_desc += [arg]

        if step_class != steps.ShellCommand:
            step_kwargs['description'] = "running"
            step_kwargs['descriptionDone'] = "ran"
            step_kwargs['descriptionSuffix'] = " ".join(step_desc)

        step_kwargs['env'] = step_env
        return step_class(**step_kwargs)