Skip to content

Context manager

ioctx = None module-attribute

A global singleton for global method handling IOContext

pwnctx = None module-attribute

A global singleton for global method handling of PwnContext

set_ctx(new_ctx)

Assign the global singleton instance context configuration.

Example:

>>> ctx = IOContext(args, config)
>>> set_ctx(ctx)
Source code in src/pwninit/context.py
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
def set_ctx(new_ctx: IOContext | PwnContext) -> None:
    """Assign the global singleton instance context configuration.

    Example:

        >>> ctx = IOContext(args, config)
        >>> set_ctx(ctx)
    """
    if isinstance(new_ctx, IOContext):
        global ioctx
        ioctx = new_ctx
        return

    if isinstance(new_ctx, PwnContext):
        global pwnctx
        pwnctx = new_ctx
        return

    log.error("Invalid context.")