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