powermolegui.lib package

Submodules

powermolegui.lib.animation module

Main code for transforming tkinter canvas items.

class powermolegui.lib.animation.AnimateItem(main_window, canvas_item)[source]

Bases: object

Animates the canvas item by moving horizontally in one direction and loop.

pause()[source]

Temporarily pause moving the TCP/IP package.

resume()[source]

Resume moving the TCP/IP package.

start()[source]

Moves a TCP/IP packet from item to another item and loop.

stop()[source]

Stop moving the TCP/IP packet and cleanup.

powermolegui.lib.application module

Main code for creating tkinter frames.

The frames are used as a container for other widgets.

powermolegui.lib.application.application(main_window)[source]

Executes the business logic.

To be executed in a separate thread, to avoid interference with the widgets.

powermolegui.lib.frames module

Main code for creating tkinter frames.

The frames are used as a container for other widgets.

class powermolegui.lib.frames.CanvasFrame(parent)[source]

Bases: Frame

Constructs a frame for the canvas widget.

class powermolegui.lib.frames.CommandEntry(parent)[source]

Bases: Frame

Constructs a frame for the text widget.

class powermolegui.lib.frames.CommandFrame(parent, *args, **kwargs)[source]

Bases: Frame

Constructs an outer frame that contains two log frames.

class powermolegui.lib.frames.CommandResponse(parent)[source]

Bases: Frame

Constructs a frame for the text widget.

class powermolegui.lib.frames.LogFrame(parent)[source]

Bases: Frame

Constructs a frame for the text widget.

insert_log_line(line)[source]

____________.

class powermolegui.lib.frames.MainFrame(parent, scale, *args, **kwargs)[source]

Bases: Frame

Constructs an outer frame that contains a canvas and a log frame.

powermolegui.lib.helpers module

Import all parts from helpers here.

class powermolegui.lib.helpers.AgentAdapter(item)[source]

Bases: object

Adapts an agent object to a representational state for the GUI.

stop()[source]

Stops.

class powermolegui.lib.helpers.ClientAdapter(item)[source]

Bases: object

Adapts a client object to a representational state for the GUI.

stop()[source]

Stops.

class powermolegui.lib.helpers.HostAdapter(items)[source]

Bases: object

Adapts a host object to a representational state for the GUI.

stop()[source]

Stops.

class powermolegui.lib.helpers.ItemsGenerator(main_window, configuration)[source]

Bases: LoggerMixin

Creates items for the components Client, Connection(s), Host(s) and Agent.

create_canvas_items()[source]

Create all items and hide.

The number of host items are derived on the total amount of hosts. The ConnectionCanvasItem needs not-hidden items to create a connection_canvas_item as it uses bbox. Bbox cannot work with hidden items. Once all canvas items are created, they are hidden.

Returns:

  • element 0: client - the Client is given an unique position on the X-axis.

  • element 1: [hosts] - each Host is given an unique position on the X-axis.

  • element 2: [connection] - each Connection is given its from and to destination.

  • element 3: agent - an Agent is a ‘child’ of the target destination host.

Return type:

A list containing items. Each type of item has its own position

show_landscape(canvas_items)[source]

Shows the shapes of Client and Host(s).

Modifying the scroll region only works after the items have been changed (“configured”) from hidden to normal.

Bases: LoggerMixin

Establishes a connection to target destination host via intermediaries by starting various objects.

This function also passes the instantiated objects to the StateManager, which will stop the Tunnel and Instructor after a KeyboardInterrupt.

start()[source]

Starts setting up link.

start_bootstrap_agent()[source]

Starts bootstrapping the agent by executing agent module on destination host.

start_client()[source]

Shows the client item.

This method also adds the instance of the client adapter to the context manager.

start_instructor()[source]

Starts the Instructor and checks if the Agent can be reached.

start_transfer_agent()[source]

Starts transferring Agent to destination host.

start_tunnel()[source]

Starts setting up the Tunnel with forwarded connections used by Instructor.

class powermolegui.lib.helpers.StateVisualiser(heartbeat, animated_packet, status_item)[source]

Bases: object

Shows the state of the encrypted tunnel by a banner and by visualising the packet flow.

start()[source]

Start continuously determining the state of the tunnel.

class powermolegui.lib.helpers.TunnelAdapter(object_, items)[source]

Bases: object

Adapts a tunnel object to a representational state for the GUI.

stop()[source]

Stops.

powermolegui.lib.helpers.parse_configuration_file(config_file_path)[source]

Parses the configuration file to a (dictionary) object.

powermolegui.lib.items module

Main code for various tkinter canvas items.

class powermolegui.lib.items.AgentCanvasItem(main_window, client_canvas_item, host_canvas_items)[source]

Bases: CanvasItem

Creates a canvas item representing an Agent.

create()[source]

Creates the canvas item.

dim()[source]

Colours the canvas item representing a non-operational state.

hide()[source]

Hides the canvas item.

move()[source]

Moves the Agent item from Client item to destination Host item.

setup_nok()[source]

Colours the canvas item in accordance with an NOK state.

setup_ok()[source]

Colours the canvas item in accordance with an OK state.

show()[source]

Shows the canvas item.

transfer_nok()[source]

Colours the outline red and changes the outline to have a dashed pattern.

transfer_ok()[source]

Colours the outline white and changes the outline into a solid pattern.

class powermolegui.lib.items.CanvasItem(main_window)[source]

Bases: ABC

Enforces methods to be implemented for the subclassed objects.

abstract create()[source]

Creates the canvas item.

abstract dim()[source]

Colours the canvas item representing a non-operational state.

abstract hide()[source]

Hides the canvas item.

abstract setup_nok()[source]

Colours the canvas item in accordance with an NOK state.

abstract setup_ok()[source]

Colours the canvas item in accordance with an OK state.

abstract show()[source]

Shows the canvas item.

class powermolegui.lib.items.ClientCanvasItem(main_window, start_pos_x, start_pos_y)[source]

Bases: CanvasItem

Creates a canvas item representing a client.

create()[source]

Creates the canvas item.

dim()[source]

Colours the canvas item representing a non-operational state.

hide()[source]

Hides the canvas item.

setup_nok()[source]

Colours the canvas item in accordance with an NOK state.

setup_ok()[source]

Colours the canvas item in accordance with an OK state.

show()[source]

Shows the canvas item.

class powermolegui.lib.items.ConnectionCalculator(main_window, canvas_item_1, canvas_item_2)[source]

Bases: object

Calculates all properties that is needed to render a connection between two canvas items.

get_connection_height()[source]

Returns the height of a connection based on the height of the item.

get_connection_length_inner()[source]

Returns the distance between two items starting from right side first item to left side second item.

get_connection_length_outer()[source]

Returns the distance between two items starting from right side first item to left side second item.

get_x_pos_connection_left_side()[source]

Returns the starting position on the X-axis of the connection item.

get_x_pos_connection_right_side()[source]

Returns the starting position on the X-axis of the connection item.

get_y_pos_connection()[source]

Returns the first position on the Y-axis of the connection item.

class powermolegui.lib.items.ConnectionCanvasItem(main_window, canvas_item_1, canvas_item_2)[source]

Bases: CanvasItem

Creates a canvas item representing a connection.

create()[source]

Creates the canvas item.

dim()[source]

Colours the canvas item representing a non-operational state.

hide()[source]

Hides the canvas item.

setup_nok()[source]

Colours the canvas item in accordance with an NOK state.

setup_ok()[source]

Colours the canvas item in accordance with an OK state.

show()[source]

Shows the canvas item.

class powermolegui.lib.items.Effect(main_window, canvas_item, filling_type)[source]

Bases: object

Applies effects to the canvas item.

This class provides methods to colour the canvas item in accordance with the operational state and provide a method to make the canvas item flicker.

dim()[source]

Colours the canvas item to a non-operational state (white).

To colour the outline of ‘rectangles’, the outline has to be configured. To colour the items made of ‘lines’, the fill has to be configured.

flicker()[source]

Changes the brightness of the canvas item irregularly appearing as a fluctuating light.

The after function is threaded, so it doesn’t block.

setup_nok()[source]

Colours the canvas item to state NOK (red).

setup_ok()[source]

Colours the canvas item to state OK (green).

class powermolegui.lib.items.HostCanvasItem(main_window, start_pos_x, start_pos_y, host_ip)[source]

Bases: CanvasItem

Creates a canvas item representing a host.

create()[source]

Creates the canvas item.

dim()[source]

Colours the canvas item representing a non-operational state.

hide()[source]

Hides the canvas item.

setup_nok()[source]

Colours the canvas item in accordance with an NOK state.

setup_ok()[source]

Colours the canvas item in accordance with an OK state.

show()[source]

Shows the canvas item.

class powermolegui.lib.items.PacketCanvasItem(main_window, connection_canvas_items)[source]

Bases: CanvasItem

Creates a visualised TCP packet.

create()[source]

Creates the canvas item.

dim()[source]

Colours the canvas item representing a non-operational state.

hide()[source]

Hides the canvas item.

setup_nok()[source]

Colours the canvas item in accordance with an NOK state.

setup_ok()[source]

Colours the canvas item in accordance with an OK state.

show()[source]

Shows the canvas item.

class powermolegui.lib.items.StatusBannerCanvasItem(main_window)[source]

Bases: CanvasItem

Creates a status banner.

create()[source]

Creates the canvas item.

dim()[source]

Colours the canvas item representing a non-operational state.

hide()[source]

Hides the canvas item.

setup_nok()[source]

Colours the canvas item in accordance with an NOK state.

setup_ok()[source]

Colours the canvas item in accordance with an OK state.

show(state=None)[source]

Shows the canvas item.

powermolegui.lib.logging module

Main code for logging.

class powermolegui.lib.logging.LoggerMixin[source]

Bases: object

Contains a logger method for use by other classes.

class powermolegui.lib.logging.LoggingHandler(main_window)[source]

Bases: Handler

A handler for sending logging events to LoggingWindow.

Handlers send the log records (created by loggers) to the appropriate destination. In this case, it invokes the insert_log_line() of LoggingWindow and passes the filtered message (for log level INFO) to be rendered on screen in the GUI.

emit(record)[source]

Do whatever it takes to actually log the specified logging record.

This version is intended to be implemented by subclasses and so raises a NotImplementedError.

powermolegui.lib.windows module

Main code for tkinter windows.

class powermolegui.lib.windows.CollectionMenuBars(file_menu: Menu, execution_menu: Menu, send_menu: Menu, logging_menu: Menu, quit_menu: Menu)[source]

Bases: object

Holds the menu bars.

execution_menu: Menu
file_menu: Menu
logging_menu: Menu
quit_menu: Menu
send_menu: Menu
class powermolegui.lib.windows.CommandWindow(parent, *args, **kwargs)[source]

Bases: Toplevel

Represents an interface for the user to send commands to destination host and show output.

close_window()[source]

Closes this top level widget.

send_command()[source]

Captures the input of the user and shows output returned from *Instructor.

class powermolegui.lib.windows.MainWindow(*args, **kwargs)[source]

Bases: Tk, LoggerMixin

Represents the main window of an application.

In an Tkinter application, the instance of the Tk class represents the main window.

change_state_menu_bar_entry(entry, label, state)[source]

Changes the state of the menu bar.

close_window()[source]

Closes the window.

config_file_dialog()[source]

Shows the file dialog.

open_command_window()[source]

Opens interface for the user to send commands to last host and show output.

retrieve_recently_opened()[source]

Retrieves the recently opened configuration file stored in /settings.

run_application()[source]

Starts the application.

stop_application()[source]

Sets the should_terminate var to True.

The application is running indefinitely until the user hits ctrl + c in the window. The window widget will capture the event, and sets the var should_terminate to True. The application, polling this var, will break the loop, and dismantles the tunnel.

class powermolegui.lib.windows.TransferWindow(*args, **kwargs)[source]

Bases: Toplevel

Represents an interface for the user to select files locally to be copied to destination host.

IN DEVELOPMENT!

powermolegui.lib.windows.determine_scale(screen_width)[source]

Sets the width of the application screen depending on type of screen.

Module contents

Import all parts from powermolegui.lib here.