Reply
Thread Tools
jvesiluoma's Avatar
Posts: 28 | Thanked: 58 times | Joined on Jan 2010
#11
Ahh, found this ==> https://bugs.maemo.org/show_bug.cgi?id=9865 about bsddb, but can't find libdb4.2-dev , argh...

That bus is marked as fixed, but can't find libdb4.2 package for maemo(arm)?

Well, have to keep digging...


// Jarkko
 
jvesiluoma's Avatar
Posts: 28 | Thanked: 58 times | Joined on Jan 2010
#12
Okay, got it working (bsddb I mean).


If anyone is interested, first update python2.5-minimal 2.5.4-1maemo6 and then python2.5_2.5.4-1maemo6.

After that you can import bsddb, now it's just a matter of coding a small python program that exports contacts.


Thanks for your help.


Regards,
Jarkko
 

The Following 2 Users Say Thank You to jvesiluoma For This Useful Post:
b666m's Avatar
Posts: 1,090 | Thanked: 476 times | Joined on Jan 2010 @ Ingolstadt, Germany
#13
sorry for bringing this thread back to the daylight

but right now i'm in the same situation as the OP.
i need a solution for fetching the phonenumber of a contact from the cli.
something like: db_get -n name -o options
where "name" is the nickname (or complete name) of the contact and options could be "phone1" "phone2" (and so on) "email1" "address1" or something.

so... any news on this topic?
 
b666m's Avatar
Posts: 1,090 | Thanked: 476 times | Joined on Jan 2010 @ Ingolstadt, Germany
#14
an (somehow) unsatisfying workaround is the vcf-method mentioned here before.
in the contacts app gui i export them into a folder as 3.0 vcfs.
(works perfectly within seconds)
then i open up xterm and cd into that folder where i can get the cellphone number via cat | grep | cut.

because this is really fast and easy my new question is:
can i export my contacts to vcf via cli?

Last edited by b666m; 2011-04-17 at 14:53.
 
nicolai's Avatar
Posts: 1,637 | Thanked: 4,424 times | Joined on Apr 2009 @ Germany
#15
Quick Python script

PHP Code:
import evolution
import sys

from optparse import OptionParser

def search_contact
(options):
    
ebook evolution.ebook.open_addressbook("default")
    if 
not options.contact is None:
        
contacts ebook.search(options.contact)
    
elif not options.full_name is None:
        
contacts = []
        for 
c in ebook.get_all_contacts():
            if 
c.get_name() == options.full_name:
                
contacts.append(c)
    
elif not options.nick_name is None:
        
contacts = []
        for 
c in ebook.get_all_contacts():
            if 
c.get_property("nickname") == options.nick_name:
                
contacts.append(c)
    
    if (
not options.attributes is None) and (len(options.attributes) > 0):
        for 
contact in contacts:
            print 
contact.get_property("full-name")
            for 
a in options.attributes:
                print 
contact.get_property(a)
    if 
options.list:
        for 
contact in contacts:
            for 
p in contact.props:
                
value contact.get_property(p.name)
                if 
not value is None
                    print 
p.namevalue

    
if options.export:
        for 
contact in contacts:
            print 
contact.get_vcard_string()

def main():
    
parser OptionParser()
    
parser.add_option("-c""--contact"help="contact name to search for"action="store"type="string"dest="contact")
    
parser.add_option("-f""--full-name"help="select contact with this name"action="store"type="string"dest="full_name")
    
parser.add_option("-n""--nickname"help="select contact with this nickname"action="store"type="string"dest="nick_name")
    
parser.add_option("-a""--attribute"help="contact attributes -a attribute1 -a attribute2 .."action="append"type="string"dest="attributes")
    
parser.add_option("-e""--export"help="print vcard string"action="store_true"dest="export", default=False)
    
parser.add_option("-l""--list-attributes"help="list vcard attributes"action="store_true"dest="list", default=False)
    
    (
optionsargs) = parser.parse_args(sys.argv)
    
    if 
len(sys.argv) <= 1:
        
parser.print_help()
    else:
        
search_contact(options)

if 
__name__ == "__main__":
    
main() 

Last edited by nicolai; 2011-04-17 at 21:13.
 

The Following 7 Users Say Thank You to nicolai For This Useful Post:
b666m's Avatar
Posts: 1,090 | Thanked: 476 times | Joined on Jan 2010 @ Ingolstadt, Germany
#16
hi nicolai!

first of all: thanks for your work!

[ignore me]
but:
if i call your script with "python yourscript -c name" there is no output.
for name i tried nickname, last name, first name, first last, last first and even separated with commas and set in " ".

how do i use it correctly?
[/ignore me]

EDIT:

okay "python yourscript -c lastname -e" produces the vcf, cool!
but i would love to search for the nickname instead of the lastname.
EDIT2:
next problem is that -e makes the vcf for all contacts who contain the nickname-string.
example: search for "chris" matches "chris" but "christina" too. :/

and i'm struggeling with the -a attributes; what are they?
-a email is working.
but how do i get the cellphone number?

Last edited by b666m; 2011-04-17 at 18:38.
 

The Following User Says Thank You to b666m For This Useful Post:
nicolai's Avatar
Posts: 1,637 | Thanked: 4,424 times | Joined on Apr 2009 @ Germany
#17
changed my script in the post above.
python yourscript -f "Pink Panther" -l
searches for the contact with the fullname Pink Panther
and prints all defined contact attributes (mobile-phone, email-1, ...)

python yourscript -n pinky -l
searches for the contact with the nickname pinky

Nicolai
 

The Following 3 Users Say Thank You to nicolai For This Useful Post:
Posts: 291 | Thanked: 398 times | Joined on Jan 2011 @ USA
#18
Nicolai, how do i search for a name in ebook by given phone number? thanks


what i try to do is search for certain phone if it exist in the ebook and return a true or false.

Last edited by khuong; 2011-04-17 at 21:46.
 
Posts: 435 | Thanked: 769 times | Joined on Apr 2010
#19
Try this, call it in terminal and give as argument the nickname you wanna get the number off. Nickname must exactly match, no more christina while looking for chris.

Code:
./contactretrieve Marco
Attached Files
File Type: zip contactretrieve.zip (9.1 KB, 153 views)
 
Posts: 67 | Thanked: 36 times | Joined on May 2010 @ Claremont (LA), California
#20
Very cool, Nicolai. I hadn't known there was a Python interface to the databases. How did you learn about it?
 
Reply

Thread Tools

 
Forum Jump


All times are GMT. The time now is 03:48.