Re: [PyKDE] DCOP memory leak
Does this help: from dcopext import DCOPClient, DCOPApp dcop=DCOPClient() dcop.attach() player = DCOPApp ("amarok", dcop).player while 1: print player.trackCurrentTimeMs() Kovid. On Wednesday 31 January 2007 12:17:42 Tim De Graeve wrote: > Hi, > > I'm writing a script for Amarok in python that has to do a lot of DCOP > calls in a short amount of time. > Now, I have noticed that every time I do a DCOP call my program grows in > memory usage, the short program below demonstrates this: > > from dcopext import DCOPClient, DCOPApp > > dcop=DCOPClient() > > > while 1: > AmarokDcopRes = DCOPApp ("amarok", dcop) > ok, ms = AmarokDcopRes.player.trackCurrentTimeMs() > print ms > > > Note that in the program I'm writing the while loop is replaced by a > timer event. > I also noticed that the program only grows in memory use once the 'ok, > ms = AmarokDcopRes.player.trackCurrentTimeMs()' code is executed. > > I already posted my problem on the comp.lang.python Usenet-group and > someone suggested to post here because my problem seems more to be pyKDE > and DCOP related. > Does someone have any suggestions on how I can avoid this memory leak? > > Kind regards, > > Tim > > ___ > PyKDE mailing listPyKDE@mats.imk.fraunhofer.de > http://mats.imk.fraunhofer.de/mailman/listinfo/pykde > > !DSPAM:2,45c0fac944256935130580! -- _ Kovid Goyal MC 452-48 California Institute of Technology 1200 E California Blvd Pasadena, CA 91125 home : +01 626 390 8699 office: +01 626 395 6595 (449 Lauritsen) email : [EMAIL PROTECTED] web : http://www.kovidgoyal.net _ ___ PyKDE mailing listPyKDE@mats.imk.fraunhofer.de http://mats.imk.fraunhofer.de/mailman/listinfo/pykde
[PyKDE] DCOP memory leak
Hi, I'm writing a script for Amarok in python that has to do a lot of DCOP calls in a short amount of time. Now, I have noticed that every time I do a DCOP call my program grows in memory usage, the short program below demonstrates this: from dcopext import DCOPClient, DCOPApp dcop=DCOPClient() dcop.attach() while 1: AmarokDcopRes = DCOPApp ("amarok", dcop) ok, ms = AmarokDcopRes.player.trackCurrentTimeMs() print ms Note that in the program I'm writing the while loop is replaced by a timer event. I also noticed that the program only grows in memory use once the 'ok, ms = AmarokDcopRes.player.trackCurrentTimeMs()' code is executed. I already posted my problem on the comp.lang.python Usenet-group and someone suggested to post here because my problem seems more to be pyKDE and DCOP related. Does someone have any suggestions on how I can avoid this memory leak? Kind regards, Tim ___ PyKDE mailing listPyKDE@mats.imk.fraunhofer.de http://mats.imk.fraunhofer.de/mailman/listinfo/pykde
Re: [PyKDE] DCOP From Cron
On Tuesday 20 June 2006 16:26, Richard Heck wrote: > Jim Bublitz wrote: > >> Here's a simple test program: > >> > >> #/usr/bin/python > >> #Create DCOP clients > >> import kdecore > >> import dcopext > >> dcopclient = kdecore.KApplication.dcopClient() > >> dcopclient.registerAs("changewp") > >> dcopapp = dcopext.DCOPApp("kdesktop", dcopclient) > >> print dcopapp.KBackgroundIface.currentWallpaper(1)[1] > >> > >> If I run that from a konsole, I get e.g. > >> /usr/share/wallpapers/default_gears.jpg. But if I run it from a virtual > >> terminal, I get: None. And again: I'm the same user both times. > > > > It appears the problem is with KDE and DCOP. There are a few things I'd > > try. First, I'd see what some of the DCOPClient methods, like > > isAttached() and isRegistered() return. I'd also query the interface and > > see if I could get a list of applications, or objects for an application. > > Lastly, I'd look into instantiating and attaching a DCOPClient directly, > > rather than using KApplication's, and pay attention to return values. > > > > I think DCOP is intended for IPC within a KDE session (ie - with child > > processes of a kdeinit). It might be that you need to create your > > application as a daemon under the current KDE session and then us cron to > > communicate with that daemon. > > The strange thing, however, is that if I use the dcop command line tool, > > then I can do: > >dcop --user rgheck > > and connect to the relevant server. It seems as if there ought to be > some way to do that using PyKDE. And similarly as if there ought to be > some way to do what you could do via > > >dcop --all-users > > and the like. But I don't see that facility. The first functional lines of the dcop utility you're using are: DCOPClient client; client.attach(); In Python the equivalent would be: import dcop c = DCOPClient () c.attach () If you run that from the Python interpreter, c.attach () returns False. It appears that attach is trying to use a server address (c.dcopServerFile () returns it) that doesn't exist. If I use c.setServerAddress ('some valid address') I get other errors that are apparently coming from X/ICE. The server address is apparently of the form DCOPserver__:0 (might be username instead of hostname, as they're identical on this machine) It's a small text file in your home directory - assuming I found the right file. You can also set the DCOPSERVER environment variable to point to it apparently. There is a signal emitted ('attachFailed') that contains more diagnostic information about why attach () failed, but since I was in the interpreter, it would be kind of a pain to connect to that - you could try it programmatically. That still doesn't explain why attach() works in the dcop utility, but not from Python, but perhaps the diagnostics will provide some more help. The code for the dcop utility is at kdelibs-3.5.0/dcop/client or whatever version of kdelibs source you might have. Jim ___ PyKDE mailing listPyKDE@mats.imk.fraunhofer.de http://mats.imk.fraunhofer.de/mailman/listinfo/pykde
Re: [PyKDE] DCOP From Cron
On Tuesday 20 June 2006 11:28, you wrote: > Jim Bublitz wrote: > > On Tuesday 20 June 2006 08:49, Richard Heck wrote: > >> İsmail Dönmez wrote: > >>> Salı 20 Haziran 2006 17:19 tarihinde, Richard Heck şunları yazmıştı: > I'm writing a simple application to rotate wallpaper every so often, > and I want to run it as a cron job. The basic structure is pretty > simple, and it works fine if I run it in a shell under KDE. But when I > run it as a cron job, it does not connect to the DCOP server. Is there > some way to tell the script which DCOP server to connect to? > >>> > >>> Maybe try dcop --user $username . > >> > >> Sorry, that wasn't clear. The program I'm writing is in Python. > > > > Yes, but it should be running under cron as the same user you're testing > > it as (the user who owns the display and is running KDE). > > > > Your application should be based on KApplication, and can use > > KApplication.dcopClient() to connect to the DCOP server. > > Here is the relevant part of the application as it presently exists: > > #Create DCOP clients > import kdecore > import dcopext > dcopclient = kdecore.KApplication.dcopClient() > dcopclient.registerAs("changewp") > dcopapp = dcopext.DCOPApp("kdesktop", dcopclient) > > and then later we have things like: > > dcopapp.KBackgroundIface.setWallpaper(...) > > As said, if I run this from a konsole under KDE, it works fine. But if I > CTRL-ALT-F1 and open a terminal outside KDE, then it doesn't work, > despite the fact that I'm running as the same user. > > Here's a simple test program: > > #/usr/bin/python > #Create DCOP clients > import kdecore > import dcopext > dcopclient = kdecore.KApplication.dcopClient() > dcopclient.registerAs("changewp") > dcopapp = dcopext.DCOPApp("kdesktop", dcopclient) > print dcopapp.KBackgroundIface.currentWallpaper(1)[1] > > If I run that from a konsole, I get e.g. > /usr/share/wallpapers/default_gears.jpg. But if I run it from a virtual > terminal, I get: None. And again: I'm the same user both times. It appears the problem is with KDE and DCOP. There are a few things I'd try. First, I'd see what some of the DCOPClient methods, like isAttached() and isRegistered() return. I'd also query the interface and see if I could get a list of applications, or objects for an application. Lastly, I'd look into instantiating and attaching a DCOPClient directly, rather than using KApplication's, and pay attention to return values. I think DCOP is intended for IPC within a KDE session (ie - with child processes of a kdeinit). It might be that you need to create your application as a daemon under the current KDE session and then us cron to communicate with that daemon. Jim ___ PyKDE mailing listPyKDE@mats.imk.fraunhofer.de http://mats.imk.fraunhofer.de/mailman/listinfo/pykde
Re: [PyKDE] DCOP From Cron
On Tuesday 20 June 2006 19:28, Richard Heck wrote: > If I run that from a konsole, I get e.g. > /usr/share/wallpapers/default_gears.jpg. But if I run it from a virtual > terminal, I get: None. And again: I'm the same user both times. Try: export XAUTHORITY=~username/.Xauthority DISPLAY=:0 appcommand on the terminal. -- Lee Braiden http://DigitalUnleashed.com "I object to violence because when it appears to do good, the good is only temporary; the evil it does is permanent." -- Mahatma Gandhi ___ PyKDE mailing listPyKDE@mats.imk.fraunhofer.de http://mats.imk.fraunhofer.de/mailman/listinfo/pykde
Re: [PyKDE] DCOP From Cron
Jim Bublitz wrote: On Tuesday 20 June 2006 08:49, Richard Heck wrote: İsmail Dönmez wrote: Salı 20 Haziran 2006 17:19 tarihinde, Richard Heck şunları yazmıştı: I'm writing a simple application to rotate wallpaper every so often, and I want to run it as a cron job. The basic structure is pretty simple, and it works fine if I run it in a shell under KDE. But when I run it as a cron job, it does not connect to the DCOP server. Is there some way to tell the script which DCOP server to connect to? Maybe try dcop --user $username . Sorry, that wasn't clear. The program I'm writing is in Python. Yes, but it should be running under cron as the same user you're testing it as (the user who owns the display and is running KDE). Your application should be based on KApplication, and can use KApplication.dcopClient() to connect to the DCOP server. Here is the relevant part of the application as it presently exists: #Create DCOP clients import kdecore import dcopext dcopclient = kdecore.KApplication.dcopClient() dcopclient.registerAs("changewp") dcopapp = dcopext.DCOPApp("kdesktop", dcopclient) and then later we have things like: dcopapp.KBackgroundIface.setWallpaper(...) As said, if I run this from a konsole under KDE, it works fine. But if I CTRL-ALT-F1 and open a terminal outside KDE, then it doesn't work, despite the fact that I'm running as the same user. Here's a simple test program: #/usr/bin/python #Create DCOP clients import kdecore import dcopext dcopclient = kdecore.KApplication.dcopClient() dcopclient.registerAs("changewp") dcopapp = dcopext.DCOPApp("kdesktop", dcopclient) print dcopapp.KBackgroundIface.currentWallpaper(1)[1] If I run that from a konsole, I get e.g. /usr/share/wallpapers/default_gears.jpg. But if I run it from a virtual terminal, I get: None. And again: I'm the same user both times. Richard Richard ___ PyKDE mailing listPyKDE@mats.imk.fraunhofer.de http://mats.imk.fraunhofer.de/mailman/listinfo/pykde
Re: [PyKDE] DCOP From Cron
On Tuesday 20 June 2006 08:49, Richard Heck wrote: > İsmail Dönmez wrote: > > Salı 20 Haziran 2006 17:19 tarihinde, Richard Heck şunları yazmıştı: > >> I'm writing a simple application to rotate wallpaper every so often, and > >> I want to run it as a cron job. The basic structure is pretty simple, > >> and it works fine if I run it in a shell under KDE. But when I run it as > >> a cron job, it does not connect to the DCOP server. Is there some way to > >> tell the script which DCOP server to connect to? > > > > Maybe try dcop --user $username . > > Sorry, that wasn't clear. The program I'm writing is in Python. Yes, but it should be running under cron as the same user you're testing it as (the user who owns the display and is running KDE). Your application should be based on KApplication, and can use KApplication.dcopClient() to connect to the DCOP server. Jim ___ PyKDE mailing listPyKDE@mats.imk.fraunhofer.de http://mats.imk.fraunhofer.de/mailman/listinfo/pykde
Re: [PyKDE] DCOP From Cron
İsmail Dönmez wrote: > Salı 20 Haziran 2006 17:19 tarihinde, Richard Heck şunları yazmıştı: > >> I'm writing a simple application to rotate wallpaper every so often, and >> I want to run it as a cron job. The basic structure is pretty simple, >> and it works fine if I run it in a shell under KDE. But when I run it as >> a cron job, it does not connect to the DCOP server. Is there some way to >> tell the script which DCOP server to connect to? >> > Maybe try dcop --user $username . > Sorry, that wasn't clear. The program I'm writing is in Python. Richard ___ PyKDE mailing listPyKDE@mats.imk.fraunhofer.de http://mats.imk.fraunhofer.de/mailman/listinfo/pykde
Re: [PyKDE] DCOP From Cron
Salı 20 Haziran 2006 17:19 tarihinde, Richard Heck şunları yazmıştı: > I'm writing a simple application to rotate wallpaper every so often, and > I want to run it as a cron job. The basic structure is pretty simple, > and it works fine if I run it in a shell under KDE. But when I run it as > a cron job, it does not connect to the DCOP server. Is there some way to > tell the script which DCOP server to connect to? Maybe try dcop --user $username . Regards, ismail -- 日本のanimeは揺れる ___ PyKDE mailing listPyKDE@mats.imk.fraunhofer.de http://mats.imk.fraunhofer.de/mailman/listinfo/pykde
[PyKDE] DCOP From Cron
I'm writing a simple application to rotate wallpaper every so often, and I want to run it as a cron job. The basic structure is pretty simple, and it works fine if I run it in a shell under KDE. But when I run it as a cron job, it does not connect to the DCOP server. Is there some way to tell the script which DCOP server to connect to? Cheers, Richard ___ PyKDE mailing listPyKDE@mats.imk.fraunhofer.de http://mats.imk.fraunhofer.de/mailman/listinfo/pykde
Re: [PyKDE] DCOP problem
On Thursday 25 May 2006 09:06, Michał Woźniak wrote: > Hi there, guys > > Got a strange issue here: trying to have my Python script open a new > KMail's Composer window through DCOP, but I can't seem to be able to call > the appropriate function. > > Now, from shell, everything works great: > dcop kontact KMailIface openComposer to cc bcc subject body False > opens me a new window. > > What's more, 1. I can call other functions of the KMailIface object from > Python without any issues, and 2. the script below actually lists the > "openComposer" method (a few times), but apparently does not call it. As > you will see in the code below, I tried three ways of passing the > arguments, in case I am missing something here, but no luck either. Any > ideas? If I add KURL(""): print dcApp.KMailIface.openComposer(QString('to'), QString('cc'), QString('bcc'), QString('subject'), QString('body'), False, KURL ("")) at the end, that works as far as creating a composer window with 'body' as the text (an actual URL argument to KURL seems to work correctly too). Of course you don't get a DCOPRef back - just an int. The problem is that PyKDE/extensions/dcopext.py (which does the DCOP stuff) doesn't handle overloaded methods correctly (or at all, for that matter). There's an alternative version here: http://twoday.tuwien.ac.at/pub/stories/22870/ I haven't had time to check it out completely, so PyKDE hasn't been modified, but it looks like it should work. To try it out, download it and replace the installed dcopext.py (usually in site-packages, or wherever the Qt and PyKDE modules are installed) with the newer version. The revised version, or something similar, will probably go in the next release. If you test the modified version, I'd appreciate a post to the list about how it works. Apologies for the slow reply - I've been replacing a fried mobo and upgrading to a 64 bit CPU. Jim ___ PyKDE mailing listPyKDE@mats.imk.fraunhofer.de http://mats.imk.fraunhofer.de/mailman/listinfo/pykde
[PyKDE] DCOP problem
Hi there, guys Got a strange issue here: trying to have my Python script open a new KMail's Composer window through DCOP, but I can't seem to be able to call the appropriate function. Now, from shell, everything works great: dcop kontact KMailIface openComposer to cc bcc subject body False opens me a new window. What's more, 1. I can call other functions of the KMailIface object from Python without any issues, and 2. the script below actually lists the "openComposer" method (a few times), but apparently does not call it. As you will see in the code below, I tried three ways of passing the arguments, in case I am missing something here, but no luck either. Any ideas? Cheers Mike === SCRIPT == #!/usr/bin/python import dcop import dcopext from kdecore import * from qt import * # the dcop client dc = dcop.DCOPClient() print 'attaching:', dc.attach() print # getting the editor up dcApp = dcopext.DCOPApp('kontact', dc) print 'methods:' for method in dcApp.KMailIface.methods: print ' - "' + str(method) + '"' print print 'calling dcApp.KMailIface.openComposer(\'to\', \'cc\', \'bcc\', \'subject\', \'body\', False):' print dcApp.KMailIface.openComposer('to', 'cc', 'bcc', 'subject', 'body', False) print dcApp.KMailIface.openComposer(QCString('to'), QCString('cc'), QCString('bcc'), QCString('subject'), QCString('body'), False) print dcApp.KMailIface.openComposer(QString('to'), QString('cc'), QString('bcc'), QString('subject'), QString('body'), False) - === OUTPUT == attaching: True methods: - "QCStringList interfaces()" - "QCStringList functions()" - "void checkMail()" - "QStringList accounts()" - "void checkAccount(QString account)" - "void openReader()" - "int openComposer(QString to,QString cc,QString bcc,QString subject,QString body,int hidden,KURL messageFile)" - "int openComposer(QString to,QString cc,QString bcc,QString subject,QString body,int hidden,KURL messageFile,KURL attachURL)" - "int openComposer(QString to,QString cc,QString bcc,QString subject,QString body,int hidden,KURL messageFile,KURL::List attachURLs)" - "int openComposer(QString to,QString cc,QString bcc,QString subject,QString body,int hidden,QString attachName,QCString attachCte,QCString attachData,QCString attachType,QCString attachSubType,QCString attachParamAttr,QString attachParamValue,QCString attachContDisp)" - "int openComposer(QString to,QString cc,QString bcc,QString subject,QString body,int hidden,QString attachName,QCString attachCte,QCString attachData,QCString attachType,QCString attachSubType,QCString attachParamAttr,QString attachParamValue,QCString attachContDisp,QCString attachCharset)" - "DCOPRef openComposer(QString to,QString cc,QString bcc,QString subject,QString body,bool hidden)" - "int sendCertificate(QString to,QByteArray certData)" - "void compactAllFolders()" - "int dcopAddMessage(QString foldername,QString messagefile)" - "int dcopAddMessage(QString foldername,KURL messagefile)" - "QStringList folderList()" - "DCOPRef getFolder(QString vpath)" - "void selectFolder(QString folder)" - "bool canQueryClose()" - "int timeOfLastMessageCountChange()" calling dcApp.KMailIface.openComposer('to', 'cc', 'bcc', 'subject', 'body', False): (False, None) (False, None) (False, None) ___ The all-new Yahoo! Mail goes wherever you go - free your email address from your Internet provider. http://uk.docs.yahoo.com/nowyoucan.html ___ PyKDE mailing listPyKDE@mats.imk.fraunhofer.de http://mats.imk.fraunhofer.de/mailman/listinfo/pykde
Re: [PyKDE] dcop program
On Tuesday 16 May 2006 00:47, basse wrote: > hi, > > I am doing a little application that can be controlled via dcop. so far > everything else works, but I am unable to set the application name without > pid number appearing to the end of it automaticly (with dash). > > so in dcop list, instead of "myapp" I see "myapp-5422" for example. > otherwise that would be ok, but as I want to control my application > remotely, I need to know the name of it and now it's different every time I > login. > > is there a way to force pid not to appear there? and why does it actually > appear? I only run one instance of it. > > thanks! > > p.s. this is what I use to set the application name in first place: > aboutdata = KAboutData("klik", "klik", "3.3") > KCmdLineArgs.init(sys.argv, aboutdata) Use KUniqueApplication instead of KApplication in the app you want to control. Jim ___ PyKDE mailing listPyKDE@mats.imk.fraunhofer.de http://mats.imk.fraunhofer.de/mailman/listinfo/pykde
[PyKDE] dcop program
hi, I am doing a little application that can be controlled via dcop. so far everything else works, but I am unable to set the application name without pid number appearing to the end of it automaticly (with dash). so in dcop list, instead of "myapp" I see "myapp-5422" for example. otherwise that would be ok, but as I want to control my application remotely, I need to know the name of it and now it's different every time I login. is there a way to force pid not to appear there? and why does it actually appear? I only run one instance of it. thanks! p.s. this is what I use to set the application name in first place: aboutdata = KAboutData("klik", "klik", "3.3") KCmdLineArgs.init(sys.argv, aboutdata) .b -- http://www.kulma.org :: http://orange.blender.org ___ PyKDE mailing listPyKDE@mats.imk.fraunhofer.de http://mats.imk.fraunhofer.de/mailman/listinfo/pykde
Re: [PyKDE] dcop call always returns same value - UPDATE
On Tuesday 28 June 2005 22:31, Jim Bublitz wrote: > On Monday 27 June 2005 06:07, Sebastian Kügler wrote: > > # Following _always_ returns True :( > > is_enabled = kdesktop.KScreensaverIface.isEnabled()[0] > > > > Any ideas what's going wrong here? > > The call returns a tuple, and the [0] element just indicates if the > call succeeded or not - since it's succeeding, it returns True every > time. The [1] element should be the result data, however that's > returning 'None' at the moment, so the call still isn't working > correctly. > > I'm looking at it and will let you know. > > UPDATE: handling for the 'bool' type wasn't implemented in PyKDE. I > have a snapshot just about ready to go and will add the type before > posting it. Should be available in a day or two. Thanks, I'll give it a go and report back. -- sebas http://www.kde.nl | GPG Key ID: 9119 0EF9 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Some people have told me they don't think a fat penguin really embodies the grace of Linux, which just tells me they have never seen an angry penguin charging at them in excess of 100mph. They'd be a lot more careful about what they say if they had. - Linus Torvalds pgphI5ZiJkM3q.pgp Description: PGP signature ___ PyKDE mailing listPyKDE@mats.imk.fraunhofer.de http://mats.imk.fraunhofer.de/mailman/listinfo/pykde
Re: [PyKDE] dcop call always returns same value - UPDATE
On Monday 27 June 2005 06:07, Sebastian Kügler wrote: > Hi, > > While trying to interface the Kdesktop ScreensaverIface, I noticed an > odd behaviour. If called via bash or kdcop, > > $ dcop kdesktop KScreensaverIface isEnabled > > would return the correct value, i.e. true or false whether I have > checked "[ ] Start automatically" in kcmshell screensaver. > > Interfacing it via python, it _always_ returns "True", which to me seems > a bug, but I may be doing something completely wrong ... > > Sample Script: > > # - > # Following _always_ returns True :( > is_enabled = kdesktop.KScreensaverIface.isEnabled()[0] > Any ideas what's going wrong here? The call returns a tuple, and the [0] element just indicates if the call succeeded or not - since it's succeeding, it returns True every time. The [1] element should be the result data, however that's returning 'None' at the moment, so the call still isn't working correctly. I'm looking at it and will let you know. UPDATE: handling for the 'bool' type wasn't implemented in PyKDE. I have a snapshot just about ready to go and will add the type before posting it. Should be available in a day or two. Jim ___ PyKDE mailing listPyKDE@mats.imk.fraunhofer.de http://mats.imk.fraunhofer.de/mailman/listinfo/pykde
Re: [PyKDE] dcop call always returns same value
On Monday 27 June 2005 06:07, Sebastian Kügler wrote: > Hi, > > While trying to interface the Kdesktop ScreensaverIface, I noticed an > odd behaviour. If called via bash or kdcop, > > $ dcop kdesktop KScreensaverIface isEnabled > > would return the correct value, i.e. true or false whether I have > checked "[ ] Start automatically" in kcmshell screensaver. > > Interfacing it via python, it _always_ returns "True", which to me seems > a bug, but I may be doing something completely wrong ... > > Sample Script: > > # - > # Following _always_ returns True :( > is_enabled = kdesktop.KScreensaverIface.isEnabled()[0] > Any ideas what's going wrong here? The call returns a tuple, and the [0] element just indicates if the call succeeded or not - since it's succeeding, it returns True every time. The [1] element should be the result data, however that's returning 'None' at the moment, so the call still isn't working correctly. I'm looking at it and will let you know. Jim ___ PyKDE mailing listPyKDE@mats.imk.fraunhofer.de http://mats.imk.fraunhofer.de/mailman/listinfo/pykde
[PyKDE] dcop call always returns same value
Hi, While trying to interface the Kdesktop ScreensaverIface, I noticed an odd behaviour. If called via bash or kdcop, $ dcop kdesktop KScreensaverIface isEnabled would return the correct value, i.e. true or false whether I have checked "[ ] Start automatically" in kcmshell screensaver. Interfacing it via python, it _always_ returns "True", which to me seems a bug, but I may be doing something completely wrong ... Sample Script: # - import sys import dcopext from kdecore import * aboutdata = KAboutData("dcop_test","dcop_test","0.0", "A test", KAboutData.License_GPL, "Copyleft") KCmdLineArgs.init(sys.argv,aboutdata) app = KApplication() dcop = app.dcopClient() kdesktop = dcopext.DCOPApp("kdesktop", dcop) # Following _always_ returns True :( is_enabled = kdesktop.KScreensaverIface.isEnabled()[0] print "Screensaver is", {True:"Enabled",False:"Disabled"}[is_enabled] # - Tested with Python 2.3 / PyKDE 3.11.3 (Debian) and Python 2.4, PyKDE20050316. Any ideas what's going wrong here? Cheers, sebas -- http://vizZzion.org | GPG Key ID: 9119 0EF9 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Anything cut to length will be too short. pgpKCmlZegebw.pgp Description: PGP signature ___ PyKDE mailing listPyKDE@mats.imk.fraunhofer.de http://mats.imk.fraunhofer.de/mailman/listinfo/pykde
[PyKDE] dcop problem querying wallpaper
Hi, Trying to query the name of the currently shown wallpaper I stumbled across the following, which is puzzling for me: #-- SNIP import dcop, dcopext, sys from kdecore import * KCmdLineArgs.init (sys.argv,"bla","foo","bar") app = KApplication () dcop = app.dcopClient () kwin = dcopext.DCOPApp ("kwin", dcop) kdesktop = dcopext.DCOPApp ("kwin", dcop) # Huge list of methods, looks good print kwin.KWinInterface.getMethods() # Just works ok,current_desktop = kwin.KWinInterface.currentDesktop() print "Desktop is : ", current_desktop # None, also no Exception print kdesktop.KBackgroundIface.getMethods() # (False, None), no Exception print kdesktop.KBackgroundIface.currentWallpaper(current_desktop) #-- SNIP [Python 2.3, KDE 3.4, PyKDE 3.11.3] While the kwin stuff works just fine, returning the name of the current desktop, from kdesktop.KBackgroundIface.getMethods() is empty and I don't even get the usual AttributeError yadda-yadda, also not my wallpaper name of course. Is that my lack of sleep tricking me? Thanks, sebas -- http://vizZzion.org | GPG Key ID: 9119 0EF9 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Give a man a fire and he's warm for the day. Set fire to him and he's warm for the rest of his life pgpkF8dLisxJp.pgp Description: PGP signature ___ PyKDE mailing listPyKDE@mats.imk.fraunhofer.de http://mats.imk.fraunhofer.de/mailman/listinfo/pykde
Re: [PyKDE] dcop
On Wednesday 26 May 2004 06:47, Amand Tihon wrote: > Ah. Then I understand why I've got problem with this :) > > Here's what I'm doing: > - Subclass DCOPObject > - Redefine interfaces() and functions(). Making them return a (python) list > of (python) string instead of a QCStringList works out of the box. > - Redefine process(). It's this one that's painful because I have to do the > [de]marshalling of data and replyData by hand. > Are there any functions that could help me doing this, in current version ? I haven't looked at the DCOPObject stuff very much, but it shouldn't be too much of a problem (famous last words). Marshalling/demarshalling is the hard part - very ugly in Python, very easy in C++. You can use Python strings as QByteArrays, but much beyond a single int or a real char string that's pretty difficult. Jim ___ PyKDE mailing list[EMAIL PROTECTED] http://mats.imk.fraunhofer.de/mailman/listinfo/pykde
Re: [PyKDE] dcop
Le mercredi 26 Mai 2004 06:54, Jim Bublitz a écrit : > On Tuesday 25 May 2004 20:22, Amand Tihon wrote: > > Hello, > > > > I've been playing with pyKDE and DCOP these last few days, and I must say > > it is not really easy. The main problem being I haven't been able to find > > any documentation (as soon as I have something working, I'll put it on > > the wiki). > It always cheers me up when someone asks about something I'm in the middle > of. I basically got a PyKDE-adapted version of pydcop (from kde-bindings - > written by Torben Weis and Julian Rockey) working this afternoon. Here's > the basic code to call a DCOP method and get the result back: [snip] That's pretty neat. I must admit I've only used kdcop for my tests, so far. > The other things I haven't looked at yet at all are DCOP enabling apps you > write using PyKDE or handling DCOP signals, but there's code I can steal > for that too. Ah. Then I understand why I've got problem with this :) Here's what I'm doing: - Subclass DCOPObject - Redefine interfaces() and functions(). Making them return a (python) list of (python) string instead of a QCStringList works out of the box. - Redefine process(). It's this one that's painful because I have to do the [de]marshalling of data and replyData by hand. Are there any functions that could help me doing this, in current version ? Thanks for your help, -- Amand Tihon pgphz2rTWAQmS.pgp Description: signature
Re: [PyKDE] dcop
On Tuesday 25 May 2004 20:22, Amand Tihon wrote: > Hello, > > I've been playing with pyKDE and DCOP these last few days, and I must say > it is not really easy. The main problem being I haven't been able to find > any documentation (as soon as I have something working, I'll put it on the > wiki). > > Up to now, I've managed to implement void functions. > > But either there's something I didn't understand, or the python prototype > of DCOPObject.process() should be reviewed. > > Currently, the replyType and replyData are passed as arguments (as it is in > C++). Their types are respectively QCString and QByteArray. > The replyType is not a real problem, as I can set it with the setStr() > method. However, pyKDE offers very few ways to interract with a QByteArray. > And since it is passed as reference, I cannot build one from a python > string. > > I'd like to be able to return at least a bool, an int, a QCString or a > QCStringList. I've already tried to play with some QDataStream, etc, but > pyKDE doesn't support the stream operators << and >>, and I couldn't obtain > any result. > > Perhaps the process() method should return a tuple of (bool, [something]) ? > I don't know if it would be perfect, though. > > Does anyone know how to solve this ? It always cheers me up when someone asks about something I'm in the middle of. I basically got a PyKDE-adapted version of pydcop (from kde-bindings - written by Torben Weis and Julian Rockey) working this afternoon. Here's the basic code to call a DCOP method and get the result back: [methods from kicker/Panel are int panelSize () and void addURLButton (QString)] app = KApplication (...) d = DCOPApplication ("kicker, app.dcopClient ()) ok, pSize = d.Panel.panelSize () # pSize gets the int from the call -or- ok = d.Panel.addURLButton (QString ("http://kde.org";)) (the QString (...) may not be required - haven't tested it yet). That's all that's required. The dcop extension (one .py file and two global functions added to the PyKDE kdecore lib) will take care of marshalling the arguments (you have to provide the correct argument value types and count), calling the function and demarshalling the replyData. The underlying methods are available if you want to/need to do it the hard way. The kdecore functions allow you to easily pack and unpack a QByteArray (using a QDataStream). No << or >> operators yet though (function calls instead) - maybe in the future, although the interface above makes them un-needed. You need to borrow the dcopClient instance from a KApplication (the second param in the DCOPApplication call). The methods above always return at least a bool ('ok' - the status value from the DCOP call -True== success, False == Failure), and a value if the method isn't void. I'm in the process of figuring what types to support, but most of the common Qt and KDE classes that DCOP uses will be supported - for the most part supporting a type is trivial. Not sure about the template types yet (for example, QMap). Also, docs are needed and I need to decide if some exceptions are required or if what's already there is sufficient. I already had the basic QByteArray/QDataStream code done, and with what PyKDE has available plus the elegant interface the KDE guys named above wrote (and I stole) it's a pretty slick little package. Not much code at all. It may not be finished for the next PyKDE release, but I'll probably include it anyway, as it's pretty usable already. I still have to look at handling the various string types (transparently I hope) and passing in things like lists or dicts from Python. There should be something available in a couple of weeks. The other things I haven't looked at yet at all are DCOP enabling apps you write using PyKDE or handling DCOP signals, but there's code I can steal for that too. Jim ___ PyKDE mailing list[EMAIL PROTECTED] http://mats.imk.fraunhofer.de/mailman/listinfo/pykde
[PyKDE] dcop
Hello, I've been playing with pyKDE and DCOP these last few days, and I must say it is not really easy. The main problem being I haven't been able to find any documentation (as soon as I have something working, I'll put it on the wiki). Up to now, I've managed to implement void functions. But either there's something I didn't understand, or the python prototype of DCOPObject.process() should be reviewed. Currently, the replyType and replyData are passed as arguments (as it is in C++). Their types are respectively QCString and QByteArray. The replyType is not a real problem, as I can set it with the setStr() method. However, pyKDE offers very few ways to interract with a QByteArray. And since it is passed as reference, I cannot build one from a python string. I'd like to be able to return at least a bool, an int, a QCString or a QCStringList. I've already tried to play with some QDataStream, etc, but pyKDE doesn't support the stream operators << and >>, and I couldn't obtain any result. Perhaps the process() method should return a tuple of (bool, [something]) ? I don't know if it would be perfect, though. Does anyone know how to solve this ? Thanks. -- Amand Tihon pgpNh3dwetj9p.pgp Description: signature
Re: [PyKDE] DCOP Problems and Solutions
On Tuesday November 18 2003 10:16, Diez B. Roggisch wrote: > > I'd be interested in hearing opinions on any of this. I'll > > make some decision on kab in the next few days depending on > > what feedback I get. > Now obviously I'm for putting kab in pyKDE :) I'm not sure > what kjs exactly does - but working in python and then > allowing java-script for scripting - doesn't make much sense > to me. kjs is in PyKDE because it fits in with khtml (and more likely because it was fairly easy to add). > For the problem I want kab for - python play out its strenghs > when dealing with conversions between different sorts of > (string-based) formats. And there's plethorea of > PDA/CellPhones out there, that could benefit from an fairly > easy way to be synchronized, because all of them have their > own format... It seems like a good Python application to me - the first program I did with Python/PyKDE was an address book (before I started maintaining PyKDE). > Of course I'm not sure what kdepim is up to - maybe they will > change great parts of the related interface, so putting effort > into kab would make not much sense - at least now. Does > anybody know what they are going to change for kde 3.2? Just from looking at 3.2 briefly, it appears that the address book application (along with KMail, KOrganizer and some other stuff) will all be rolled into kontact but still remain as standalone applications. I would expect the kab lib won't change much though. I'd also like to be able to script kontact eventually (and a lot of it is plugin-based already). Jim ___ PyKDE mailing list[EMAIL PROTECTED] http://mats.imk.fraunhofer.de/mailman/listinfo/pykde
Re: [PyKDE] DCOP Problems and Solutions
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi, > I'd be interested in hearing opinions on any of this. I'll make > some decision on kab in the next few days depending on what > feedback I get. Now obviously I'm for putting kab in pyKDE :) I'm not sure what kjs exactly does - but working in python and then allowing java-script for scripting - doesn't make much sense to me. For the problem I want kab for - python play out its strenghs when dealing with conversions between different sorts of (string-based) formats. And there's plethorea of PDA/CellPhones out there, that could benefit from an fairly easy way to be synchronized, because all of them have their own format... Of course I'm not sure what kdepim is up to - maybe they will change great parts of the related interface, so putting effort into kab would make not much sense - at least now. Does anybody know what they are going to change for kde 3.2? Regards, Diez -BEGIN PGP SIGNATURE- Version: GnuPG v1.2.3 (GNU/Linux) iD8DBQE/umIKBUNnEs5xWG4RAg82AJ9LOfDpMA3lE9PzpKXrThaCx/YzKgCgms0L 7inbkTCV7A1fBuMUHkyZtpo= =0YOq -END PGP SIGNATURE- ___ PyKDE mailing list[EMAIL PROTECTED] http://mats.imk.fraunhofer.de/mailman/listinfo/pykde
Re: [PyKDE] DCOP Problems and Solutions
On Tuesday November 18 2003 08:47, Diez B. Roggisch wrote: > > looked into that much at all, but will eventually). If I'm > > missing something else (that you'd really want to use) let > > me know. > Hmmm - this is really not sooo important, but I'm missing the > bindings for the kaddressbook (module is called kab). > I have been successfully connection my cellphone using python > + usb, and wanted to write a small synchronization-tool, as > kandy currently doesn't work for me. > Its a while since I looked into SIP, so I'm not sure how > complicated it is to wrap the 6 objects I can see here > http://developer.kde.org/documentation/library/3.0-api/classre >f/kab/index.html I've debated doing bindings for kab for a while - the previous address book library was much more complicated to write bindings for and in my opinion wasn't as useful as the current version. I looked at the current version a few months ago, and it's not too difficult to do bindings for but it does require some handwritten code. The handwritten code also isn't that difficult, but it's "challenging" if you've never used sip before (and the structure will change with sip 4 as well). Someone else had expressed interest in writing kab bindings - I'm not sure where that stands at the moment. I'm not sure how to proceed on this - if no one else is planning to do bindings for kab, I can probably get them done fairly quickly. The other question is whether they should be added into PyKDE (which is pretty large already) or be a standalone set of bindings? Do you guys think PyKDE is too big already, or should I add another module? If someone else is planning on doing it, let me know - I'd be happy to provide assistance too. Kind of related to this is whether some of the other modules in PyKDE are something people really will want/use. kdesu is largely undocumented by KDE, kdeprint and kjs may not be that useful either. None of those has really been tested very thoroughly or has any example code written. I could, for example, drop those three modules and add kab which would make PyKDE a little smaller/faster to compile (maybe 10% improvement). I could also split those off as a separate package, although there was a complaint this morning on comp.lang.python about there being too many packages already. I'd be interested in hearing opinions on any of this. I'll make some decision on kab in the next few days depending on what feedback I get. Jim ___ PyKDE mailing list[EMAIL PROTECTED] http://mats.imk.fraunhofer.de/mailman/listinfo/pykde
[PyKDE] DCOP Problems and Solutions
I think I've mentioned here before that I don't know much about DCOP and haven't been too sure that what's included in PyKDE is correct or sufficient (it's been there mostly so kdecore would build). You may have noticed a short exchange on comp.lang.python with Eric Williams (hi Eric!), who finally got me to take a look at the sorry state the PyKDE DCOP implementation is in (no one has asked previously). It appears to need only some relatively simple fixes for the most part (some of the implementation might be a little difficult to do, but it should be very usable in even the worst case). My plan is to update all of the dcop module and provide some examples (probably stolen from Eric) and docs in the PyKDE 4.0 release, which is a ways off. It will also include sip 4.0 final and KDE 3.2 final. With that improvement and David's software, PyKDE will be able to support everything KDE does (I think) except panel extensions (trivial - almost the same as panel applets) and styles (haven't looked into that much at all, but will eventually). If I'm missing something else (that you'd really want to use) let me know. Jim ___ PyKDE mailing list[EMAIL PROTECTED] http://mats.imk.fraunhofer.de/mailman/listinfo/pykde