View Single Post
Posts: 2 | Thanked: 7 times | Joined on Dec 2012
#27
Here's a snippet for adding a contact from the command line:

PHP Code:
#!/usr/bin/env python
#
# Please let me know if this works without python-gnome2 installed!
#

USE='Use: addressbook add_contact given-name=John family-name=Doe email-1=johndoe@example.com'

import os
import sys
import evolution

def quit
message):
    
sys.stderr.write("%s\n"message)
    exit( 
1)

if 
== os.getuid():
    
quit('Not as root please')

adb evolution.ebook.open_addressbook('default')

# Not listing contact because already covered: http://maemo.cloud-7.de/maemo5/usr/local/bin/contact
#def list_contacts( args):
#    for contact in adb.get_all_contacts():
#        print [contact.get_property(ppt) for ppt in ['full-name', 'mobile-phone']]

if lensys.argv) < or sys.argv[1] != 'add_contact':
    
quit( USE)

ct evolution.ebook.EContact()

for 
arg in sys.argv[2:]:
    
namevalue arg.split('=')
    
ct.set_propertynamevalue)

adb.add_contactct
There's also a longer script that can list in YAML and VCARD and add and remove contacts.

Last edited by unclouded; 2012-12-18 at 07:38.
 

The Following User Says Thank You to unclouded For This Useful Post: