comparison link2contact.py @ 0:d31fcb953080 default tip

A quick script which will allow you to add a link to someone via kopete.
author darius@inchoate.localdomain
date Mon, 19 Nov 2007 23:28:23 +1030
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:d31fcb953080
1 #!/usr/bin/env python
2
3 import sys
4 import dcopext
5 import subprocess
6
7 if (len(sys.argv) < 2):
8 sys.stderr.write("Bad usage:\n")
9 sys.stderr.write(sys.argv[0] + " url [url] [url]\n")
10 sys.exit(1)
11
12 dcopClient = dcopext.DCOPClient()
13 assert(dcopClient.attach())
14 kopete = dcopext.DCOPApp('kopete', dcopClient)
15 ok, contacts = kopete.KopeteIface.reachableContacts()
16 assert(ok)
17
18 print contacts
19 cmd = ['kdialog', '--menu', 'Please choose a contact']
20 for c in contacts:
21 print "Adding " + str(c)
22 cmd.append(str(c))
23 cmd.append(str(c))
24
25 print cmd
26 c = subprocess.Popen(cmd, stdout=subprocess.PIPE)
27 answer = c.communicate()
28 name = answer[0].strip()
29 print name
30 assert(c.wait() == 0)
31
32 print "Looking up " + name
33 ok, accts = kopete.KopeteIface.contactsForDisplayName(name)
34 assert(ok)
35 for a in accts:
36 print " |" + a + "| ",
37 print
38
39
40 msg = ""
41 for a in sys.argv[1:]:
42 msg = msg + a + "\n"
43
44 ok, remsg = kopete.KopeteIface.messageContact(accts[0], msg)
45 assert(ok)
46 print "Got - " + remsg
47
48