示例#1
0
def sources_generation_download(execution_id):
    step_props = SourcesGenerationHost.host_step_properties(execution_id)
    artifact_name = ConfigUtils.artifact_name()

    if ConfigUtils.check_artifact_exist(step_props, artifact_name):
        return send_from_directory(step_props.host_guest_output_dir_path(),
                                   artifact_name,
                                   as_attachment=True,
                                   attachment_filename=artifact_name,
                                   mimetype='application/gzip')
    else:
        return 'The artifact does not exist. Please ensure that the provided ' \
               'execution_id is correct and the generation phase is finished ' \
               'and try again', 404
示例#2
0
def sources_generation_output(execution_id):
    step_props = SourcesGenerationHost.host_step_properties(execution_id)
    artifact_name = ConfigUtils.artifact_name()
    download_link = None
    if ConfigUtils.check_artifact_exist(step_props, artifact_name):
        download_link = "/sources-generation/%s/download" % execution_id

    rows = HtmlUtils.generate_html_from_console_output(
        step_props.stdout_file_path())

    output_path = step_props.temp_path()
    stream = ServiceUtils.stream_template('sources_generation_output.html',
                                          rows=rows,
                                          download_link=download_link,
                                          output_link=output_path)
    return Response(stream, mimetype='text/html')
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')
示例#4
0
def sources_generation():
    config_yaml = ServiceUtils.get_step_config(request.form,
                                               'sources_generation.yaml',
                                               _params_to_yaml)

    execution_id = ConfigUtils.generate_id('src-gen-')
    config_yaml['execution_id'] = execution_id
    step = SourcesGenerationHost(config_yaml)
    ServiceUtils.run_host_step(step)

    return redirect("/sources-generation/%s" % execution_id)
def java_sources_staging():
    step_props = JavaSourcesStagingHost.host_step_properties(
        ConfigUtils.generate_id('java-src-stage-'))

    config_yaml = ServiceUtils.get_step_config(request.form,
                                               'java_sources_staging.yaml',
                                               _params_to_yaml)
    artifacts_zip_path = step_props.temp_subpath(ConfigUtils.artifact_name())
    config_yaml['generator_artifacts']['sources_zip'] = artifacts_zip_path
    execution_id = step_props.execution_id()
    config_yaml['staging']['git_branch'] = execution_id
    config_yaml['execution_id'] = execution_id

    ServiceUtils.run_host_step(JavaSourcesStagingHost(config_yaml))

    step = JavaSourcesStagingHost(config_yaml)
    step.pre_execute()
    request.files['generator_artifacts_sources_zip'].save(artifacts_zip_path)
    ServiceUtils.run_host_step(step)

    return redirect("/java-sources-staging/%s" % step_props.execution_id())
示例#6
0
def _check_artifacts_exist(step_props):
    artifacts_fl = step_props.host_guest_output_dir_subpath(
        ConfigUtils.artifact_name())
    return os.path.isfile(artifacts_fl)
            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()
示例#8
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()