InteractiveTomcatManager

class tomcatmanager.interactive_tomcat_manager.InteractiveTomcatManager

An interactive command line tool for the Tomcat Manager web application.

each command sets the value of the instance variable exit_code, which mirrors bash standard values for exit codes (available via $?)

EXIT_CODES = {0: 'success', 1: 'error', 2: 'usage', 127: 'command_not_found'}
BOOLEAN_VALUES = {'0': False, '1': True, 'f': False, 'false': False, 'n': False, 'no': False, 'off': False, 'on': True, 't': True, 'true': True, 'y': True, 'yes': True}
exit_codes = {'command_not_found': 127, 'error': 1, 'success': 0, 'usage': 2}
app_name = 'tomcat-manager'
app_author = 'tomcatmanager'
config = None
timeout = 10
status_prefix = '--'
status_to_stdout

Proxy property for feedback_to_output.

poutput(msg: Any = '', *, end: str = '\n') → None

Convenient shortcut for self.stdout.write(); by default adds newline to end if not already present.

Also handles BrokenPipeError exceptions for when a commands’s output has been piped to another process and that process terminates before the cmd2 command is finished executing.

Parameters:
  • msg – str - message to print to current stdout - anyting convertible to a str with ‘{}’.format() is OK
  • end – str - string appended after the end of the message if not already present, default a newline
perror(msg: Any = '', *, end: str = '\n', apply_style=False) → None

Print an error message or an exception.

Param:errmsg The error message to print. If None, then print information about the exception currently beging handled.
Param:exception_type From superclass. Ignored here.
Param:traceback_war From superclass. Ignored here.

If debug=True, you will get a full stack trace, otherwise just the exception.

pfeedback(msg: Any, *, end: str = '\n') → None

Print nonessential feedback.

Set quiet=True to suppress all feedback. If feedback_to_output=True, then feedback will be included in the output stream. Otherwise, it will be sent to sys.stderr.

emptyline()

Do nothing on an empty line

default(statement: cmd2.parsing.Statement)

what to do if we don’t recognize the command the user entered

docmd(func: Callable, *args, **kwargs) → Any

Call a function and return, printing any exceptions that occur

Sets exit_code to 0 and calls {func}. If func throws a TomcatError, set exit_code to 1 and print the exception

show_help_from(argparser: argparse.ArgumentParser)

Set exit code and output help from an argparser.

parse_args(parser: argparse.ArgumentParser, argv: List[T]) → argparse.Namespace

Use argparse to parse a list of arguments a-la sys.argv

do_help(args: str)

Show available commands, or help on a specific command.

config_parser = ArgumentParser(prog='config', usage=None, description='Edit or show the location of the user configuration file.', formatter_class=<class 'argparse.HelpFormatter'>, conflict_handler='error', add_help=True)
do_config(cmdline: cmd2.parsing.Statement)

Edit or show the location of the user configuration file.

help_config()

Show help for the ‘config’ command.

show_parser = ArgumentParser(prog='show', usage=None, description='Show all settings or a specific setting.', formatter_class=<class 'argparse.HelpFormatter'>, conflict_handler='error', add_help=True)
do_show(cmdline: cmd2.parsing.Statement)

Show all settings or a specific setting.

help_show()

Show help for the ‘show’ command.

settings_parser = ArgumentParser(prog='settings', usage=None, description="Show all settings or a specific setting. Synonym for 'show'.", formatter_class=<class 'argparse.HelpFormatter'>, conflict_handler='error', add_help=True)
do_settings(cmdline: cmd2.parsing.Statement)

Synonym for ‘show’ command.

help_settings()

Show help for the ‘settings’ command.

do_set(args: cmd2.parsing.Statement)

Change program settings.

help_set()

Show help for the ‘set’ command.

config_file

The location of the user configuration file.

Returns:The full path to the user configuration file, or None if self.appdirs has not been defined.
history_file

The location of the command history file.

Returns:The full path to the file where command history will be saved and loaded, or None if self.appdirs has not been defined.
load_config()

Open and parse the user config file and set self.config.

convert_to_boolean(value: Any)

Return a boolean value translating from other types if necessary.

connect_parser = ArgumentParser(prog='connect', usage='%(prog)s [-h] config_name\n %(prog)s [-h] url [user] [password]', description='connect to a tomcat manager instance', formatter_class=<class 'argparse.HelpFormatter'>, conflict_handler='error', add_help=True)
do_connect(cmdline: cmd2.parsing.Statement)

Connect to a tomcat manager instance.

help_connect()

Show help for the connect command.

which_parser = ArgumentParser(prog='which', usage=None, description='show the url of the tomcat server you are connected to', formatter_class=<class 'argparse.HelpFormatter'>, conflict_handler='error', add_help=True)
do_which(*args, **kwargs)

Show the url of the tomcat server you are connected to.

help_which()

Show help for the ‘which’ command.

deploy_local(args: argparse.Namespace, update: bool = False)

Deploy a local war file to the tomcat server.

deploy_server(args: argparse.Namespace, update: bool = False)

Deploy a war file to the tomcat server.

deploy_context(args: argparse.Namespace, update: bool = False)

Deploy a context xml file to the tomcat server.

deploy_parser = ArgumentParser(prog='deploy', usage=None, description='deploy an application to the tomcat server', formatter_class=<class 'argparse.HelpFormatter'>, conflict_handler='error', add_help=True)
do_deploy(*args, **kwargs)

Deploy an application to the tomcat server.

help_deploy()

Show help for the deploy command.

redeploy_parser = ArgumentParser(prog='redeploy', usage=None, description='deploy an application to the tomcat server, undeploying any application at the given path', formatter_class=<class 'argparse.HelpFormatter'>, conflict_handler='error', add_help=True)
do_redeploy(*args, **kwargs)

Redeploy an application to the tomcat server.

help_redeploy()

Show help for the redeploy command.

undeploy_parser = ArgumentParser(prog='undeploy', usage=None, description='Remove an application at a given path from the tomcat server.', formatter_class=<class 'argparse.HelpFormatter'>, conflict_handler='error', add_help=True)
do_undeploy(*args, **kwargs)

Remove an application from the tomcat server.

help_undeploy()

Help for the ‘undeploy’ command.

start_parser = ArgumentParser(prog='start', usage=None, description="Start a tomcat application that has been deployed but isn't running.", formatter_class=<class 'argparse.HelpFormatter'>, conflict_handler='error', add_help=True)
do_start(*args, **kwargs)

Start a deployed tomcat application that isn’t running.

help_start()

Help for the ‘start’ command.

stop_parser = ArgumentParser(prog='stop', usage=None, description='Stop a running tomcat application and leave it deployed on the server.', formatter_class=<class 'argparse.HelpFormatter'>, conflict_handler='error', add_help=True)
do_stop(*args, **kwargs)

Stop a tomcat application and leave it deployed on the server.

help_stop()

Help for the ‘stop’ command.

reload_parser = ArgumentParser(prog='reload', usage=None, description="Start and stop a tomcat application. Synonym for 'restart'.", formatter_class=<class 'argparse.HelpFormatter'>, conflict_handler='error', add_help=True)
do_reload(*args, **kwargs)

Start and stop a tomcat application.

help_reload()

Help for the ‘reload’ command.

restart_parser = ArgumentParser(prog='restart', usage=None, description='Start and stop a tomcat application.', formatter_class=<class 'argparse.HelpFormatter'>, conflict_handler='error', add_help=True)
do_restart(*args, **kwargs)

Start and stop a tomcat application.

help_restart()

Show help for the ‘restart’ command.

sessions_parser = ArgumentParser(prog='sessions', usage=None, description='Show active sessions for a tomcat application.', formatter_class=<class 'argparse.HelpFormatter'>, conflict_handler='error', add_help=True)
do_sessions(*args, **kwargs)

Show active sessions for a tomcat application.

help_sessions()

Help for the ‘sessions’ command.

expire_parser = ArgumentParser(prog='expire', usage=None, description='expire idle sessions', formatter_class=<class 'argparse.HelpFormatter'>, conflict_handler='error', add_help=True)
do_expire(*args, **kwargs)

Expire idle sessions.

help_expire()

Help for the ‘expire’ command.

list_parser = ArgumentParser(prog='list', usage=None, description='Show all installed applications', formatter_class=<class 'argparse.HelpFormatter'>, conflict_handler='error', add_help=False)
do_list(*args, **kwargs)

Show all installed applications.

help_list()

Show help for the ‘list’ command.

serverinfo_parser = ArgumentParser(prog='serverinfo', usage=None, description='show information about the tomcat server', formatter_class=<class 'argparse.HelpFormatter'>, conflict_handler='error', add_help=True)
do_serverinfo(*args, **kwargs)

Show information about the tomcat server.

help_serverinfo()

Show help for the ‘serverinfo’ command.

status_parser = ArgumentParser(prog='status', usage=None, description='show server status information in xml format', formatter_class=<class 'argparse.HelpFormatter'>, conflict_handler='error', add_help=True)
do_status(*args, **kwargs)

Show server status information in xml format.

help_status()

Show help for the ‘status’ command.

vminfo_parser = ArgumentParser(prog='vminfo', usage=None, description='show diagnostic information about the jvm', formatter_class=<class 'argparse.HelpFormatter'>, conflict_handler='error', add_help=True)
do_vminfo(*args, **kwargs)

Show diagnostic information about the jvm.

help_vminfo()

Show help for the ‘vminfo’ command.

sslconnectorciphers_parser = ArgumentParser(prog='sslconnectorciphers', usage=None, description='show SSL/TLS ciphers configured for each connector', formatter_class=<class 'argparse.HelpFormatter'>, conflict_handler='error', add_help=True)
do_sslconnectorciphers(*args, **kwargs)

Show SSL/TLS ciphers configured for each connector.

help_sslconnectorciphers()

Show help for the ‘sslconnectorciphers’ command.

threaddump_parser = ArgumentParser(prog='threaddump', usage=None, description='show a jvm thread dump', formatter_class=<class 'argparse.HelpFormatter'>, conflict_handler='error', add_help=True)
do_threaddump(*args, **kwargs)

Show a jvm thread dump.

help_threaddump()

Show help for the ‘threaddump’ command.

resources_parser = ArgumentParser(prog='resources', usage=None, description='show global JNDI resources configured in tomcat', formatter_class=<class 'argparse.HelpFormatter'>, conflict_handler='error', add_help=True)
do_resources(*args, **kwargs)

Show global JNDI resources configured in Tomcat.

help_resources()

Show help for the ‘resources’ command.

findleakers_parser = ArgumentParser(prog='findleakers', usage=None, description='show tomcat applications that leak memory', formatter_class=<class 'argparse.HelpFormatter'>, conflict_handler='error', add_help=True)
do_findleakers(*args, **kwargs)

Show tomcat applications that leak memory.

help_findleakers()

Show help for the ‘findleakers’ command.

do_exit(_)

Exit the interactive command prompt.

do_quit(cmdline: cmd2.parsing.Statement)

Synonym for the ‘exit’ command.

do_eof(cmdline: cmd2.parsing.Statement)

Exit on the end-of-file character.

version_parser = ArgumentParser(prog='version', usage=None, description='show the version number of this program', formatter_class=<class 'argparse.HelpFormatter'>, conflict_handler='error', add_help=True)
do_version(cmdline: cmd2.parsing.Statement)

Show the version number of this program.

help_version()

Show help for the ‘version’ command.

exit_code_epilog = ['The codes have the following meanings:', ' 0 success', ' 1 error', ' 2 usage', ' 127 command not found']
exit_code_parser = ArgumentParser(prog='exit_code', usage=None, description='show a number indicating the status of the previous command', formatter_class=<class 'argparse.RawDescriptionHelpFormatter'>, conflict_handler='error', add_help=True)
do_exit_code(_)

Show a number indicating the status of the previous command.

help_exit_code()

Show help for the ‘exit_code’ command.

license_parser = ArgumentParser(prog='license', usage=None, description='show the software license for this program', formatter_class=<class 'argparse.HelpFormatter'>, conflict_handler='error', add_help=True)
do_license(cmdline: cmd2.parsing.Statement)

Show the software license for this program.

help_license()

Show help for the ‘license’ command.

name = 'command_not_found'
number = 127