pawnlib.cli package
from pawnlib.cli import *
Submodules
pawnlib.cli.aws module
from pawnlib.cli import aws
pawnlib.cli.compose module
from pawnlib.cli import compose
- 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:
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
- 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
- main()[source]
Genesis Tool
Usage examples:
- Generate a genesis file from a genesis.json file:
pawns gs gen -i genesis.json -o icon_genesis.zip
- 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 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]
-
url:
- 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
- apply_config_values(config_instance, section_name, section_value)[source]
섹션 값들을 AppConfig 인스턴스에 적용합니다.
- 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:
- Basic usage:
pawns http https://example.com
- Verbose mode:
pawns http https://example.com -v
- Using custom headers and POST method:
pawns http https://example.com -m POST –headers ‘{“Content-Type”: “application/json”}’ –data ‘{“param”: “value”}’
- Ignoring SSL verification and setting a custom timeout:
pawns http https://example.com –ignore-ssl True –timeout 5
- Checking with specific success criteria and logical operator:
pawns http https://example.com –success ‘status_code==200’ ‘response_time<2’ –logical-operator and
- Running with a custom config file and interval:
pawns http https://example.com -c http_config.ini -i 3
- Setting maximum workers and stack limit:
pawns http https://example.com -w 5 –stack-limit 10
- Dry run without actual HTTP request:
pawns http https://example.com –dry-run
- Sending notifications to a Slack URL on failure:
pawns http https://example.com –slack-url ‘https://hooks.slack.com/services/…’
- 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==200slack_url =interval = 3method = get; data = sdsddata = {“sdsd”: “sd222sd”}[post]url = http://httpbin.org/postmethod = 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
- main()[source]
This command displays server resource information. This tool provides a detailed overview of your server’s system and network resources.
- Usage examples:
Display all resource information in verbose mode: - Displays detailed information about system and network resources.
pawns info -v
Run in quiet mode without displaying any output: - Executes the script without showing any output, useful for logging purposes.
pawns info -q
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
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
- 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:
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
- 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:
Query network information:
Fetches block information by height.
pawns rpc –url <RPC_ENDPOINT> –method icx_getBlockByHeight –params ‘{“height”:”0x1”}’
Send ICX transaction:
Sends an ICX transaction to the network.
pawns rpc –url <RPC_ENDPOINT> –method icx_sendTransaction –params <TRANSACTION_PARAMETERS>
Configure network settings:
Sets the network configuration for subsequent operations.
pawns rpc –platform icon –network mainnet
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
- class EchoWebServer(listen, forward, buffer_size, delay)[source]
Bases:
object- input_list = []
- channel = {}
- 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:
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
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
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
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
- 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:
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
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
- 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:
Basic Monitoring: Monitor system resources with default settings. Example: pawns top
Detailed View: Use -v to increase verbosity and get more detailed logs. Example: pawns top -v
Minimal Output: Use -q for quiet mode to suppress standard output. Example: pawns top -q
Custom Update Interval: Adjust the refresh rate with -i to set the interval in seconds. Example: pawns top -i 5
Output Formats: Choose between ‘live’ and ‘line’ output styles with -t. Example: pawns top -t live
Network-Specific Monitoring: Focus solely on network traffic and protocols. Example: pawns top net
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.
pawnlib.cli.wallet module
from pawnlib.cli import wallet
- 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:
Create a new wallet:
This command creates a new wallet and outputs the keystore file and address.
pawns wallet create
Load an existing wallet using a private key:
Loads a wallet from the provided private key.
pawns wallet load –private-key YOUR_PRIVATE_KEY
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
- 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:
Connect to Goloop network via WebSocket: - Connects to the Goloop network via WebSocket using the specified URL.
pawns websocket http://example.com/ws
Specify the starting block height: - Specifies the starting block height as 1000.
pawns websocket https://example.com/ws -b 1000
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'
- 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.
- class WalletStateTracker(persist_file=None)[source]
Bases:
object
- 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
- 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]
- 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