[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Weechat-dev] [bug #18103] weechat display broken by python cmd.Cmd obje

From: ts
Subject: [Weechat-dev] [bug #18103] weechat display broken by python cmd.Cmd objects
Date: Thu, 02 Nov 2006 16:49:22 +0000
User-agent: Mozilla/5.0 (compatible; Konqueror/3.5; Linux; ppc; en_US) KHTML/3.5.2 (like Gecko)

Follow-up Comment #2, bug #18103 (project weechat):

Here is an example work-around for those who wish to use cmd.Cmd, or any
other ncurses-linked Python module. Some modules conflict with WeeChat when
loaded directly into the WeeChat python interpreter, including all of those
that link to ncurses.

What you need to do is to execute the conflicting modules within a *separate*
python interpreter instance, while maintaining the interface between WeeChat
and the script. A typical method to accomplish this:

(1) all use of conflicting module(s) must run in stand-alone Python script(s)
designated as SLAVE
(2) a WeeChat script that facilitates IRC commands, etc., and does not use
conflicting modules, is designated as MASTER
(3) the MASTER script (1) executes and controls SLAVE script(s) (2) via some
form of interprocess communication

One clean way to accomplish this is from MASTER to parse the WeeChat IRC
command, and send the direct results to the subprocess as a single line,
token-parsable by SLAVE.

User inputs '/cmd -g blah foo bar' in WeeChat. The MASTER writes to the SLAVE
pipe 'CMD G blah foo bar', and then reads from the SLAVE pipe for how to

An obvious method for the MASTER--SLAVE communication is a bidirectional pipe
using some form of 'popen2' or Popen from the Python library. Unfortunately,
there are a plethora of caveats involved, including the fact that synchronous
pipe communication will likely lockup even with Python 2.4.

To solve this, one can use asynchronous pipe communication. An example module
for subclassing the Python 2.4 subprocess module:

An example of a WeeChat script that uses this form of interprocess


Additional Item Attachment:

File name: weechat_ncurses_workaround_example_1.txt Size:1 KB
text of workaround example 1


Reply to this item at:


  Message sent via/by Savannah

reply via email to

[Prev in Thread] Current Thread [Next in Thread]