View previous topic :: View next topic |
Author |
Message |
l3u Advocate
Joined: 26 Jan 2005 Posts: 2616 Location: Konradsreuth (Germany)
|
Posted: Mon Mar 05, 2007 6:22 pm Post subject: kabc von Perl bzw. Python aus nutzen |
|
|
Mahlzeit :-)
Weiß einer von euch, wie man "richtig" auf die kaddressbook-Dateien mit Perl oder Python zugreifen kann? Ich hab ein paar Sachen gemacht, z. B. ein Perl-Script, was E-Mail-Adressen sammelt, wenn ich eine Mail an jemanden verschicke, der noch nicht in meinem Adreßbuch steht. Funktioniert zwar, ist aber eher quick-and-dirty, weil ich einfach nen kleinen Parser für das Adreßbuch geschrieben habe, der aber nur funktioniert, wenn es als Textdatei vorliegt. Und zwar als eine.
Ich würd das (und ein paar andere Sachen) gern "richtig" programmieren, weil ich denke, daß für sowas schon ein Bedarf bestünde ... aber die bisherige Lösung ist mir zu Hack-mäßig, um sie zu veröffentlichen. Ich wär echt froh über Tips :-)
MfG, Libby |
|
Back to top |
|
|
dakjo Veteran
Joined: 31 Jan 2004 Posts: 1544
|
Posted: Mon Mar 05, 2007 7:51 pm Post subject: |
|
|
Ich würde da eher mal im KDE Forum fragen. |
|
Back to top |
|
|
astaecker Guru
Joined: 28 Apr 2003 Posts: 403 Location: Hamburg / Germany
|
Posted: Mon Mar 05, 2007 7:59 pm Post subject: |
|
|
Für Python gibt es PyKDE. Und da gibt es auch Klassen für KABC. |
|
Back to top |
|
|
l3u Advocate
Joined: 26 Jan 2005 Posts: 2616 Location: Konradsreuth (Germany)
|
Posted: Mon Mar 05, 2007 9:32 pm Post subject: |
|
|
Gibt's da irgendwo ein Beispiel, wie das funktioniert? Ich hab mir das schonmal vor längerer Zeit angeschaut, und ich hab's einfach nicht hingekriegt ... |
|
Back to top |
|
|
Fauli l33t
Joined: 24 Apr 2004 Posts: 760 Location: Moers, Germany
|
Posted: Tue Mar 06, 2007 8:00 pm Post subject: |
|
|
Hier ein Miniprogrämmchen mit KABC: Code: | #!/usr/bin/python
import sys
from kdecore import KApplication
from kabc import KABC
app = KApplication(sys.argv, "AddressbookApp")
stdab = KABC.StdAddressBook()
for address in stdab.allAddressees():
print address.realName().latin1().decode("latin1")
del stdab
|
_________________ Do your part to beautify the web! Turn off link underlining! |
|
Back to top |
|
|
l3u Advocate
Joined: 26 Jan 2005 Posts: 2616 Location: Konradsreuth (Germany)
|
Posted: Wed Mar 07, 2007 2:32 pm Post subject: |
|
|
Funktioniert nicht :-(
Code: | Traceback (most recent call last):
File "./kabc.py", line 4, in ?
from kabc import KABC
File "/home/tobias/bin-test/kabc.py", line 4, in ?
from kabc import KABC
ImportError: cannot import name KABC |
|
|
Back to top |
|
|
Fauli l33t
Joined: 24 Apr 2004 Posts: 760 Location: Moers, Germany
|
Posted: Wed Mar 07, 2007 6:08 pm Post subject: |
|
|
Welche Version von PyKDE hast du installiert? Ich habe hier dev-python/pykde-3.16.0. _________________ Do your part to beautify the web! Turn off link underlining! |
|
Back to top |
|
|
l3u Advocate
Joined: 26 Jan 2005 Posts: 2616 Location: Konradsreuth (Germany)
|
Posted: Wed Mar 07, 2007 9:00 pm Post subject: |
|
|
Vorhin hab ich festgestellt, daß wohl scheinbar in kde-base/pykde keine kabc-Bindings drin sind. Seither versuche ich dev-python/pykde-3.16.10 zu installieren. Damit wird's ja wahrscheinlich gehen, aber ... seit drei Stunden starre ich auf eine Konsole, in der steht
Code: | i686-pc-linux-gnu-g++ -c -Wno-deprecated-declarations -pipe -fPIC -march=pentium4 -O2 -pipe -fno-strict-aliasing -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_THREAD_SUPPORT -I. -I../extra/kde353 -I/usr/kde/3.5/include -I/usr/include/python2.4 -I/usr/qt/3/mkspecs/linux-g++ -I/usr/qt/3/include -I/usr/X11R6/include -o sipkdeuipart1.o sipkdeuipart1.cpp |
Meine 512 MB RAM sind randvoll, und der Computer Swappt wie ein Weltmeister (~600 MB Swap). Kann's das geben, daß so ein paar popelige Python-Bindings DERART viel Arbeitsspeicher zumKompilieren brauchen?! |
|
Back to top |
|
|
Fauli l33t
Joined: 24 Apr 2004 Posts: 760 Location: Moers, Germany
|
Posted: Wed Mar 07, 2007 9:49 pm Post subject: |
|
|
Mach mal ein: Code: | MAKEOPTS="-j1" emerge dev-python/pykde |
_________________ Do your part to beautify the web! Turn off link underlining! |
|
Back to top |
|
|
l3u Advocate
Joined: 26 Jan 2005 Posts: 2616 Location: Konradsreuth (Germany)
|
Posted: Wed Mar 07, 2007 10:27 pm Post subject: |
|
|
Hab ich probiert, danach ging's. ich hab auch nen Bugreport geschrieben ... scheint ein bekanntes Problem zu sein. Naja, zumindest klappt's jetzt mit dem KABC ;-)
EDIT:
Okay, ein bißchen bin ich jetzt dahintergestiegen, wie das läuft. mit KABC.StdAddressBook() kann ich auf den Inhalt sämtlicher Adreßbücher zurückgreifen. Aber wie kann ich auf ein bestimmtes zugreifen? Im konkreten Fall auf das, in dem dann die Adressen gesammelt werden sollen?
EDIT: Hab's hinbekommen ;-) |
|
Back to top |
|
|
l3u Advocate
Joined: 26 Jan 2005 Posts: 2616 Location: Konradsreuth (Germany)
|
|
Back to top |
|
|
|