mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Add /plugins python_version command
This commit is contained in:
parent
b48a3d2f6a
commit
4209b1cf45
@ -711,6 +711,7 @@ cmd_ac_init(void)
|
|||||||
autocomplete_add(plugins_ac, "load");
|
autocomplete_add(plugins_ac, "load");
|
||||||
autocomplete_add(plugins_ac, "unload");
|
autocomplete_add(plugins_ac, "unload");
|
||||||
autocomplete_add(plugins_ac, "reload");
|
autocomplete_add(plugins_ac, "reload");
|
||||||
|
autocomplete_add(plugins_ac, "python_version");
|
||||||
|
|
||||||
filepath_ac = autocomplete_new();
|
filepath_ac = autocomplete_new();
|
||||||
|
|
||||||
|
@ -1982,14 +1982,16 @@ static struct cmd_t command_defs[] =
|
|||||||
"/plugins install <path>",
|
"/plugins install <path>",
|
||||||
"/plugins unload <plugin>",
|
"/plugins unload <plugin>",
|
||||||
"/plugins load <plugin>",
|
"/plugins load <plugin>",
|
||||||
"/plugins reload [<plugin>]")
|
"/plugins reload [<plugin>]",
|
||||||
|
"/plugins python_version")
|
||||||
CMD_DESC(
|
CMD_DESC(
|
||||||
"Manage plugins. Passing no arguments lists currently loaded plugins.")
|
"Manage plugins. Passing no arguments lists currently loaded plugins.")
|
||||||
CMD_ARGS(
|
CMD_ARGS(
|
||||||
{ "install <file>", "Install file to plugins directory, and load or reload the plugin." },
|
{ "install <file>", "Install file to plugins directory, and load or reload the plugin." },
|
||||||
{ "load <plugin>", "Load a plugin that already exists in the plugin directory." },
|
{ "load <plugin>", "Load a plugin that already exists in the plugin directory." },
|
||||||
{ "unload <plugin>", "Unload a loaded plugin." },
|
{ "unload <plugin>", "Unload a loaded plugin." },
|
||||||
{ "reload [<plugin>]", "Reload a plugin, passing no argument will reload all plugins" })
|
{ "reload [<plugin>]", "Reload a plugin, passing no argument will reload all plugins." },
|
||||||
|
{ "python_version", "Show the Python interpreter version." })
|
||||||
CMD_EXAMPLES(
|
CMD_EXAMPLES(
|
||||||
"/plugin install /home/steveharris/Downloads/metal.py",
|
"/plugin install /home/steveharris/Downloads/metal.py",
|
||||||
"/plugin load browser.py",
|
"/plugin load browser.py",
|
||||||
|
@ -84,6 +84,9 @@
|
|||||||
#include "tray.h"
|
#include "tray.h"
|
||||||
#endif
|
#endif
|
||||||
#include "tools/http_upload.h"
|
#include "tools/http_upload.h"
|
||||||
|
#ifdef HAVE_PYTHON
|
||||||
|
#include "plugins/python_plugins.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
static void _update_presence(const resource_presence_t presence,
|
static void _update_presence(const resource_presence_t presence,
|
||||||
const char *const show, gchar **args);
|
const char *const show, gchar **args);
|
||||||
@ -6109,6 +6112,16 @@ cmd_plugins(ProfWin *window, const char *const command, gchar **args)
|
|||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
} else if (g_strcmp0(args[0], "python_version") == 0) {
|
||||||
|
#ifdef HAVE_PYTHON
|
||||||
|
const char *version = python_get_version();
|
||||||
|
cons_show("Python version:");
|
||||||
|
cons_show("%s", version);
|
||||||
|
#else
|
||||||
|
cons_show("This build does not support pytyon plugins.");
|
||||||
|
#endif
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
GList *plugins = plugins_loaded_list();
|
GList *plugins = plugins_loaded_list();
|
||||||
if (plugins == NULL) {
|
if (plugins == NULL) {
|
||||||
|
@ -65,6 +65,12 @@ _unref_module(PyObject *module)
|
|||||||
Py_XDECREF(module);
|
Py_XDECREF(module);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char*
|
||||||
|
python_get_version(void)
|
||||||
|
{
|
||||||
|
return Py_GetVersion();
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
python_env_init(void)
|
python_env_init(void)
|
||||||
{
|
{
|
||||||
@ -72,9 +78,6 @@ python_env_init(void)
|
|||||||
|
|
||||||
python_init_prof();
|
python_init_prof();
|
||||||
|
|
||||||
const char *ver = Py_GetVersion();
|
|
||||||
cons_show("PYTHON: %s", ver);
|
|
||||||
|
|
||||||
gchar *plugins_dir = plugins_get_dir();
|
gchar *plugins_dir = plugins_get_dir();
|
||||||
GString *path = g_string_new("import sys\n");
|
GString *path = g_string_new("import sys\n");
|
||||||
g_string_append(path, "sys.path.append(\"");
|
g_string_append(path, "sys.path.append(\"");
|
||||||
|
@ -43,6 +43,8 @@ void python_check_error(void);
|
|||||||
void allow_python_threads();
|
void allow_python_threads();
|
||||||
void disable_python_threads();
|
void disable_python_threads();
|
||||||
|
|
||||||
|
const char* python_get_version(void);
|
||||||
|
|
||||||
void python_init_hook(ProfPlugin *plugin, const char *const version, const char *const status,
|
void python_init_hook(ProfPlugin *plugin, const char *const version, const char *const status,
|
||||||
const char *const account_name, const char *const fulljid);
|
const char *const account_name, const char *const fulljid);
|
||||||
void python_on_start_hook(ProfPlugin *plugin);
|
void python_on_start_hook(ProfPlugin *plugin);
|
||||||
|
Loading…
Reference in New Issue
Block a user