Warning
Please know that the API is not stable at this time. API changes, additions and removals are only documented in the release changelogs, so make sure to read them. Things should stabilize once HPX enters beta status.
The plugin interface module is named __hpx__
.
Import it in your plugin to access the methods and classes defined by the module:
import __hpx__ as hpx
logger = hpx.get_logger(__name__)
In addition to what is defined here, exceptions and enums defined by HPX are also available at the module-level and can be imported like so:
import __hpx__ as hpx
from __hpx__ import PluginError, PluginState
print(PluginState) # -> <enum 'PluginState'>
print(hpx.ImageSize) # -> <enum 'ImageSize'>
raise PluginError("", "")
raise hpx.PluginError("", "")
command
The object command
is available on the module-level and provides access to the various different commands defined by HPX:
from __hpx__ import command
command.CheckUpdate()
See Commands for all the various commands available information.
constants
The object constants
is available on the module-level and provides various useful constant values.:
from __hpx__ import constants
print(constants.version) # -> (0, 0, 0)
version: current HPX version
database_version: current HPX database version
webclient_version: current HPX webclient version
dev: developer mode enabled
debug: debug mode enabled
is_frozen: application has been made into an executable
is_osx: application is running on OS X
is_linux: application is running on Linux
is_win: application is running on Windows
is_posix: application is running on a posix-compliant OS (true for both OS X and Linux)
download_path: path to the downloads folder
tumbnail_path: path to the thumbnails folder
translation_path: path to the translations folder
current_dir: path to the plugin’s folder
current_dir : str =
database_version : tuple = (0, 9, 0)
debug : bool = False
dev : bool = False
download_path : str = downloads
is_frozen : bool = False
is_linux : bool = True
is_osx : bool = False
is_posix : bool = True
is_win : bool = False
thumbnail_path : str = static/thumbnails
translation_path : str = translations
version : tuple = (0, 13, 3)
webclient_version : tuple = (0, 13, 1)
addfilter
(f=None, command=None, on=None)¶Add a callable to a pipeline command
f (Optional
[Callable
]) – a callable
command (Optional
[str
]) – name of pipeline command
on (Optional
[str
]) – on a specific action
attach
(f=None, command=None, trigger=None)¶Attach a handler to a command entry
f (Optional
[Callable
]) – command handler
command (Optional
[str
]) – a fully qualified command name, required
trigger (Union
[str
, list
, tuple
, None
]) – trigger only on a special keyword
get_logger
(name=None)¶Get the logging.Logger
object for this plugin
name (Optional
[str
]) – name of logger
get_plugin_config
()¶Get a dict-like object with configuration specific to this plugin
dict-like object
get_setting
(namespace, key, default=<class 'happypanda.core.plugin_interface._NO_DEFAULT'>)¶Get the value of any setting in the configuration. See Settings.
namespace (str
) – setting namespace
key (str
) – setting key
default – default value if no key was found
value of setting or default value if default was set, else raise a KeyError
removefilter
(f=None, command=None, on=None)¶Remove a callable from a pipeline command
f (Optional
[Callable
]) – a callable
command (Optional
[str
]) – name of pipeline command
on (Optional
[str
]) – on a specific action
a boolean indicating whether the filter was removed
save_plugin_config
(obj)¶Save configuration specific to this plugin
The configuration will appear in the plugin.config.<plugin shortname>
namespace.
obj (dict
) – dict-like object
bool on if config was saved
subscribe
(f=None, commandevent=None, trigger=None)¶Subscribe a handler to a command event
f (Optional
[Callable
]) – command event handler
commandevent (Optional
[str
]) – a fully qualified command event name, required
trigger (Union
[str
, list
, tuple
, None
]) – trigger only on a special keyword
update_setting
(namespace, key, value, user=True)¶Update the value of any setting in the configuration. See Settings.
namespace (str
) – setting namespace
key (str
) – setting key
value (Union
[dict
, list
, int
, float
, tuple
, str
]) – value to set
user (bool
) – the value should only apply to the current client user. Note that a user haven’t necessarily been assigned.
Besides the command entries and events listed here, HPX also provides some plugin meta events that are specific for each plugin.
These events are emitted on plugin state changes. See PluginState
for the different kinds of plugin states.
init
– this event is emitted for a plugin after it has initialized and after all its dependencies has been initialized.It is therefore ideal to put the plugin’s own initialization on this event.
disable
– this event is emitted when a plugin has been disabled, either manually by the user or because of some other cause.The plugin should listen to this event to terminate any on-going process it has running.
remove
– this event is emitted just before a plugin is to be removed. HPX will handle the deletion of the plugin folder.The disable
event will always be emitted before this event. The plugin should listen to this event to remove any produced items
that would still be lingering even after its folder has been deleted.
before_update
– this event is emitted just before a plugin is updated.The plugin should listen to this event to perform actions before it is updated.
after_update
– this event is emitted just after a plugin has been updated.The plugin should listen to this event to perform actions after it has been updated.
config_update (dict)
– this event is emitted with a dict
of configuration that has been updated, usually from a client.The plugin should listen to this event to be notified when its configuration has been updated.
These are special entries each plugin can attach to.
message (dict) -> dict
– this entry is called is called with a message, usually from a client. A dict
is expected to be returned.The plugin should attach to this entry when wanting to exchange messages with a client or another plugin.
Meta
|
Backup the application |
|
Check for new plugin release |
|
Check for new release |
|
|
|
Initialize the appplication |
|
Notify client |
|
Trigger a reindex |
|
Remove a callable to a pipeline command |
|
Restart the appplication |
|
Restore the application from a backup |
|
Shutdown the appplication |
|
Sweeps trashed items |
|
Check for new release and update the application |
|
Check for new release and update a plugin |
I/O
|
Clean the provided folder |
|
Encapsulates path on the filesystem |
|
Delete path or database item files from filesystem |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Encapsulates an gallery object on the filesystem :type path_or_dbitem: |
|
Generate an image from source image |
|
|
|
Extract several components from a gallery name (usually a filename) |
|
|
|
|
|
Watch a directory for file system changes |
Database
|
Delete a database item |
|
Get database model item by name |
|
Returns a name or, a namedtuple(expr, joins) of a data sort expression and additional tables to join, for a given sort index |
|
|
|
Fetch a database model item’s image |
|
Fetch model items from the database |
|
Get a database session |
|
Get the most common tags for item |
|
Update database items |
|
Update a database item’s attribute |
Item
|
Get logs for item |
|
Watches a specified directory for supported items |
|
Log a message for item |
|
A convenience wrapper around LogItem |
|
A convenience wrapper around LogItem |
|
A convenience wrapper around LogItem |
|
A convenience wrapper around LogItem |
|
A convenience wrapper around LogItem |
|
Move database item files on filesystem |
|
Set/update configuration for item |
|
Update a GalleryProgress |
|
Gallery
|
Open a gallery in an external viewer |
|
|
|
Get a list of similar galleries to given gallery |
|
Synchronise the gallery source with the database, meaning if the source is a path on the filesystem, it will rescan the source for any possibly new items for given item. |
Item Data
|
|
|
|
|
|
|
Base Data |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Base operation |
|
|
|
|
|
|
|
|
|
|
|
A remove operation |
|
An append operation |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Login
|
Get the login session if logged in, else None |
|
Check if user is logged in |
|
Get login status text |
|
|
|
Metadata
|
Fetch metadata |
|
|
|
|
|
|
|
Search
|
Index data |
|
|
|
Perform a partial search on database model with a single term |
|
Perform a full search on database model |
|
Parse a search query. |
|
Parse a single term |
|
Convert a list of ns:tag from ParseSearch to an ESearch query. |
|
used to encapsulate a single term, e.g: |
|
Update filters |
|
|
|
Network
|
An enumeration. |
|
A convenience wrapper around MultiRequest for GET requests |
|
A convenience wrapper around MultiRequest for POST requests |
|
Make multiple HTTP requests |
|
|
|
A request response. |
|
A convenience wrapper around SingleRequest for GET requests |
|
A convenience wrapper around SingleRequest for POST requests |
|
Make a HTTP request |
Download
|
|
|
|
|
|
|
|
|
|
|
Error
happypanda.core.commands.meta_cmd
ImageProperties
(size=ImageSize(width=200, height=276), radius=0, output_dir=None, output_path=None, name=None, create_symlink=True, crop=False)¶create_symlink
: bool¶create an artificial symlink til the source image instead of copying it (only useful if image size isn’t modified)
crop
: bool¶crop the image when scaling to keep aspect ratio
name
: str¶name of image file when saved to output_dir
, else a random name will be generated
output_dir
: str¶folder to save the image to
output_path
: str¶path to save the image to, this and output_dir
are mutually exclusive
radius
: int¶corner radius
size
: happypanda.common.utils.ImageSize¶size of image, a utils.ImageSize
object
Error
happypanda.core.commands.io_cmd
Error
happypanda.core.commands.database_cmd
Error
happypanda.core.commands.item_cmd
Error
happypanda.core.commands.gallery_cmd
Error
happypanda.core.commands.login_cmd
Error
happypanda.core.commands.metadata_cmd
Term
= NamedTuple¶used to encapsulate a single term, e.g:
pages::>5
where pages
is the namespace,
>
is the operator and 5
is the tag
Error
happypanda.core.commands.search_cmd
Method
(value)¶An enumeration.
DELETE
= 'delete'¶DELETE
GET
= 'get'¶GET
HEAD
= 'head'¶HEAD
OPTIONS
= 'options'¶OPTIONS
POST
= 'post'¶POST
PUT
= 'put'¶PUT
RequestProperties
(method=None, name='', session=None, timeout=None, proxy=None, headers=None, files=None, data=None, json=None, params=None, auth=None, cookies=None, stream=False, stream_callback=None, progress=False)¶auth
¶auth
cookies
data
¶data
files
¶files
headers
¶headers
json
¶json
method
: happypanda.core.commands.network_cmd.Method¶a Method
object
params
¶params
progress
¶progress
proxy
¶proxy
session
: bool¶set to True for new session, None for default session, False for no session, or to a custom session
stream
¶stream
stream_callback
¶stream_callback
timeout
: int¶request timeout
GetDefaultSession
()¶Retrieve the default session
Available entries:
Available events:
MultiGETRequest
(*args, **kwargs)¶A convenience wrapper around MultiRequest for GET requests
Available entries:
Available events:
MultiPOSTRequest
(*args, **kwargs)¶A convenience wrapper around MultiRequest for POST requests
Available entries:
Available events:
MultiRequest
(*args, **kwargs)¶Make multiple HTTP requests
Available entries:
Available events:
Response
(_url, _request_method, _request_kwargs, _props, _session)¶A request response. Not meant to be instanced publicly.
Available entries:
Available events:
SingleGETRequest
(*args, **kwargs)¶A convenience wrapper around SingleRequest for GET requests
Available entries:
Available events:
SinglePOSTRequest
(*args, **kwargs)¶A convenience wrapper around SingleRequest for POST requests
Available entries:
Available events:
SingleRequest
(*args, **kwargs)¶Make a HTTP request
Available entries:
Available events:
Error
happypanda.core.commands.download_cmd