Reply
Thread Tools
blubbi's Avatar
Posts: 288 | Thanked: 113 times | Joined on Dec 2009 @ Germany
#11
Well, in fact it does not work the way I expect it.

I run your code on my Contact and all I get is
Code:
>>> for p in phone_attributes:
...  print p, me.get_property(p)
...
assistant-phone None
business-phone None
business-phone-2 None
business-fax None
callback-phone None
car-phone None
company-phone None
home-phone None
home-phone-2 None
home-fax None
isdn-phone None
mobile-phone +4917****
other-phone None
other-fax +4934***
pager None
primary-phone None
radio None
telex None
tty None
>>>
But I have two numbers in category "Mobile", one in "Mobile (home)", two in Phone (home), one in "Phone (work)"

So IMHO ist should look like:
Code:
assistant-phone None
business-phone None
business-phone-2 None
business-fax None
callback-phone None
car-phone None
company-phone +49345***
home-phone +49345***
home-phone +49345***
home-phone-2 None
home-fax None
isdn-phone None
mobile-phone +49173***
mobile-phone +49170***
other-phone None
other-fax +49345***
pager None
primary-phone None
radio None
telex None
tty None
And for Fax I have nothing...
So either there is something wrong with the mapping or we ar doing something terribly wrong.

Second there is nothing like 'mobile-home'

I am going nuts there is no documentation about the available attributes used in the addressbook and no docu about the attributes available to "python-evolution".

I guess the only way to get a serious list of numbers is via ctypes, but I would rather like to avoid this. *grrrr*

Any ideas?

Cheers
Bjoern
 
Posts: 15 | Thanked: 4 times | Joined on Mar 2010
#12
Idea is to look how Hermes does it. I've browsed their source code yesterday.. looks they use "proper" way of accessing contacts..

Btw: there should be some new external python lib for accessing contacts in more object oriented way.. Hermes does it somehow, I will somehow, you will somehow.. each of us on its own..

Should be some common public code for that...
 
blubbi's Avatar
Posts: 288 | Thanked: 113 times | Joined on Dec 2009 @ Germany
#13
Originally Posted by nthx View Post
Idea is to look how Hermes does it. I've browsed their source code yesterday.. looks they use "proper" way of accessing contacts..

Btw: there should be some new external python lib for accessing contacts in more object oriented way.. Hermes does it somehow, I will somehow, you will somehow.. each of us on its own..

Should be some common public code for that...
Well, hermes uses python-evolution and ctypes for the shortcomings of python-evolution.

DAMN, is Nokia not able to release a python module to access the database they use properly?

Currently python-evolution is just a ugly hack.

I don't have a lot of spare time to code my programs, and I don't wan't to wast my time on hacking around flaws.
 
nicolai's Avatar
Posts: 1,637 | Thanked: 4,424 times | Joined on Apr 2009 @ Germany
#14
I dont know if this is a fault in python-evolution, have you tried to use
libebook from c rather then from python. It looks like, that this
way to get multiple mobile-phone numbers (get contact, get contact properties ...)
wouldnt work even there. I dont know, just a guess.

However, you can create vcard string from your contacts
(with "contact[x].get_vcard_string()")
and parse this string for "TEL;TYPE=HOME" or "TEL;TYPE=CELL".
This is an easy way to get all phone numbers.

nicolai
 
blubbi's Avatar
Posts: 288 | Thanked: 113 times | Joined on Dec 2009 @ Germany
#15
Originally Posted by nicolai View Post
I dont know if this is a fault in python-evolution, have you tried to use
libebook from c rather then from python. It looks like, that this
way to get multiple mobile-phone numbers (get contact, get contact properties ...)
wouldnt work even there. I dont know, just a guess.

However, you can create vcard string from your contacts
(with "contact[x].get_vcard_string()")
and parse this string for "TEL;TYPE=HOME" or "TEL;TYPE=CELL".
This is an easy way to get all phone numbers.

nicolai
Hey man, thanks for this nice hint!
I'll try the "vcard" workaround ASAP.
I hope the vcard includes ALL numbers :-)

Thanks a lot!

Cheers
Bjoern
 
Posts: 200 | Thanked: 300 times | Joined on Nov 2009 @ The Netherlands
#16
Originally Posted by nthx View Post
I've found the reason...

=username

I log with different username, though the same UID as 'user'
That's the reason. Library can't find /home/*/.osso/*


When logged as 'user' I get proper results
Is there a way to make it also run as root?

I'm using this Python code as part of a cgi-bin script on my website on my N900.

But a cgi-bin script under lighttpd is run as root so it won't work...
 
Posts: 15 | Thanked: 4 times | Joined on Mar 2010
#17
Originally Posted by digitalvoid View Post
Is there a way to make it also run as root?

I'm using this Python code as part of a cgi-bin script on my website on my N900.

But a cgi-bin script under lighttpd is run as root so it won't work...
The 2 methods worked for me to access addressbook from python:
a) su - user
b) symlinking dirs

Probably, if you symlink dirs for /root you will also be able to read addressbook. But I don't know if there aren't any side effects to this method. I didn't experience any .. yet

Code:
cd /home/your-custom-user/
ln -s /home/user/.osso-abook/

cd /root/
ln -s /home/user/.osso-abook/
ipython
....
 

The Following User Says Thank You to nthx For This Useful Post:
Posts: 200 | Thanked: 300 times | Joined on Nov 2009 @ The Netherlands
#18
Still having some problem; if I use the python evolution script inside a Python cgi-bin script on my phone's website it doesn't work.

I can't see what the problem is because the html page doesn't get generated.

If I remove the python evolution addressbook readout part the webpage works.


PS: the symlink solution above works great for running the python evolution script as root under cli.

Last edited by digitalvoid; 2010-04-01 at 11:41. Reason: typo
 
Posts: 15 | Thanked: 4 times | Joined on Mar 2010
#19
wow man ... :-/ vobject->vcard parsing is so slooooww

I get like 10x slower in parsing vcard.
When parsing 500 contacts it makes an 11 seconds difference vs 1sec when parsing contacts using "econtact.get_property()..."
But at least it looks more reliable, cause it returns ALL phones...

it's time to cache sth.. :/

Code:
    #ebook = evolution.ebook.open_addressbook("default")
    #self.econtact == abook.get_all_contacts()[x]

    def get_vcard(self):
        if not self.vcard:
            self.vcard = vobject.readOne(self.econtact.get_vcard_string())
        return self.vcard


    def phones_from_vobject_slow(self):
        #vcard parsing implementation: SLOW
        for line in self.get_vcard().lines():
            if 'TEL' == line.name and line.value:
                yield line.value


    def phones_from_ctypes(self):
        #initial implementation... not returning all phones..
        for phone_attr in ContactsAPI.phone_attributes:
            phone = self.econtact.get_property(phone_attr)
            if phone:
                yield phone
 
blubbi's Avatar
Posts: 288 | Thanked: 113 times | Joined on Dec 2009 @ Germany
#20
Originally Posted by nthx View Post
wow man ... :-/ vobject->vcard parsing is so slooooww

I get like 10x slower in parsing vcard.
When parsing 500 contacts it makes an 11 seconds difference vs 1sec when parsing contacts using "econtact.get_property()..."
But at least it looks more reliable, cause it returns ALL phones...

it's time to cache sth.. :/
Well, I don't have so many contacts, but until there is another solution I guess we have to stick with this ugly hack... :-(
 
Reply


 
Forum Jump


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