nanome.api.plugin module

class Plugin(name, description, tags=None, has_advanced=False, permissions=None, integrations=None, version=None)[source]

Bases: object

Process that connects to NTS, and allows a user to access a PluginInstance.

When plugin process is running, an entry is added to the Nanome Stacks Menu.

When a user activates a Plugin, this class creates a PluginInstance object connected to the user’s Nanome session.

static create_parser()[source]

Command Line Interface for Plugins.

Moved into config.py, but there are plugins that retrieve parser from Plugin class. Leaving this here for backwards compatibility.

rtype: argsparser: args parser

custom_data = None
name

Name of plugin as shown in the Nanome Stacks menu.

plugin_id = -1
post_run
Function to call when the plugin is about to exit
Useful when using autoreload
pre_run
Function to call before the plugin runs and tries to connect to NTS
Useful when using autoreload
run(host=None, port=None, key=None)[source]
Starts the plugin by connecting to the server specified.
If arguments (-a, -p) are given when starting plugin, host/port will be ignored.
Function will return only when plugin exits.
Parameters:
  • host (str) – NTS IP address if plugin started without -a option
  • port (int) – NTS port if plugin started without -p option
set_custom_data(*args)[source]
Store arbitrary data to send to plugin instances
Parameters:args (Anything serializable) – Variable length argument list
static set_maximum_processes_count(max_process_nb)[source]
set_plugin_class(plugin_class)[source]
Set plugin class to instantiate when a new session is connected
The plugin class should interact with or override functions in PluginInstance to interact with Nanome
Parameters:plugin_class (PluginInstance) – Plugin class to instantiate
classmethod setup(name, description, tags, has_advanced, plugin_class, host=None, port=None, key=None, permissions=None, integrations=None)[source]
to_ignore