Command Line Launcher

The command-line launcher tgcrawl.py:

  • Retrieves any command-line arguments

  • Sets default values for all parameters which fine-tune the program’s operation.

  • Optionally reads a configuration TOML file to override the default values of these parameters

  • Reads a network descriptor text file which provides the range of IP addresses (over which to crawl), as well as log-in credentials for the radios.

  • Calls the batch engine main API: TgCrawler.

Module Information

A Command line launcher for TgCrawl.

class tgtools.tgcrawl.CrawlLauncher(**kwargs)

The main API for launching the TgCrawl from the command line.

__init__(**kwargs)

Collect all program attributes, including command line arguments, and parameters specified in some ancilliary configuration text files.

get_credentials() Credentials

Read the network description (IP addresses, log-in credentials) from file network_filename. Automatically called by __init__().

print_summary()

Print summary of pending action. Automatically called by run().

read_script_file() list[str]

Read script file send_cmds_script_filename. Automatically called by validate().

Return type:

list[str]

read_toml_config()

Get program configurations from TOML file configs_filename, and attempt to override the default running parameters. Automatically called by __init__().

run()

Validate parameters, print a summary of pending actions, and run the TgCrawl batch engine (as determined by mode: either once, or repeatedly (polling).

validate() bool

Validate coherency of all attributes:

Automatically run by run().

Return type:

bool

action_local: bool

Action IP-accessible radios (whose IP addresses are denoted in network_filename). Default: True (but may be overridden by config_filename).

action_remote_cns: bool

Action IP-less radios (remote Client Nodes without a network-accessible IP address). Default: True (but may be overridden by config_filename).

action_remote_cns_list: list | None

Applicable if action_remote_cns is True: List of remote radio names for actions. If None: remote radios are automatically discovered and actions are applied to them all. Default: None (but may be overridden by config_filename).

concurrency: bool

If True: access radios concurrently (multiple threads); else: sequentially. Default: True (but may be overridden by config_filename).

concurrency_threads: int

Applicable if concurrency is True: maximum number of concurrent threads. Default: 10 (but may be overridden by config_filename).

config_filename: str

Name of TOML file overriding default running parameters. Default: ‘configs.toml’.

credentials: Credentials

Network credentials, as read from get_credentials().

debug_print: bool

Run with additional output to console Default: True (but may be overridden by config_filename).

dir_get_configs: str

Directory to save config files fetched from radios. Default: ‘configs’ (but may be overridden by config_filename).

dir_get_events: str

Directory to save events files fetched from radios. Default: ‘events’ (but may be overridden by config_filename).

dir_get_status: str

Directory to save parsed status (telemetry) files fetched from radios. Default: ‘get_status’ (but may be overridden by config_filename).

dir_get_status_xml: str

Directory to save raw XML telemetry files fetched from radios. Default: ‘get_status_xml’ (but may be overridden by config_filename).

dir_get_tech_logs: str

Directory to save tech_log files fetched from radios. Default: ‘configs’ (but may be overridden by config_filename).

dir_output_root: str

Path to output root directory. Default: ‘output’ (but may be overridden by config_filename).

get_configs: bool

Actions to include fetching configuration from radio. Default: False (but may be overridden by config_filename).

get_configs_db: str

Applicable if get_configs is True: type of configuration to fetch. Default: ‘startup’ (but may be overridden by config_filename).

get_configs_max_files: int

Applicable if get_configs is True: maximum number of files to save before rolling over. Default: 3 (but may be overridden by config_filename).

get_events: bool

Actions to include fetching events from radio. Default: True (but may be overridden by config_filename).

get_status: bool

Actions to include fetching comprehensive telemetry from radio, parsing and saving. Default: True (but may be overridden by config_filename).

get_status_xml: bool

Applicable if get_status is True: Save the raw XML response from radio. Default: False (but may be overridden by config_filename).

get_status_xml_max_files: int

Applicable if get_status is True: maximum number of files to save before rolling over. Default: 3 (but may be overridden by config_filename).

get_tech_log_max_files: int

Applicable if get_tech_logs is True: maximum number of files to save before rolling over. Default: 10 (but may be overridden by config_filename).

get_tech_logs: bool

Actions to include fetching the tech_log from radio. Default: False (but may be overridden by config_filename).

interactive: bool

Run in interactive mode. Default: True.

iteration_period

Applicable if mode is ‘poll’: Period of iterations. Default: 5 minutes (but may be overridden by config_filename).

logger

Console logger for this class.

mode: str

Mode of operation. Default: ‘once’.

network_filename: str

Name of file describing the network over which TgCrawl will ‘crawl’. Default: ‘network.txt’.

num_iterations: int

Applicable if mode is ‘poll’: Number of iterations (value of zero means: forever). Default: 0 (but may be overridden by config_filename).

send_cmds: bool

Actions to include sending a command script to radio. Default: False (but may be overridden by config_filename).

send_cmds_script_filename: str

Applicable if send_cmds is True: name of file containing the script. Default: ‘script.txt’ (but may be overridden by config_filename).

send_script_cmds: list[str]

Script commands as read from send_cmds_script_filename. Defaults to an empty list.

set_tod: bool

Actions to include setting the radio’s date and time based on the computer’s clock. Default: False (but may be overridden by config_filename).

set_tod_shift: float

Applicable if set_tod is True: a time shift (in hours) for cases where the computer is in a different timezone relative to the radios. Default: 0 (but may be overridden by config_filename).

silent: bool

Run in silent mode. Default: False.

tgtools.tgcrawl.main()

Interpret command line and launch appropriate program

tgtools.tgcrawl.parse_args()

Auxiliary function for parsing command-line arguments (using the standard argpass library).