Skip to content

other

dev_tool.commands.other

log = logging.getLogger(__name__) module-attribute

OtherCommandGroup

Bases: CommandGroup

A command group for ungrouped operations.

This class provides commands for ungrouped operations such as directory access, version information, updates, and application exit.

The constructor for the SystemCommandGroup class.

This method initializes the command group with required services and registers all command methods.

Parameters:

  • updater (UpdateService) –

    The update service for checking and applying updates.

Source code in dev_tool/commands/other.py
def __init__(
        self,
        updater: UpdateService,
        ngrok: NgrokService
) -> None:
    """
    The constructor for the SystemCommandGroup class.

    This method initializes the command group with required services
    and registers all command methods.

    :param updater: The update service for checking and applying updates.
    """

    super().__init__()

    self.updater = updater
    self.ngrok = ngrok

updater = updater instance-attribute

ngrok = ngrok instance-attribute

__str__

The string representation of the command group.

This method returns the category name for the command group.

Returns:

  • str

    The category name as a string.

Source code in dev_tool/commands/other.py
def __str__(self) -> str:
    """
    The string representation of the command group.

    This method returns the category name for the command group.

    :return: The category name as a string.
    """

    return 'Other'

websites

A command that opens a submenu for websites.

This method returns a menu for accessing various websites.

Returns:

  • Menu

    A submenu for website access.

Source code in dev_tool/commands/other.py
@ordered_submenu(label='Open websites')
def websites(self) -> Menu:
    """
    A command that opens a submenu for websites.

    This method returns a menu for accessing various websites.

    :return: A submenu for website access.
    """

    items: list[Menu | MenuItem] = [
        MenuItem(
            label='Jira',
            action=CommandAction(command=self._open_stratus_jira)
        ),
        MenuItem(
            label='Confluence',
            action=CommandAction(command=self._open_stratus_confluence)
        ),
        MenuItem(
            label='GitHub',
            action=CommandAction(command=self._open_stratus_github)
        ),
        MenuItem(
            label='django-spire documentation',
            action=CommandAction(command=self._open_django_spire_documentation)
        ),
        MenuItem(
            label='dandy documentation',
            action=CommandAction(command=self._open_dandy_documentation)
        ),
        MenuItem(
            label='dev_tool documentation',
            action=CommandAction(command=self._open_dev_tool_documentation)
        ),
        MenuItem(
            label='Python documentation',
            action=CommandAction(command=self._open_python_documentation)
        ),
        MenuItem(
            label='Django documentation',
            action=CommandAction(command=self._open_django_documentation)
        )
    ]

    return Menu(title='Open websites', items=items)

open_directories

A command that opens a submenu for opening directories.

This method returns a menu for opening various project directories.

Returns:

  • Menu

    A submenu for directory access.

Source code in dev_tool/commands/other.py
@ordered_submenu(label='Open directories')
def open_directories(self) -> Menu:
    """
    A command that opens a submenu for opening directories.

    This method returns a menu for opening various project directories.

    :return: A submenu for directory access.
    """

    items: list[Menu | MenuItem] = [
        MenuItem(
            label='Open project directory',
            action=CommandAction(command=self._open_base_directory),
        ),
        MenuItem(
            label='Open Stratus directory',
            action=CommandAction(command=self._open_stratus_directory),
        ),
    ]

    return Menu(title='Open directories', items=items)

run_ngrok_proxy

Source code in dev_tool/commands/other.py
@ordered_command(label='Publicly expose an app with ngrok proxy')
def run_ngrok_proxy(self):
    default_address = 'http://127.0.0.1:8000'

    address_input = get_user_input(
        f'Enter the address the proxy should forward requests to (default: {default_address}):'
    )

    if not address_input.strip():
        address_input = default_address
    else:
        error_message = None

        url_pattern = r'^https?://(?:[-\w.]|(?:%[\da-fA-F]{2}))+(?::\d+)?(?:/[^\s]*)?$'
        if not re.match(url_pattern, address_input):
            error_message = f'Invalid address: {address_input}'

        if not error_message:
            address_parts = address_input.split(':')
            if len(address_parts) > 2:
                error_message = f'Invalid address: {address_input}'

        if error_message:
            CONTEXT.notification.error_banner(error_message)

            log.debug(error_message)

            return

    self.ngrok.run_public_proxy(address_input)

version

A command that displays the current version information.

This method retrieves and logs the current version of the application.

Source code in dev_tool/commands/other.py
@ordered_command(label='Show version information')
def version(self) -> None:
    """
    A command that displays the current version information.

    This method retrieves and logs the current version of the application.
    """

    version = CONTEXT.configuration.get_current_version()

    message = f'You are running v{version}'
    CONTEXT.notification.normal_text(message)

update

A command that updates the dev_tool to the latest version.

This method runs the update service to check for and apply updates, exiting the application if an update was applied.

Source code in dev_tool/commands/other.py
@ordered_command(label='Update the dev_tool')
def update(self) -> None:
    """
    A command that updates the dev_tool to the latest version.

    This method runs the update service to check for and apply updates,
    exiting the application if an update was applied.
    """

    message = 'Checking for updates...'
    CONTEXT.notification.normal_text(message)
    log.debug(message)

    if not self.updater.run():
        return

    sys.exit(2)

exit

A command that exits the application.

This method terminates the application with exit code 0.

Source code in dev_tool/commands/other.py
@ordered_command(label='Exit the application')
def exit(self) -> None:
    """
    A command that exits the application.

    This method terminates the application with exit code 0.
    """

    sys.exit(0)