diff options
-rw-r--r-- | ChangeLog | 1 | ||||
-rw-r--r-- | doc/de/autogen/plugin_api/infos.txt | 2 | ||||
-rw-r--r-- | doc/en/autogen/plugin_api/infos.txt | 2 | ||||
-rw-r--r-- | doc/fr/autogen/plugin_api/infos.txt | 2 | ||||
-rw-r--r-- | doc/it/autogen/plugin_api/infos.txt | 2 | ||||
-rw-r--r-- | po/cs.po | 5 | ||||
-rw-r--r-- | po/de.po | 5 | ||||
-rw-r--r-- | po/es.po | 5 | ||||
-rw-r--r-- | po/fr.po | 7 | ||||
-rw-r--r-- | po/hu.po | 5 | ||||
-rw-r--r-- | po/it.po | 5 | ||||
-rw-r--r-- | po/pl.po | 5 | ||||
-rw-r--r-- | po/ru.po | 5 | ||||
-rw-r--r-- | po/weechat.pot | 5 | ||||
-rw-r--r-- | src/plugins/scripts/python/weechat-python.c | 84 |
15 files changed, 130 insertions, 10 deletions
@@ -59,6 +59,7 @@ Version 0.3.4 (under dev!) expressions (bug #26964) * relay: beta version of IRC proxy * scripts: add missing function "infolist_reset_item_cursor" in API (bug #31057) +* python: add info "python2_bin" (path to python 2.x interpreter) * lua: fix crash when unloading script * ruby: fix compilation with Ruby 1.9.2 (patch #7316) diff --git a/doc/de/autogen/plugin_api/infos.txt b/doc/de/autogen/plugin_api/infos.txt index 631609c1c..2e5c88033 100644 --- a/doc/de/autogen/plugin_api/infos.txt +++ b/doc/de/autogen/plugin_api/infos.txt @@ -22,6 +22,8 @@ | irc | irc_server_isupport_value | Wert der Funktion, sofern es vom Server unterstützt wird (durch IRC Message 005) | Server,Funktion +| python | python2_bin | path to python 2.x interpreter | - + | weechat | charset_internal | Interner WeeChat Zeichensatz | - | weechat | charset_terminal | Terminal Zeichensatz | - diff --git a/doc/en/autogen/plugin_api/infos.txt b/doc/en/autogen/plugin_api/infos.txt index 9de4fb5c6..db75a89d5 100644 --- a/doc/en/autogen/plugin_api/infos.txt +++ b/doc/en/autogen/plugin_api/infos.txt @@ -22,6 +22,8 @@ | irc | irc_server_isupport_value | value of feature, if supported by server (from IRC message 005) | server,feature +| python | python2_bin | path to python 2.x interpreter | - + | weechat | charset_internal | WeeChat internal charset | - | weechat | charset_terminal | terminal charset | - diff --git a/doc/fr/autogen/plugin_api/infos.txt b/doc/fr/autogen/plugin_api/infos.txt index 4c16c9100..a51dbcb36 100644 --- a/doc/fr/autogen/plugin_api/infos.txt +++ b/doc/fr/autogen/plugin_api/infos.txt @@ -22,6 +22,8 @@ | irc | irc_server_isupport_value | valeur de la fonctionnalité, si supportée par le serveur (du message IRC 005) | serveur,fonctionnalité +| python | python2_bin | chemin vers l'interpréteur python 2.x | - + | weechat | charset_internal | charset interne à WeeChat | - | weechat | charset_terminal | charset du terminal | - diff --git a/doc/it/autogen/plugin_api/infos.txt b/doc/it/autogen/plugin_api/infos.txt index 96bdaa5e8..fdee19485 100644 --- a/doc/it/autogen/plugin_api/infos.txt +++ b/doc/it/autogen/plugin_api/infos.txt @@ -22,6 +22,8 @@ | irc | irc_server_isupport_value | valore della caratteristica, se supportata dal servre (dal messaggio IRC 005) | server,caratteristica +| python | python2_bin | path to python 2.x interpreter | - + | weechat | charset_internal | set caratteri interno di WeeChat | - | weechat | charset_terminal | set caratteri terminale | - @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.4-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2010-11-07 09:27+0100\n" +"POT-Creation-Date: 2010-11-08 15:03+0100\n" "PO-Revision-Date: 2010-11-06 11:55+0100\n" "Last-Translator: Jiri Golembiovsky <golemj@gmail.com>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -6581,6 +6581,9 @@ msgstr "%s%s: nemůžu přesměrovat stdout" msgid "%s%s: unable to redirect stderr" msgstr "%s%s: nemohu přesměrovat stderr" +msgid "path to python 2.x interpreter" +msgstr "" + #, c-format msgid "%s%s: unable to launch global interpreter" msgstr "%s%s: nemohu spustit globální interpreter" @@ -22,7 +22,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.3-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2010-11-07 09:27+0100\n" +"POT-Creation-Date: 2010-11-08 15:03+0100\n" "PO-Revision-Date: 2010-11-06 11:55+0100\n" "Last-Translator: Nils G.\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -6852,6 +6852,9 @@ msgstr "%s%s: Kann Standardausgabe (stdout) nicht umlenken" msgid "%s%s: unable to redirect stderr" msgstr "%s%s: Kann Standardfehlerausgabe (stderr) nicht umlenken" +msgid "path to python 2.x interpreter" +msgstr "" + #, c-format msgid "%s%s: unable to launch global interpreter" msgstr "%s%s: Kann globalen Interpreter nicht starten" @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.4-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2010-11-07 09:27+0100\n" +"POT-Creation-Date: 2010-11-08 15:03+0100\n" "PO-Revision-Date: 2010-11-06 11:56+0100\n" "Last-Translator: Elián Hanisch <lambdae2@gmail.com>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -6657,6 +6657,9 @@ msgstr "%s%s: no es posible redirigir la salida stdout" msgid "%s%s: unable to redirect stderr" msgstr "%s%s: no es posible redirigir la salida stderr" +msgid "path to python 2.x interpreter" +msgstr "" + #, c-format msgid "%s%s: unable to launch global interpreter" msgstr "%s%s: no es posible iniciar el intérprete global" @@ -21,8 +21,8 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.4-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2010-11-07 09:27+0100\n" -"PO-Revision-Date: 2010-11-07 09:29+0100\n" +"POT-Creation-Date: 2010-11-08 15:03+0100\n" +"PO-Revision-Date: 2010-11-08 15:03+0100\n" "Last-Translator: Sebastien Helleu <flashcode@flashtux.org>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" "Language: French\n" @@ -6758,6 +6758,9 @@ msgstr "%s%s: impossible de rediriger stdout" msgid "%s%s: unable to redirect stderr" msgstr "%s%s: impossible de rediriger stderr" +msgid "path to python 2.x interpreter" +msgstr "chemin vers l'interpréteur python 2.x" + #, c-format msgid "%s%s: unable to launch global interpreter" msgstr "%s%s: impossible de lancer l'interpréteur global" @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.4-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2010-11-07 09:27+0100\n" +"POT-Creation-Date: 2010-11-08 15:03+0100\n" "PO-Revision-Date: 2010-11-05 17:17+0100\n" "Last-Translator: Andras Voroskoi <voroskoi@frugalware.org>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -6302,6 +6302,9 @@ msgstr "Nem sikerült a(z) \"%s\" naplófájlt írni\n" msgid "%s%s: unable to redirect stderr" msgstr "%s nem sikerült a szervert létrehozni\n" +msgid "path to python 2.x interpreter" +msgstr "" + #, fuzzy, c-format msgid "%s%s: unable to launch global interpreter" msgstr "%s nem sikerült a szervert létrehozni\n" @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.4-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2010-11-07 09:27+0100\n" +"POT-Creation-Date: 2010-11-08 15:03+0100\n" "PO-Revision-Date: 2010-11-06 11:56+0100\n" "Last-Translator: Marco Paolone <marcopaolone@gmail.com>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -6696,6 +6696,9 @@ msgstr "%s%s: impossibile reindirizzare stdout" msgid "%s%s: unable to redirect stderr" msgstr "%s%s: impossibile reindirizzare stderr" +msgid "path to python 2.x interpreter" +msgstr "" + #, c-format msgid "%s%s: unable to launch global interpreter" msgstr "%s%s: impossibile avviare l'interprete globale" @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.4-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2010-11-07 09:27+0100\n" +"POT-Creation-Date: 2010-11-08 15:03+0100\n" "PO-Revision-Date: 2010-11-06 11:56+0100\n" "Last-Translator: Krzysztof Koroscik <soltys@szluug.org>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -6603,6 +6603,9 @@ msgstr "%s%s: nie można przekierować wyjścia" msgid "%s%s: unable to redirect stderr" msgstr "%s%s: nie można przekierować wyjścia błędu" +msgid "path to python 2.x interpreter" +msgstr "" + #, c-format msgid "%s%s: unable to launch global interpreter" msgstr "%s%s: nie można uruchomić globalnego interpretera" @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.4-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2010-11-07 09:27+0100\n" +"POT-Creation-Date: 2010-11-08 15:03+0100\n" "PO-Revision-Date: 2010-11-05 17:17+0100\n" "Last-Translator: Pavel Shevchuk <stlwrt@gmail.com>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -6315,6 +6315,9 @@ msgstr "Не могу записать лог-файл \"%s\"\n" msgid "%s%s: unable to redirect stderr" msgstr "%s не могу создать сервер\n" +msgid "path to python 2.x interpreter" +msgstr "" + #, fuzzy, c-format msgid "%s%s: unable to launch global interpreter" msgstr "%s не могу создать сервер\n" diff --git a/po/weechat.pot b/po/weechat.pot index 461c06c65..88fdd23d9 100644 --- a/po/weechat.pot +++ b/po/weechat.pot @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2010-11-07 09:27+0100\n" +"POT-Creation-Date: 2010-11-08 15:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Language-Team: LANGUAGE <LL@li.org>\n" @@ -5528,6 +5528,9 @@ msgstr "" msgid "%s%s: unable to redirect stderr" msgstr "" +msgid "path to python 2.x interpreter" +msgstr "" + #, c-format msgid "%s%s: unable to launch global interpreter" msgstr "" diff --git a/src/plugins/scripts/python/weechat-python.c b/src/plugins/scripts/python/weechat-python.c index dadf38fb7..a49aad852 100644 --- a/src/plugins/scripts/python/weechat-python.c +++ b/src/plugins/scripts/python/weechat-python.c @@ -25,6 +25,9 @@ #undef _ #include <Python.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <unistd.h> #include "../../weechat-plugin.h" #include "../script.h" @@ -47,6 +50,7 @@ struct t_plugin_script *python_current_script = NULL; struct t_plugin_script *python_registered_script = NULL; const char *python_current_script_filename = NULL; PyThreadState *python_mainThreadState = NULL; +char *python2_bin = NULL; /* * string used to execute action "install": @@ -68,6 +72,54 @@ char python_buffer_output[128]; /* + * weechat_python_set_python2_bin: set path to python 2.x interpreter + */ + +void +weechat_python_set_python2_bin () +{ + const char *dir_separator; + char *path, **paths, bin[4096]; + char *versions[] = { "2", "2.7", "2.6", "2.5", "2.4", "2.3", "2.2", NULL }; + int num_paths, i, j, rc; + struct stat stat_buf; + + python2_bin = NULL; + + dir_separator = weechat_info_get ("dir_separator", ""); + path = getenv ("PATH"); + + if (dir_separator && path) + { + paths = weechat_string_split (path, ":", 0, 0, &num_paths); + if (paths) + { + for (i = 0; i < num_paths; i++) + { + for (j = 0; versions[j]; j++) + { + snprintf (bin, sizeof (bin), "%s%s%s%s", + paths[i], dir_separator, "python", + versions[j]); + rc = stat (bin, &stat_buf); + if ((rc == 0) && (S_ISREG(stat_buf.st_mode))) + { + python2_bin = strdup (bin); + break; + } + } + if (python2_bin) + break; + } + weechat_string_free_split (paths); + } + } + + if (!python2_bin) + python2_bin = strdup ("python"); +} + +/* * weechat_python_hashtable_map_cb: callback called for each key/value in a * hashtable */ @@ -795,6 +847,26 @@ weechat_python_completion_cb (void *data, const char *completion_item, } /* + * weechat_python_info_cb: callback for info + */ + +const char * +weechat_python_info_cb (void *data, const char *info_name, + const char *arguments) +{ + /* make C compiler happy */ + (void) data; + (void) arguments; + + if (weechat_strcasecmp (info_name, "python2_bin") == 0) + { + return python2_bin; + } + + return NULL; +} + +/* * weechat_python_infolist_cb: callback for infolist */ @@ -939,6 +1011,16 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[]) { weechat_python_plugin = plugin; + /* + * hook info to get path to python 2.x interpreter + * (some scripts using hook_process need that) + */ + weechat_python_set_python2_bin (); + weechat_hook_info ("python2_bin", + N_("path to python 2.x interpreter"), + NULL, + &weechat_python_info_cb, NULL); + /* init stdout/stderr buffer */ python_buffer_output[0] = '\0'; @@ -1019,6 +1101,8 @@ weechat_plugin_end (struct t_weechat_plugin *plugin) } /* free some data */ + if (python2_bin) + free (python2_bin); if (python_action_install_list) free (python_action_install_list); if (python_action_remove_list) |