pawnlib.cli package

from pawnlib.cli import *

Submodules

pawnlib.cli.aws module

from pawnlib.cli import aws

pawnlib.cli.banner module

from pawnlib.cli import banner
get_parser()[source]
get_arguments(parser)[source]
main()[source]

Command to test the banner. This script generates text banners using various fonts.

Usage examples:
  1. Generate a banner with default font:

    $ pawns banner --text "Hello World"

  2. List all available fonts and generate banners:

    $ pawns banner --text "Sample Text"

For more information, visit the project repository or consult the documentation.

pawnlib.cli.compose module

from pawnlib.cli import compose
non_empty_validator(value)[source]
get_parser()[source]
get_arguments(parser)[source]
main()[source]

An interactive Docker Compose builder for creating and managing services. This tool helps to build a Docker Compose file interactively. You can add multiple services, configure ports, environment variables, and volumes.

Usage examples:
  1. Create a Docker Compose file: - This will start the interactive wizard to create a docker-compose.yml file.

    pawns compose  init

pawnlib.cli.docker module

from pawnlib.cli import docker
get_parser()[source]
get_arguments(parser)[source]
initialize(args)[source]
main()[source]

Command Line Interface for managing Docker containers. This tool supports initialization, running, starting, stopping, and removing Docker containers. This script provides various commands for Docker container management.

Usage examples:

  • Initialize configuration and generate sample files:

    $ pawns docker init

  • Run containers based on provided targets:

    $ pawns docker run --count 10 --name my_container --image my_image

  • Start, stop, or remove containers:

    $ pawns docker start --name my_container $ pawns docker stop --name my_container $ pawns docker delete --name my_container

For more information, visit the project repository or consult the documentation.

pawnlib.cli.gs module

from pawnlib.cli import gs
get_parser()[source]
get_arguments(parser=None)[source]
print_hex_value(name, value)[source]
get_hex_value(value)[source]
main()[source]

Genesis Tool

Usage examples:

  1. Generate a genesis file from a genesis.json file:

    pawns gs gen -i genesis.json -o icon_genesis.zip

  2. Display information about a genesis zip file:

    pawns gs info genesis.zip

Note

The ‘gen’ command generates a genesis file based on a provided genesis.json file. The ‘info’ command displays information from a given genesis.zip file.

pawnlib.cli.http module

from pawnlib.cli import http
class SuccessCriteria[source]

Bases: object

static from_string(criteria_string)[source]
Return type:

List[str]

class AppConfig(url='', config_file='config.ini', verbose=1, quiet=0, interval=1.0, method='', timeout=10.0, base_dir=<factory>, success=<factory>, logical_operator='and', ignore_ssl=True, data=<factory>, headers=<factory>, workers=10, stack_limit=5, section_name='default', total_count=0, error_stack_count=0, fail_count=0, response_time=<factory>, dynamic_increase_stack_limit=True, slack_url='', blockheight_key=None, blockheight_stack=<factory>)[source]

Bases: object

url: str = ''
config_file: str = 'config.ini'
verbose: int = 1
quiet: int = 0
interval: float = 1.0
method: str = ''
timeout: float = 10.0
base_dir: str
success: List[str]
logical_operator: str = 'and'
ignore_ssl: bool = True
data: dict
headers: dict
workers: int = 10
stack_limit: int = 5
section_name: str = 'default'
total_count: int = 0
error_stack_count: int = 0
fail_count: int = 0
response_time: List[int]
dynamic_increase_stack_limit: bool = True
slack_url: str = ''
blockheight_key: Optional[str] = None
blockheight_stack: List[int]
class CustomArgumentParser(prog=None, usage=None, description=None, epilog=None, parents=[], formatter_class=<class 'argparse.HelpFormatter'>, prefix_chars='-', fromfile_prefix_chars=None, argument_default=None, conflict_handler='error', add_help=True, allow_abbrev=True, exit_on_error=True)[source]

Bases: ArgumentParser

error(message: string)[source]

Prints a usage message incorporating the message to stderr and exits.

If you override this in a subclass, it should not return – it should either exit or raise an exception.

convert_type(value, to_type)[source]

주어진 값을 to_type 타입으로 변환합니다.

convert_value(value, target_type)[source]
Return type:

Any

get_parser()[source]
get_arguments(parser)[source]
check_url_process(config)[source]
print_response_if_verbose(check_url)[source]
handle_failure_on_check_url(args, message, check_url)[source]
set_default_counter(section_name='default')[source]
apply_config_values(config_instance, section_name, section_value)[source]

섹션 값들을 AppConfig 인스턴스에 적용합니다.

load_and_verify_config()[source]
generate_task_from_config()[source]
fill_default_config_values(tasks)[source]
print_banner()[source]
validate_task_exit_on_failure(tasks)[source]
main()[source]

This is a tool to measure RTT on HTTP/S requests. This script provides various options to check the HTTP status of URLs.

Usage examples:
  1. Basic usage:

    pawns http https://example.com

  2. Verbose mode:

    pawns http https://example.com -v

  3. Using custom headers and POST method:

    pawns http https://example.com -m POST –headers ‘{“Content-Type”: “application/json”}’ –data ‘{“param”: “value”}’

  4. Ignoring SSL verification and setting a custom timeout:

    pawns http https://example.com –ignore-ssl True –timeout 5

  5. Checking with specific success criteria and logical operator:

    pawns http https://example.com –success ‘status_code==200’ ‘response_time<2’ –logical-operator and

  6. Running with a custom config file and interval:

    pawns http https://example.com -c http_config.ini -i 3

  7. Setting maximum workers and stack limit:

    pawns http https://example.com -w 5 –stack-limit 10

  8. Dry run without actual HTTP request:

    pawns http https://example.com –dry-run

  9. Sending notifications to a Slack URL on failure:

    pawns http https://example.com –slack-url ‘https://hooks.slack.com/services/…’

  1. Checking blockheight increase:

    pawns http http://test-node-01:26657/status –blockheight-key “result.sync_info.latest_block_height” -i 5

Note

# The configuration options are provided below. You can customize these settings in the ‘http_config.ini’ file.

[default]
success = status_code==200
slack_url =
interval = 3
method = get
; data = sdsd
data = {“sdsd”: “sd222sd”}

[post]
method = post

[http_200_ok]
success = status_code==200

[http_300_ok_and_2ms_time]
success = [‘status_code==300’, ‘response_time<0.02’]

[http_400_ok]
success = [“status_code==400”]

For more details, use the -h or –help flag.

pawnlib.cli.icon module

from pawnlib.cli import icon

pawnlib.cli.info module

from pawnlib.cli import info
get_parser()[source]
get_arguments(parser)[source]
print_banner()[source]
print_unless_quiet_mode(message='')[source]
main()[source]

This command displays server resource information. This tool provides a detailed overview of your server’s system and network resources.

Usage examples:
  1. Display all resource information in verbose mode: - Displays detailed information about system and network resources.

    pawns info -v

  2. Run in quiet mode without displaying any output: - Executes the script without showing any output, useful for logging purposes.

    pawns info -q

  3. Specify a custom base directory and configuration file: - Uses the specified base directory and configuration file for operations.

    pawns info -b /path/to/base/dir –config-file my_config.ini

  4. Write output to a specified file in quiet mode without displaying any output: - Writes the collected resource information to ‘output.json’.

pawns info -q –output-file output.json

For more detailed command usage and options, refer to the help documentation by running ‘pawns info –help’.

pawnlib.cli.init module

from pawnlib.cli import init
get_parser()[source]
get_arguments(parser)[source]
main()[source]

Advanced Python application builder: Easily initialize your Python development environment with customizable templates and best practices. This script provides advanced features for building Python applications.

The script will generate a new application with default settings and print the generated code to the console. Make sure to adjust the generated code according to your project’s needs.

Usage examples:
  1. Initialize a new Python application with default settings:

    $ pawns init

For more details on available commands and options, use the -h or –help flag. For additional support and documentation, visit the project repository or consult the documentation.

pawnlib.cli.net module

from pawnlib.cli import net

pawnlib.cli.rpc module

from pawnlib.cli import rpc
get_parser()[source]
get_arguments(parser)[source]
get_methods(answers)[source]
get_required(answers)[source]
fetch_environments_to_args()[source]
print_banner()[source]
fill_sign_params_from_args(payload)[source]
network_info_to_args(network_info)[source]
class RpcCommand[source]

Bases: object

initialize_arguments()[source]
load_network_config()[source]
load_config_file()[source]
set_network_info()[source]
generate_tx_payload()[source]
load_wallet_and_prepare_for_sign()[source]
print_balance()[source]
prepare_signature()[source]
write_config_file()[source]
call_raw_rpc()[source]
deploy_score()[source]
create_json_rpc_request_from_dot_command()[source]
run()[source]
main()[source]

This tool uses JSON remote procedure calls, or RPCs, commonly used on the ICON blockchain. This utility offers a comprehensive suite for interacting with the ICON blockchain, leveraging JSON-RPC for efficient communication.

Usage examples:
  1. Query network information:

    • Fetches block information by height.

    pawns rpc –url <RPC_ENDPOINT> –method icx_getBlockByHeight –params ‘{“height”:”0x1”}’

  2. Send ICX transaction:

    • Sends an ICX transaction to the network.

    pawns rpc –url <RPC_ENDPOINT> –method icx_sendTransaction –params <TRANSACTION_PARAMETERS>

  3. Configure network settings:

    • Sets the network configuration for subsequent operations.

    pawns rpc –platform icon –network mainnet

  4. Configure custom network settings:

    • If you want to edit network information, create config.yaml with a parameter called config and then change it.

    pawns rpc config

For detailed command usage and options, refer to the help documentation by running ‘pawns rpc –help’.

pawnlib.cli.proxy module

from pawnlib.cli import proxy
get_parser()[source]
get_arguments(parser)[source]
class Forward[source]

Bases: object

start(host, port, is_ssl=False, hostname='', timeout=10)[source]
class EchoWebServer(listen, forward, buffer_size, delay)[source]

Bases: object

input_list = []
channel = {}
main_loop()[source]
parse_http_request()[source]
parse_http_response()[source]
convert_to_request_raw()[source]
modify_http_request_headers(headers={})[source]
on_accept()[source]
on_close()[source]
on_recv()[source]
resolve_domain_to_ip(domain)[source]
is_valid_ip(ip)[source]
parse_ip_port(input_str)[source]
main()[source]

A Proxy Reflector Tool This script acts as a proxy reflector, forwarding traffic between a listening address and a forwarding address.

Usage examples:
  1. To start proxying with default settings (listening on 0.0.0.0:8080):

    • This forwards traffic from the default listening address to the specified forward address.

    pawns proxy –forward ip_address:port

  2. To specify a listening address and port:

    • Listens on 127.0.0.1:9090 and forwards traffic to the specified forward address.

    pawns proxy –listen 127.0.0.1:9090 –forward ip_address:port

  3. To adjust buffer size and delay for socket operations:

    • Uses a buffer size of 5120 bytes and a delay of 0.001 seconds for socket operations.

    pawns proxy –listen ip_address:port –forward ip_address:port –buffer-size 5120 –delay 0.001

  4. To set a timeout for the proxy connections: - Sets a timeout of 5 seconds for the proxy connections.

    pawns proxy –listen ip_address:port –forward ip_address:port –timeout 5

For more detailed information on command options, use the -h or –help flag.

pawnlib.cli.s3 module

from pawnlib.cli import s3

pawnlib.cli.server module

from pawnlib.cli import server
get_parser()[source]
get_arguments(parser)[source]
print_banner()[source]
find_all_arguments(parser)[source]
create_argument_dict(namespace, all_arguments)[source]
print_unless_quiet_mode(message='')[source]
run_disk_performance_test(args)[source]
run_filesystem_performance_test(args)[source]
display_system_info(system_info)[source]
display_performance_results(disk_performance_result=None, filesystem_performance_result=None)[source]
main()[source]

This command is used to measure server performance and verify specifications. This tool is intended for checking and validating server resources.

Usage examples:
  1. Measure disk performance:

    • Measures write and read speed for a test file with specified parameters.

    pawns server disk –file-path /path/to/testfile –file-size-mb 1024 –iterations 5 –block-size-kb 1024 –num-threads 1 –io-pattern sequential

  2. Measure filesystem performance:

    • Measure the filesystem performance 5 times with 2,000 files.

    pawns server fs server fs -i 5 –count 2000

For more detailed command usage and options, refer to the help documentation by running ‘pawns server –help’.

pawnlib.cli.top module

from pawnlib.cli import top
get_parser()[source]
get_arguments(parser)[source]
print_banner()[source]
main()[source]

A simple and powerful tool for monitoring server resources in real time. This tool is a comprehensive solution for monitoring your server’s resource usage.

Features include real-time tracking of network traffic, CPU, memory, and disk usage, making it an indispensable tool for system administrators and DevOps professionals.

Here are some usage examples to get you started:

  1. Basic Monitoring: Monitor system resources with default settings. Example: pawns top

  2. Detailed View: Use -v to increase verbosity and get more detailed logs. Example: pawns top -v

  3. Minimal Output: Use -q for quiet mode to suppress standard output. Example: pawns top -q

  4. Custom Update Interval: Adjust the refresh rate with -i to set the interval in seconds. Example: pawns top -i 5

  5. Output Formats: Choose between ‘live’ and ‘line’ output styles with -t. Example: pawns top -t live

  6. Network-Specific Monitoring: Focus solely on network traffic and protocols. Example: pawns top net

  7. Advanced Filters: Use advanced options to filter processes by PID, name, or network protocols. Example: pawns top proc –pid-filter 1234 –protocols tcp udp

Key options:
--top-n

Specify the number of top processes to display.

--refresh-rate

Set the data refresh rate in seconds.

--unit

Choose the unit for network traffic (e.g., Mbps, Gbps).

--group-by

Group processes by PID or name.

This flexibility allows you to tailor the tool to your specific needs. For more detailed usage, run –help or refer to the documentation.

print_simple_line_type_status(table_title, system_info, system_monitor, args)[source]
print_line_status(line)[source]
print_rich_live_type_status(table_title='', system_info={}, system_monitor=None)[source]
print_rich_layout_type_status(table_title='', system_info={}, system_monitor=None)[source]
get_resources_status(system_monitor=None, args=None)[source]

pawnlib.cli.wallet module

from pawnlib.cli import wallet
get_parser()[source]
get_arguments(parser)[source]
private_key_validator(private_key)[source]
least_length_validator(text, length=1)[source]
main()[source]

A tool for managing ICON wallets. It supports creating new wallets and loading existing ones. This command-line interface offers various options for interacting with ICON wallets. You can easily create a new wallet or load an existing one using a private key or a keystore file.

Usage examples:
  1. Create a new wallet:

    • This command creates a new wallet and outputs the keystore file and address.

    pawns wallet create

  2. Load an existing wallet using a private key:

    • Loads a wallet from the provided private key.

    pawns wallet load –private-key YOUR_PRIVATE_KEY

  3. Load an existing wallet from a keystore file:

    • Loads a wallet from a keystore file with the provided password.

    pawns wallet load –keystore /path/to/keystore –password YOUR_PASSWORD

Options:
  • Use ‘–debug’ to enable debug mode for more detailed logs.

  • Use ‘–no-store’ with the ‘create’ command to avoid saving the wallet keystore file.

For more detailed information on command options, use the -h or –help flag.

pawnlib.cli.websocket module

from pawnlib.cli import websocket
get_parser()[source]
get_arguments(parser)[source]
main()[source]

Connect to the Goloop network with WebSocket to receive blocks. This script allows you to connect to the Goloop network via WebSocket and receive real-time block information.

Usage examples:
  1. Connect to Goloop network via WebSocket: - Connects to the Goloop network via WebSocket using the specified URL.

    pawns websocket http://example.com/ws

  2. Specify the starting block height: - Specifies the starting block height as 1000.

    pawns websocket https://example.com/ws -b 1000

  3. Adjust verbosity level: - Increases verbosity level for more detailed output.

    pawns websocket http://example.com/ws -v

For more information and options, use the -h or –help flag.

pawnlib.cli.mon module

from pawnlib.cli import mon
class ComposeDefaultSettings[source]

Bases: object

BASE_DIR = '/pawnlib'
LOG_FILE = '/pawnlib/logs'
VERBOSE = 1
LOG_TYPE = 'file'
PRIORITY = 'env'
parse_address_list(address_string)[source]

Comma-separated string to list, removing whitespace.

get_parser()[source]
add_common_arguments(parser)[source]

Add common arguments to both SSH and Wallet parsers.

get_arguments(parser=None)[source]
load_environment_settings(args)[source]

Load environment settings from command-line arguments or environment variables, prioritizing args if provided, otherwise using environment variables.

Return type:

dict

merge_environment_settings(args)[source]

Merge environment settings with command-line arguments based on the selected priority.

run_monitor_ssh(args, logger)[source]
class WalletStateTracker(persist_file=None)[source]

Bases: object

get(address)[source]

주소별 캐시 데이터 반환

Return type:

dict

async update(address, new_data)[source]

변경 감지 및 업데이트 수행

Return type:

bool

async classmethod load_from_file(filename)[source]

파일에서 상태 복구

Return type:

WalletStateTracker

track_changes(old, new)[source]

변경 필드 식별 로직 분리

Return type:

dict

async worker(rpc, address)[source]

지갑 전체 데이터 반환

Return type:

dict

deep_filter_ignored(data, ignore_keys)[source]

중첩 구조에서 특정 키 재귀적으로 제거 (검색 결과 [3] 확장)

Return type:

Any

format_balance_change(old_val, new_val, ignore_decimal=False)[source]
  • ignore_decimal=True 이면, 소숫점 이하를 아예 무시(정수 변환).

  • ignore_decimal=False 이면, 소숫점 4자리까지 반올림하되, 실질적으로 정수면 정수 형태로.

Return type:

str

format_changes(changed_fields)[source]

변경 사항을 여러 줄 문자열로 포매팅

Return type:

str

async detect_changes(tracker, address, current_data, logger, ignore_keys=None, ignore_decimal_changes=False, is_send_slack=False)[source]
Return type:

bool

async run_continuous_monitoring(rpc, addresses, tracker, interval, logger, ignore_decimal_changes=False, is_send_slack=False)[source]
run_multi_wallet_monitoring(args, logger)[source]
run_wallet_client_with_websocket(args, logger)[source]
select_service_name()[source]

Show a simple menu to select between SSH and Wallet for docker-compose generation.

prompt_for_env_variables(settings)[source]

Prompt user to input values for settings. Use default values if provided. If a value is a list, it will be converted to a comma-separated string. Special handling for BASE_DIR and LOG_FILE defaults from ComposeDefaultSettings.

Parameters:

settings (dict) – Dictionary containing key-value pairs of settings.

Returns:

Dictionary with user-provided or default values.

Return type:

dict

run_compose_init(args, logger, parser)[source]
main()[source]

SSH and Wallet Monitoring Tool

Usage examples:

  1. Start monitoring SSH log files:

    pawns mon ssh -f /var/log/secure /var/log/auth.log

  2. Start the wallet client:

    pawns mon wallet –url https://example.com -vvv

Note

You can monitor multiple log files by providing multiple -f arguments.