[Konversation-devel] Script help in python

Eli MacKenzie argonel at gmail.com
Fri Oct 26 18:27:35 CEST 2007


On 10/25/07, Paul Walsh <paul at pbmm.net> wrote:
> Hi all
>
> I am trying to get started with some small scripts for konversation but I am
> having difficulty understanding the communication mechanism used in the
> existing python scripts (media and weather) that I am using to learn. I was
> expecting that I would use the dcoppython bindings but these scripts seem to
> use some sort of threading mechanism via a module called "subprocess". I
> suppose I have 2 questions:
>

The python DCOP bindings are not used to avoid the addition of the
extra dependancy on the app. So instead all scripts for Konversation
communicate via the command-line "dcop" application, which is why you
see the use of subprocess.py

> Is this the correct method of communcation from a script to konvi?
>
> If so - how do I get the information about all the sys.argv variables? In dcop
> I can look for labels but I am clueless about sys.argv stuff.

Only the first 3 of them are special. The first try block in the
current version of media.py assigns them to the global variables as
below:

APP_ID = sys.argv[1]
IRC_SERVER = sys.argv[2]
TARGET = sys.argv[3]

TARGET is a channel name, nickname, or "" (in which case the script
was triggered from the server window.

The "tell" function after the second try block is where the dcop
command line is built and executed. The "feedback" variable will
contain the name of the dcop command that is being called from the
default interface ("irc"). So for instance:

tell([IRC_SERVER, TARGET, "/me is running a python script"], 'say')

...which would expand to this (inside subprocess.py):

dcop konversation default say irc.kde.org "#konversation" "/me is
running a python script"

Hopefully this is slightly clearer than mud. :)


More information about the Konversation-devel mailing list