diff options
author | James Booth <boothj5@gmail.com> | 2016-07-24 02:12:56 +0100 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2016-07-24 02:12:56 +0100 |
commit | 4209b1cf45b9b52e852b58aa6dcfe513c16c8dcd (patch) | |
tree | d6c13a6b2c60e8b4f7db947ff51a2f8ce0227030 /src | |
parent | b48a3d2f6a50a8dea92c87d640573e0c827eb0cd (diff) | |
download | profani-tty-4209b1cf45b9b52e852b58aa6dcfe513c16c8dcd.tar.gz |
Add /plugins python_version command
Diffstat (limited to 'src')
-rw-r--r-- | src/command/cmd_ac.c | 1 | ||||
-rw-r--r-- | src/command/cmd_defs.c | 6 | ||||
-rw-r--r-- | src/command/cmd_funcs.c | 13 | ||||
-rw-r--r-- | src/plugins/python_plugins.c | 9 | ||||
-rw-r--r-- | src/plugins/python_plugins.h | 2 |
5 files changed, 26 insertions, 5 deletions
diff --git a/src/command/cmd_ac.c b/src/command/cmd_ac.c index 0d30df88..69e350bc 100644 --- a/src/command/cmd_ac.c +++ b/src/command/cmd_ac.c @@ -711,6 +711,7 @@ cmd_ac_init(void) autocomplete_add(plugins_ac, "load"); autocomplete_add(plugins_ac, "unload"); autocomplete_add(plugins_ac, "reload"); + autocomplete_add(plugins_ac, "python_version"); filepath_ac = autocomplete_new(); diff --git a/src/command/cmd_defs.c b/src/command/cmd_defs.c index 900e8e96..34f840ed 100644 --- a/src/command/cmd_defs.c +++ b/src/command/cmd_defs.c @@ -1982,14 +1982,16 @@ static struct cmd_t command_defs[] = "/plugins install <path>", "/plugins unload <plugin>", "/plugins load <plugin>", - "/plugins reload [<plugin>]") + "/plugins reload [<plugin>]", + "/plugins python_version") CMD_DESC( "Manage plugins. Passing no arguments lists currently loaded plugins.") CMD_ARGS( { "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." }, { "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( "/plugin install /home/steveharris/Downloads/metal.py", "/plugin load browser.py", diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c index c9094f18..65982541 100644 --- a/src/command/cmd_funcs.c +++ b/src/command/cmd_funcs.c @@ -84,6 +84,9 @@ #include "tray.h" #endif #include "tools/http_upload.h" +#ifdef HAVE_PYTHON +#include "plugins/python_plugins.h" +#endif static void _update_presence(const resource_presence_t presence, const char *const show, gchar **args); @@ -6109,6 +6112,16 @@ cmd_plugins(ProfWin *window, const char *const command, gchar **args) } 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 { GList *plugins = plugins_loaded_list(); if (plugins == NULL) { diff --git a/src/plugins/python_plugins.c b/src/plugins/python_plugins.c index 61c7573f..40046200 100644 --- a/src/plugins/python_plugins.c +++ b/src/plugins/python_plugins.c @@ -65,6 +65,12 @@ _unref_module(PyObject *module) Py_XDECREF(module); } +const char* +python_get_version(void) +{ + return Py_GetVersion(); +} + void python_env_init(void) { @@ -72,9 +78,6 @@ python_env_init(void) python_init_prof(); - const char *ver = Py_GetVersion(); - cons_show("PYTHON: %s", ver); - gchar *plugins_dir = plugins_get_dir(); GString *path = g_string_new("import sys\n"); g_string_append(path, "sys.path.append(\""); diff --git a/src/plugins/python_plugins.h b/src/plugins/python_plugins.h index f3ab7bce..dda73405 100644 --- a/src/plugins/python_plugins.h +++ b/src/plugins/python_plugins.h @@ -43,6 +43,8 @@ void python_check_error(void); void allow_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, const char *const account_name, const char *const fulljid); void python_on_start_hook(ProfPlugin *plugin); |