コード例 #1
0
def _build_sample_yaml(args, app_desc):
    schema = app_desc.schema
    f = StringIO()
    for key, value in UWSGI_OPTIONS.items():
        for field in ["desc", "default"]:
            if field not in value:
                continue
            field_value = value[field]
            if not isinstance(field_value, six.string_types):
                continue

            new_field_value = string.Template(field_value).safe_substitute(
                **{
                    'default_port': str(app_desc.default_port),
                    'app_name': app_desc.app_name,
                    'uwsgi_module': app_desc.uwsgi_module,
                })
            value[field] = new_field_value
    description = getattr(schema, "description", None)
    if description:
        description = description.lstrip()
        as_comment = "\n".join(["# %s" % l
                                for l in description.split("\n")]) + "\n"
        f.write(as_comment)
    _write_sample_section(args,
                          f,
                          'uwsgi',
                          Schema(UWSGI_OPTIONS),
                          as_comment=False,
                          uwsgi_hack=True)
    _write_sample_section(args, f, app_desc.app_name, schema)
    destination = os.path.join(args.galaxy_root, app_desc.sample_destination)
    _write_to_file(args, f, destination)
コード例 #2
0
ファイル: config_manage.py プロジェクト: mvdbeek/galaxy
def _build_sample_yaml(args, app_desc):
    if app_desc.app_name in ["tool_shed"]:
        UWSGI_OPTIONS.update(SHED_ONLY_UWSGI_OPTIONS)
    schema = app_desc.schema
    f = StringIO()
    for value in UWSGI_OPTIONS.values():
        for field in ["desc", "default"]:
            if field not in value:
                continue
            field_value = value[field]
            if not isinstance(field_value, str):
                continue

            new_field_value = string.Template(field_value).safe_substitute(
                **{
                    'default_port': str(app_desc.default_port),
                    'app_name': app_desc.app_name,
                    'uwsgi_module': app_desc.uwsgi_module,
                })
            value[field] = new_field_value
    description = getattr(schema, "description", None)
    if description:
        description = description.lstrip()
        as_comment = "\n".join(f"# {line}"
                               for line in description.split("\n")) + "\n"
        f.write(as_comment)
    if app_desc.app_name == "galaxy":
        if settings_to_sample is None:
            raise Exception(
                "Please install gravity to rebuild the sample config")
        f.write(settings_to_sample())
    _write_sample_section(args,
                          f,
                          'uwsgi',
                          Schema(UWSGI_OPTIONS),
                          as_comment=False,
                          uwsgi_hack=True)
    _write_sample_section(args, f, app_desc.app_name, schema)
    destination = os.path.join(args.galaxy_root, app_desc.sample_destination)
    _write_to_file(args, f, destination)