Skip to main content

pawnlib is a collection of libraries for IaC.

Project description

♟️ Pawnlib

A collection of libraries that can be used like pawns on a chessboard. Pawnlib is a collection of libraries for IaC.

utils, globals vars, logging, http, network, pretty printing, resource, converter ...

Build Docker Images Docs pages-build-deployment

PyPI version

Installing pawnlib

pawnlib is available on PyPI:

pip3 install pawnlib

pawnlib with wallet is available on PyPI:

pip3 install pawnlib[wallet]

Global Config

You can use the global config.

from pawnlib.config.globalconfig import pawnlib_config as pawn
from pawnlib.output import *


def main():
    current_path = get_script_path(__file__)
    log_time_format = '%Y-%m-%d %H:%M:%S.%f'
    app_name = "default_app"
    stdout = True
    pawn.set(
        PAWN_PATH=current_path,        
        PAWN_TIME_FORMAT=log_time_format,
        PAWN_LOGGER=dict(
            log_level="INFO",
            stdout_level="INFO",
            log_path=f"{current_path}/logs",
            stdout=stdout,
            use_hook_exception=True,
        ),
        PAWN_CONSOLE=dict(
            redirect=True,
            record=True,
            log_time_format=f"%Y-%m-%d %H:%M:%S.%f",
        ),
        PAWN_DEBUG=True, # Don't use production, because it's not stored exception log.
        PAWN_VERBOSE=3,
        app_name=app_name,
        app_data={},
    )
    
    pawn.console.log("START APP")
    pawn.console.log(pawn.to_dict())

app builder

You can create a simple application based on pawnlib with the command below.

$ pawns init
[10:35:21,837] main_cli wrapper                                                                                               main_cli.py:117
[10:35:21,840] args = Namespace(proxy=None, init=Namespace(command='init')), command = init                                   main_cli.py:119

--------------------------------------------------


___.         .__.__       .___
\_ |__  __ __|__|  |    __| _/___________
 | __ \|  |  \  |  |   / __ |/ __ \_  __ \
 | \_\ \  |  /  |  |__/ /_/ \  ___/|  | \/
 |___  /____/|__|____/\____ |\___  >__|
     \/                    \/    \/

 - Description : Initialize Python Development Environment
 - Version     : 0.0.28
 - Author      : jinwoo


--------------------------------------------------

PWD = /Users/jinwoo/work/python_prj/pawnlib


What's your python3 app name? (default_app):
What's your name? (jinwoo):
Please explain this script. (This is script):
Project directory => /Users/jinwoo/work/python_prj/pawnlib ? [y/n] (y):
Do you want to logger? [y/n] (y):
Do you want to daemon? [y/n] (n):

simple reflector proxy

Simple Python HTTP Server which reflects the client HTTP request header in server logs to see the header fields forwarded by web servers.

$ pawns proxy -l 8080 -f 127.0.0.1:8200
[10:34:33,898] main_cli wrapper                                                                                               main_cli.py:117
[10:34:33,902] args = Namespace(proxy=Namespace(listen='8080', forward='127.0.0.1:8200', buffer_size=4096, delay=0.0001,      main_cli.py:119
               timeout=3), init=None), command = proxy

--------------------------------------------------



_____________  _______  ______.__.
\____ \_  __ \/  _ \  \/  <   |  |
|  |_> >  | \(  <_> >    < \___  |
|   __/|__|   \____/__/\_ \/ ____|
|__|                     \/\/
                _____.__                 __
_______   _____/ ____\  |   ____   _____/  |_  ___________
\_  __ \_/ __ \   __\|  | _/ __ \_/ ___\   __\/  _ \_  __ \
 |  | \/\  ___/|  |  |  |_\  ___/\  \___|  | (  <_> )  | \/
 |__|    \___  >__|  |____/\___  >\___  >__|  \____/|__|
             \/                \/     \/

 - Description : proxy reflector
 - Version     : 0.0.28
 - Author      : jinwoo


--------------------------------------------------

[10:34:33,904] args = Namespace(listen='8080', forward='127.0.0.1:8200', buffer_size=4096, delay=0.0001, timeout=3)              proxy.py:173
[10:34:33,905] Listen 0.0.0.0:8080 => Forward 127.0.0.1:8200

Officially supports Python 3.9+.

Documentation

Documentation and tutorials are available at https://docs.jinwoo.xyz

Release Information

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pawnlib-1.0.43.tar.gz (139.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pawnlib-1.0.43-py3-none-any.whl (163.3 kB view details)

Uploaded Python 3

File details

Details for the file pawnlib-1.0.43.tar.gz.

File metadata

  • Download URL: pawnlib-1.0.43.tar.gz
  • Upload date:
  • Size: 139.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.13

File hashes

Hashes for pawnlib-1.0.43.tar.gz
Algorithm Hash digest
SHA256 de4e14a44e892106ce5f0f48d0714fca5646b059e6ffe24ecb31e6a6528e4c7b
MD5 ff6d5648f7dd869efb985bbfccd3299d
BLAKE2b-256 c77b22505ff5b7d6b11aa32060997b22966b8fb2a47a2198b9f74c1b39d3d13f

See more details on using hashes here.

File details

Details for the file pawnlib-1.0.43-py3-none-any.whl.

File metadata

  • Download URL: pawnlib-1.0.43-py3-none-any.whl
  • Upload date:
  • Size: 163.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.13

File hashes

Hashes for pawnlib-1.0.43-py3-none-any.whl
Algorithm Hash digest
SHA256 5510bc95d34985d0ae77d701f57773a555d7b0ca4ec52f68361940e2be3e3fb3
MD5 dabc2adfa4a225662490881a2b91bfef
BLAKE2b-256 a4151c856c9355873006421375c29d4cae1cb2e4f999c37d2f80faf647688721

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page