Beispiel #1
0
        redirect_uri = "/"

    location = urllib.parse.quote(redirect_uri)
    response = web.HTTPFound(location=location)
    remove_session_cookie(response)
    return response


@click_helper.extend
@click.option(
    "--user",
    help="User backend to use (can have multiple).",
    type=click.Choice(["developer", "github"], case_sensitive=False),
    required=True,
    multiple=True,
    callback=click_helper.import_module("truewiki.user", "User"),
)
@click.option(
    "--user-session-expire",
    help="Time for a session to expire (measured from the moment of login).",
    default=60 * 60 * 14,
    show_default=True,
    metavar="SECONDS",
)
@click.option(
    "--user-login-expire",
    help="Time for a login attempt to expire.",
    default=60 * 10,
    show_default=True,
    metavar="SECONDS",
)
Beispiel #2
0
@click_sentry
@click.option("--bind",
              help="The IP to bind the server to",
              multiple=True,
              default=["::1", "127.0.0.1"],
              show_default=True)
@click.option("--port",
              help="Port of the web server",
              default=80,
              show_default=True)
@click.option(
    "--storage",
    type=click.Choice(["github", "gitlab", "git", "local"],
                      case_sensitive=False),
    required=True,
    callback=click_helper.import_module("truewiki.storage", "Storage"),
)
@click.option(
    "--frontend-url",
    help=
    "URL of the frontend, used for creating absolute links in the sitemap.xml",
)
@click.option("--cache-time",
              help="Cache time of uploaded images (in seconds)",
              default=CACHE_TIME_UPLOADS,
              show_default=True)
@click_web_routes
@click_metadata
@click_storage_local
@click_storage_git
@click_storage_github
Beispiel #3
0
              multiple=True,
              default=["::1", "127.0.0.1"],
              show_default=True)
@click.option("--content-port",
              help="Port of the content server",
              default=3978,
              show_default=True)
@click.option("--web-port",
              help="Port of the web server",
              default=80,
              show_default=True)
@click.option(
    "--storage",
    type=click.Choice(["local", "s3"], case_sensitive=False),
    required=True,
    callback=click_helper.import_module("bananas_server.storage", "Storage"),
)
@click_storage_local
@click_storage_s3
@click.option(
    "--index",
    type=click.Choice(["local", "github"], case_sensitive=False),
    required=True,
    callback=click_helper.import_module("bananas_server.index", "Index"),
)
@click_index_local
@click_index_github
@web_routes.click_web_routes
@click.option(
    "--bootstrap-unique-id",
    help=
        for field in ("description", "url", "tags"):
            if field in raw_data:
                package_data[field] = raw_data[field]

        package = Package().load(package_data)

        index_package(package, index_versions=False)

    version = VersionMinimized().load(version_data)

    package["versions"].append(version)
    index_version(session["content_type"], session["unique_id"], version)

    store_on_disk(session["user"], package)


@click_helper.extend
@click.option(
    "--storage",
    help="Storage backend to use.",
    type=click.Choice(["local", "s3"], case_sensitive=False),
    required=True,
    callback=click_helper.import_module("bananas_api.storage", "Storage"),
)
@click_storage_local
@click_storage_s3
def click_storage(storage):
    global _storage_instance
    _storage_instance = storage()
Beispiel #5
0
def get_session_expire():
    return SESSION_EXPIRE


def get_login_expire():
    return LOGIN_EXPIRE


@click_helper.extend
@click.option(
    "--user",
    help="User backend to use (can have multiple).",
    type=click.Choice(["developer", "github"], case_sensitive=False),
    required=True,
    multiple=True,
    callback=click_helper.import_module("bananas_api.user", "User"),
)
@click.option(
    "--user-session-expire",
    help="Time for a session to expire (measured from the moment of login).",
    default=60 * 60 * 14,
    show_default=True,
    metavar="SECONDS",
)
@click.option(
    "--user-login-expire",
    help="Time for a login attempt to expire.",
    default=60 * 10,
    show_default=True,
    metavar="SECONDS",
)
Beispiel #6
0
import click

from openttd_helpers import click_helper


@click_helper.extend
@click.option("--parameter", default=1)
@click.option(
    "--mod",
    help="Pick a module.",
    type=click.Choice(["mod-a", "mod-b"], case_sensitive=False),
    callback=click_helper.import_module("mod", "Mod"),
)
@click.option(
    "--mod-multi",
    help="Pick a module.",
    type=click.Choice(["mod-a", "mod-b"], case_sensitive=False),
    multiple=True,
    callback=click_helper.import_module("mod", "Mod"),
)
def click_function(parameter, mod, mod_multi):
    print(f"Parameter has value {parameter}")

    if mod:
        instance = mod()
        print(f"Mod is saying {instance.print()}")

    if mod_multi:
        for mod in mod_multi:
            instance = mod()
            print(f"Mod is saying {instance.print()}")
Beispiel #7
0
    # allows a user to take a bit of time to get its edits right, before we
    # make a commit out of it.
    if _timer[user.full_id]:
        _timer[user.full_id].cancel()

    loop = asyncio.get_event_loop()
    _timer[user.full_id] = loop.create_task(_timer_handler(user))


@click_helper.extend
@click.option(
    "--index",
    help="Index backend to use.",
    type=click.Choice(["local", "github"], case_sensitive=False),
    required=True,
    callback=click_helper.import_module("bananas_api.index", "Index"),
)
@click_index_local
@click_index_github
@click.option(
    "--commit-graceperiod",
    help="Graceperiod between commits to disk.",
    default=60 * 5,
    show_default=True,
    metavar="SECONDS",
)
@click.option("--validate",
              help="Only validate BaNaNaS files and exit.",
              is_flag=True)
def click_content_save(index, commit_graceperiod, validate):
    global TIMER_TIMEOUT, _index_instance