summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEmmanuel Bouthenot <kolter@openics.org>2005-06-16 16:41:41 +0000
committerEmmanuel Bouthenot <kolter@openics.org>2005-06-16 16:41:41 +0000
commitebf5f9e66d57cb10e175f844924fd93c301176f1 (patch)
tree3f7594238a86ce87139e47b759cb535b1257195c /src
parent7330dc862a9a1491bda825801191066fa0e53f38 (diff)
downloadweechat-ebf5f9e66d57cb10e175f844924fd93c301176f1.zip
in python scripts, all messages written in stdin and stderr are redirect in server window
Diffstat (limited to 'src')
-rw-r--r--src/plugins/python/wee-python.c29
1 files changed, 27 insertions, 2 deletions
diff --git a/src/plugins/python/wee-python.c b/src/plugins/python/wee-python.c
index cab102ea7..b984281ea 100644
--- a/src/plugins/python/wee-python.c
+++ b/src/plugins/python/wee-python.c
@@ -58,7 +58,7 @@ wee_python_register (PyObject *self, PyObject *args)
irc_display_prefix (NULL, PREFIX_ERROR);
gui_printf (NULL,
_("%s error: wrong parameters for \"%s\" function\n"),
- "Python", "print_with_channel");
+ "Python", "register");
return NULL;
}
@@ -140,7 +140,7 @@ wee_python_print (PyObject *self, PyObject *args)
irc_display_prefix (NULL, PREFIX_ERROR);
gui_printf (NULL,
_("%s error: wrong parameters for \"%s\" function\n"),
- "Python", "print");
+ "Python", "prnt");
return NULL;
}
@@ -407,6 +407,31 @@ wee_python_init ()
{
wee_log_printf (_("Loading %s module \"weechat\"\n"), "Python");
Py_InitModule ("weechat", weechat_funcs);
+
+ if (PyRun_SimpleString (
+ "import weechat, sys, string\n"
+
+ "class weechatStdout:\n"
+ "\tdef write(self, str):\n"
+ "\t\tstr = string.strip(str)\n"
+ "\t\tif str != \"\":\n"
+ "\t\t\tweechat.prnt(\"Python stdout : \" + str, \"\")\n"
+
+ "class weechatStderr:\n"
+ "\tdef write(self, str):\n"
+ "\t\tstr = string.strip(str)\n"
+ "\t\tif str != \"\":\n"
+ "\t\t\tweechat.prnt(\"Python stderr : \" + str, \"\")\n"
+
+ "sys.stdout = weechatStdout()\n"
+ "sys.stderr = weechatStderr()\n"
+ ) != 0)
+ {
+ irc_display_prefix (NULL, PREFIX_PLUGIN);
+ gui_printf (NULL,
+ _("%s error: error while redirecting stdout and stderr\n"),
+ "Python");
+ }
}
}