def java_sources_staging_output(execution_id):
    step_props = JavaSourcesStagingHost.host_step_properties(execution_id)
    artifact_name = ConfigUtils.artifact_yaml_name()
    pr_url = None

    if ConfigUtils.check_artifact_exist(step_props, artifact_name):
        artifact = ConfigUtils.read_config(
            step_props.host_guest_output_dir_subpath(
                ConfigUtils.artifact_yaml_name()))
        pr_url = artifact['pr_url']

    rows = HtmlUtils.generate_html_from_console_output(
        step_props.stdout_file_path())
    stream = ServiceUtils.stream_template('java_sources_staging_output.html',
                                          rows=rows, pr_url=pr_url,
                                          output_link=step_props.temp_path())
    return Response(stream, mimetype='text/html')
            self,
            JavaSourcesStagingHost.host_step_properties(
                config['execution_id']), config)

    def execute(self):
        self._stage_sources_in_guest()
        return self._host.execution_id()

    def _stage_sources_in_guest(self):
        host_art_path = self._config['generator_artifacts']['sources_zip']
        art_name = host_art_path[host_art_path.rfind('/') + 1:]
        guest_art_path = self._guest.guest_root_subpath(art_name)

        guest_config = copy.deepcopy(self._config)
        guest_config['generator_artifacts']['sources_zip'] = guest_art_path

        self.run_guest_script(guest_config,
                              [[host_art_path, guest_art_path, 'ro']])

    @staticmethod
    def host_step_properties(execution_id):
        return HostStepProperties(__file__, execution_id)


if __name__ == '__main__':
    execution_config = ConfigUtils.read_config(
        execution_id=ConfigUtils.generate_id('java-src-stage-'))
    step = JavaSourcesStagingHost(execution_config)
    step.pre_execute()
    step.execute()
Esempio n. 3
0
 def get_step_default_config(config_file_name):
     default_config_str = render_template(config_file_name)
     default_config_yaml = ConfigUtils.read_config(
         yaml_str=default_config_str)
     return default_config_yaml
        guest_config = copy.deepcopy(self._config)
        mounts = self._local_repo_mounts()
        extra_mounts = []
        for repo_name, repo_mounts in mounts.items():
            if repo_mounts:
                guest_config[repo_name]['git_repo'] = repo_mounts[1]
                extra_mounts.append(repo_mounts)

        self.run_guest_script(guest_config, extra_mounts)

    def _local_repo_mounts(self):
        config = self._config
        mounts = {
            'artman': self.local_repo_mount(config['artman']),
            'toolkit': self.local_repo_mount(config['toolkit']),
            'googleapis': self.local_repo_mount(config['googleapis'])
        }
        return mounts

    @staticmethod
    def host_step_properties(execution_id):
        return HostStepProperties(__file__, execution_id)


if __name__ == '__main__':
    execution_config = ConfigUtils.read_config(
        execution_id=ConfigUtils.generate_id('src-gen'))
    step = SourcesGenerationHost(execution_config)
    step.pre_execute()
    step.execute()