Fri, 02 Sep 2016 00:45:59 -0400
Remove some "clever" Python code.
|
37444
8c851c1bc85b
Ensure backwards compatibility with Python 2
Daniël van Eeden <hg@myname.nl>
parents:
37443
diff
changeset
|
1 | #!/usr/bin/env python |
|
37983
7d134a4a87b2
Ensure all Python scripts are Py3k compatible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37910
diff
changeset
|
2 | |
|
7d134a4a87b2
Ensure all Python scripts are Py3k compatible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37910
diff
changeset
|
3 | from __future__ import absolute_import, division, print_function |
|
7d134a4a87b2
Ensure all Python scripts are Py3k compatible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37910
diff
changeset
|
4 | |
| 14582 | 5 | import dbus |
| 6 | import re | |
| 7 | import sys | |
| 8 | import time | |
|
37444
8c851c1bc85b
Ensure backwards compatibility with Python 2
Daniël van Eeden <hg@myname.nl>
parents:
37443
diff
changeset
|
9 | try: |
|
8c851c1bc85b
Ensure backwards compatibility with Python 2
Daniël van Eeden <hg@myname.nl>
parents:
37443
diff
changeset
|
10 | from urllib.parse import unquote_plus |
|
8c851c1bc85b
Ensure backwards compatibility with Python 2
Daniël van Eeden <hg@myname.nl>
parents:
37443
diff
changeset
|
11 | except ImportError: |
|
8c851c1bc85b
Ensure backwards compatibility with Python 2
Daniël van Eeden <hg@myname.nl>
parents:
37443
diff
changeset
|
12 | from urllib import unquote_plus |
| 14582 | 13 | |
|
37984
6a5ca046a90d
Make all Python files PEP8 compatible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37983
diff
changeset
|
14 | |
|
23562
312323547538
Handle D-Bus errors more helpfully in purple-url-handler.
Will Thompson <resiak@pidgin.im>
parents:
23237
diff
changeset
|
15 | bus = dbus.SessionBus() |
|
312323547538
Handle D-Bus errors more helpfully in purple-url-handler.
Will Thompson <resiak@pidgin.im>
parents:
23237
diff
changeset
|
16 | obj = None |
|
312323547538
Handle D-Bus errors more helpfully in purple-url-handler.
Will Thompson <resiak@pidgin.im>
parents:
23237
diff
changeset
|
17 | try: |
|
312323547538
Handle D-Bus errors more helpfully in purple-url-handler.
Will Thompson <resiak@pidgin.im>
parents:
23237
diff
changeset
|
18 | obj = bus.get_object("im.pidgin.purple.PurpleService", |
|
312323547538
Handle D-Bus errors more helpfully in purple-url-handler.
Will Thompson <resiak@pidgin.im>
parents:
23237
diff
changeset
|
19 | "/im/pidgin/purple/PurpleObject") |
|
37443
78408ad717bd
Make purlpe-url-handler work with Python 3
Daniël van Eeden <hg@myname.nl>
parents:
31582
diff
changeset
|
20 | except dbus.DBusException as e: |
|
23562
312323547538
Handle D-Bus errors more helpfully in purple-url-handler.
Will Thompson <resiak@pidgin.im>
parents:
23237
diff
changeset
|
21 | if e._dbus_error_name == "org.freedesktop.DBus.Error.ServiceUnknown": |
|
37984
6a5ca046a90d
Make all Python files PEP8 compatible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37983
diff
changeset
|
22 | print("Error: no libpurple-powered client is running. " |
|
6a5ca046a90d
Make all Python files PEP8 compatible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37983
diff
changeset
|
23 | "Try starting Pidgin or Finch.") |
|
23562
312323547538
Handle D-Bus errors more helpfully in purple-url-handler.
Will Thompson <resiak@pidgin.im>
parents:
23237
diff
changeset
|
24 | sys.exit(1) |
|
16205
397be242f4a4
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@pidgin.im>
parents:
15987
diff
changeset
|
25 | purple = dbus.Interface(obj, "im.pidgin.purple.PurpleInterface") |
| 14582 | 26 | |
|
37984
6a5ca046a90d
Make all Python files PEP8 compatible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37983
diff
changeset
|
27 | |
|
37983
7d134a4a87b2
Ensure all Python scripts are Py3k compatible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37910
diff
changeset
|
28 | class CheckedObject(object): |
| 14582 | 29 | def __init__(self, obj): |
| 30 | self.obj = obj | |
| 31 | ||
| 32 | def __getattr__(self, attr): | |
| 33 | return CheckedAttribute(self, attr) | |
| 34 | ||
|
37984
6a5ca046a90d
Make all Python files PEP8 compatible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37983
diff
changeset
|
35 | |
|
37983
7d134a4a87b2
Ensure all Python scripts are Py3k compatible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37910
diff
changeset
|
36 | class CheckedAttribute(object): |
| 14582 | 37 | def __init__(self, cobj, attr): |
| 38 | self.cobj = cobj | |
| 39 | self.attr = attr | |
| 40 | ||
| 41 | def __call__(self, *args): | |
|
16207
b4b168c28673
Print decent error messages instead of stack traces if there's a problem.
Richard Laager <rlaager@pidgin.im>
parents:
16205
diff
changeset
|
42 | # Redirect stderr to suppress the printing of an " Introspect error" |
|
b4b168c28673
Print decent error messages instead of stack traces if there's a problem.
Richard Laager <rlaager@pidgin.im>
parents:
16205
diff
changeset
|
43 | # message if nothing is listening on the bus. We print a friendly |
|
b4b168c28673
Print decent error messages instead of stack traces if there's a problem.
Richard Laager <rlaager@pidgin.im>
parents:
16205
diff
changeset
|
44 | # error message ourselves. |
|
b4b168c28673
Print decent error messages instead of stack traces if there's a problem.
Richard Laager <rlaager@pidgin.im>
parents:
16205
diff
changeset
|
45 | real_stderr = sys.stderr |
|
b4b168c28673
Print decent error messages instead of stack traces if there's a problem.
Richard Laager <rlaager@pidgin.im>
parents:
16205
diff
changeset
|
46 | sys.stderr = None |
| 14582 | 47 | result = self.cobj.obj.__getattr__(self.attr)(*args) |
|
16207
b4b168c28673
Print decent error messages instead of stack traces if there's a problem.
Richard Laager <rlaager@pidgin.im>
parents:
16205
diff
changeset
|
48 | sys.stderr = real_stderr |
|
b4b168c28673
Print decent error messages instead of stack traces if there's a problem.
Richard Laager <rlaager@pidgin.im>
parents:
16205
diff
changeset
|
49 | |
|
b4b168c28673
Print decent error messages instead of stack traces if there's a problem.
Richard Laager <rlaager@pidgin.im>
parents:
16205
diff
changeset
|
50 | # This can be useful for debugging. |
|
37984
6a5ca046a90d
Make all Python files PEP8 compatible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37983
diff
changeset
|
51 | # if result == 0: |
|
6a5ca046a90d
Make all Python files PEP8 compatible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37983
diff
changeset
|
52 | # print("Error:", self.attr, str(args), "returned", str(result)) |
|
16207
b4b168c28673
Print decent error messages instead of stack traces if there's a problem.
Richard Laager <rlaager@pidgin.im>
parents:
16205
diff
changeset
|
53 | |
| 14582 | 54 | return result |
| 55 | ||
|
37984
6a5ca046a90d
Make all Python files PEP8 compatible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37983
diff
changeset
|
56 | |
|
16205
397be242f4a4
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@pidgin.im>
parents:
15987
diff
changeset
|
57 | cpurple = CheckedObject(purple) |
| 14582 | 58 | |
|
37984
6a5ca046a90d
Make all Python files PEP8 compatible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37983
diff
changeset
|
59 | |
|
17323
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
60 | def extendlist(list, length, fill): |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
61 | if len(list) < length: |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
62 | return list + [fill] * (length - len(list)) |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
63 | else: |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
64 | return list |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
65 | |
|
37984
6a5ca046a90d
Make all Python files PEP8 compatible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37983
diff
changeset
|
66 | |
| 14582 | 67 | def convert(value): |
| 68 | try: | |
| 69 | return int(value) | |
| 70 | except: | |
| 71 | return value | |
| 72 | ||
|
37984
6a5ca046a90d
Make all Python files PEP8 compatible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37983
diff
changeset
|
73 | |
|
23563
04877760aaf1
Give findaccount an option 'matcher' callback parameter, to match arbitrary
Will Thompson <resiak@pidgin.im>
parents:
23562
diff
changeset
|
74 | def account_not_found(): |
|
37443
78408ad717bd
Make purlpe-url-handler work with Python 3
Daniël van Eeden <hg@myname.nl>
parents:
31582
diff
changeset
|
75 | print("No matching account found.") |
|
23563
04877760aaf1
Give findaccount an option 'matcher' callback parameter, to match arbitrary
Will Thompson <resiak@pidgin.im>
parents:
23562
diff
changeset
|
76 | sys.exit(1) |
|
04877760aaf1
Give findaccount an option 'matcher' callback parameter, to match arbitrary
Will Thompson <resiak@pidgin.im>
parents:
23562
diff
changeset
|
77 | |
|
37984
6a5ca046a90d
Make all Python files PEP8 compatible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37983
diff
changeset
|
78 | |
|
23563
04877760aaf1
Give findaccount an option 'matcher' callback parameter, to match arbitrary
Will Thompson <resiak@pidgin.im>
parents:
23562
diff
changeset
|
79 | def bring_account_online(account): |
|
04877760aaf1
Give findaccount an option 'matcher' callback parameter, to match arbitrary
Will Thompson <resiak@pidgin.im>
parents:
23562
diff
changeset
|
80 | if not cpurple.PurpleAccountIsConnected(account): |
|
04877760aaf1
Give findaccount an option 'matcher' callback parameter, to match arbitrary
Will Thompson <resiak@pidgin.im>
parents:
23562
diff
changeset
|
81 | # The last argument is meant to be a GList * but the D-Bus binding |
|
04877760aaf1
Give findaccount an option 'matcher' callback parameter, to match arbitrary
Will Thompson <resiak@pidgin.im>
parents:
23562
diff
changeset
|
82 | # generator thing just wants a UInt32, which is pretty failing. |
|
04877760aaf1
Give findaccount an option 'matcher' callback parameter, to match arbitrary
Will Thompson <resiak@pidgin.im>
parents:
23562
diff
changeset
|
83 | # Happily, passing a 0 to mean an empty list turns out to work anyway. |
|
04877760aaf1
Give findaccount an option 'matcher' callback parameter, to match arbitrary
Will Thompson <resiak@pidgin.im>
parents:
23562
diff
changeset
|
84 | purple.PurpleAccountSetStatusList(account, "online", 1, 0) |
|
04877760aaf1
Give findaccount an option 'matcher' callback parameter, to match arbitrary
Will Thompson <resiak@pidgin.im>
parents:
23562
diff
changeset
|
85 | purple.PurpleAccountConnect(account) |
|
04877760aaf1
Give findaccount an option 'matcher' callback parameter, to match arbitrary
Will Thompson <resiak@pidgin.im>
parents:
23562
diff
changeset
|
86 | |
|
37984
6a5ca046a90d
Make all Python files PEP8 compatible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37983
diff
changeset
|
87 | |
|
23563
04877760aaf1
Give findaccount an option 'matcher' callback parameter, to match arbitrary
Will Thompson <resiak@pidgin.im>
parents:
23562
diff
changeset
|
88 | def findaccount(protocolname, accountname="", matcher=None): |
|
04877760aaf1
Give findaccount an option 'matcher' callback parameter, to match arbitrary
Will Thompson <resiak@pidgin.im>
parents:
23562
diff
changeset
|
89 | if matcher: |
|
04877760aaf1
Give findaccount an option 'matcher' callback parameter, to match arbitrary
Will Thompson <resiak@pidgin.im>
parents:
23562
diff
changeset
|
90 | for account in cpurple.PurpleAccountsGetAll(): |
|
37984
6a5ca046a90d
Make all Python files PEP8 compatible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37983
diff
changeset
|
91 | if protocolname != cpurple.PurpleAccountGetProtocolId(account): |
|
6a5ca046a90d
Make all Python files PEP8 compatible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37983
diff
changeset
|
92 | continue |
|
6a5ca046a90d
Make all Python files PEP8 compatible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37983
diff
changeset
|
93 | if (accountname != "" and |
|
6a5ca046a90d
Make all Python files PEP8 compatible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37983
diff
changeset
|
94 | accountname != cpurple.PurpleAccountGetUsername(account)): |
|
23563
04877760aaf1
Give findaccount an option 'matcher' callback parameter, to match arbitrary
Will Thompson <resiak@pidgin.im>
parents:
23562
diff
changeset
|
95 | continue |
|
04877760aaf1
Give findaccount an option 'matcher' callback parameter, to match arbitrary
Will Thompson <resiak@pidgin.im>
parents:
23562
diff
changeset
|
96 | if matcher(account): |
|
04877760aaf1
Give findaccount an option 'matcher' callback parameter, to match arbitrary
Will Thompson <resiak@pidgin.im>
parents:
23562
diff
changeset
|
97 | bring_account_online(account) |
|
04877760aaf1
Give findaccount an option 'matcher' callback parameter, to match arbitrary
Will Thompson <resiak@pidgin.im>
parents:
23562
diff
changeset
|
98 | return account |
|
04877760aaf1
Give findaccount an option 'matcher' callback parameter, to match arbitrary
Will Thompson <resiak@pidgin.im>
parents:
23562
diff
changeset
|
99 | account_not_found() |
|
04877760aaf1
Give findaccount an option 'matcher' callback parameter, to match arbitrary
Will Thompson <resiak@pidgin.im>
parents:
23562
diff
changeset
|
100 | |
|
17323
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
101 | # prefer connected accounts |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
102 | account = cpurple.PurpleAccountsFindConnected(accountname, protocolname) |
|
37984
6a5ca046a90d
Make all Python files PEP8 compatible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37983
diff
changeset
|
103 | if account != 0: |
|
23563
04877760aaf1
Give findaccount an option 'matcher' callback parameter, to match arbitrary
Will Thompson <resiak@pidgin.im>
parents:
23562
diff
changeset
|
104 | return account |
|
17323
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
105 | |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
106 | # try to get any account and connect it |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
107 | account = cpurple.PurpleAccountsFindAny(accountname, protocolname) |
|
37984
6a5ca046a90d
Make all Python files PEP8 compatible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37983
diff
changeset
|
108 | if account == 0: |
|
23563
04877760aaf1
Give findaccount an option 'matcher' callback parameter, to match arbitrary
Will Thompson <resiak@pidgin.im>
parents:
23562
diff
changeset
|
109 | account_not_found() |
|
17323
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
110 | |
|
23563
04877760aaf1
Give findaccount an option 'matcher' callback parameter, to match arbitrary
Will Thompson <resiak@pidgin.im>
parents:
23562
diff
changeset
|
111 | bring_account_online(account) |
|
17323
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
112 | return account |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
113 | |
|
37984
6a5ca046a90d
Make all Python files PEP8 compatible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37983
diff
changeset
|
114 | |
|
17323
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
115 | def goim(account, screenname, message=None): |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
116 | # XXX: 1 == PURPLE_CONV_TYPE_IM |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
117 | conversation = cpurple.PurpleConversationNew(1, account, screenname) |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
118 | if message: |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
119 | purple.PurpleConvSendConfirm(conversation, message) |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
120 | |
|
37984
6a5ca046a90d
Make all Python files PEP8 compatible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37983
diff
changeset
|
121 | |
|
17323
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
122 | def gochat(account, params, message=None): |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
123 | connection = cpurple.PurpleAccountGetConnection(account) |
|
37900
07caaa17a5a6
Fix xmpp:jid?join URIs in purple-uri-handler.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37441
diff
changeset
|
124 | purple.PurpleServJoinChat(connection, params) |
|
17323
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
125 | |
|
37984
6a5ca046a90d
Make all Python files PEP8 compatible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37983
diff
changeset
|
126 | if message is not None: |
|
6a5ca046a90d
Make all Python files PEP8 compatible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37983
diff
changeset
|
127 | for i in range(20): |
|
17323
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
128 | # XXX: 2 == PURPLE_CONV_TYPE_CHAT |
|
37984
6a5ca046a90d
Make all Python files PEP8 compatible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37983
diff
changeset
|
129 | conversation = purple.PurpleFindConversationWithAccount( |
|
6a5ca046a90d
Make all Python files PEP8 compatible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37983
diff
changeset
|
130 | 2, |
|
6a5ca046a90d
Make all Python files PEP8 compatible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37983
diff
changeset
|
131 | params.get("channel", params.get("room")), |
|
6a5ca046a90d
Make all Python files PEP8 compatible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37983
diff
changeset
|
132 | account) |
|
17323
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
133 | if conversation: |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
134 | purple.PurpleConvSendConfirm(conversation, message) |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
135 | break |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
136 | else: |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
137 | time.sleep(0.5) |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
138 | |
|
37984
6a5ca046a90d
Make all Python files PEP8 compatible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37983
diff
changeset
|
139 | |
|
17323
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
140 | def addbuddy(account, screenname, group="", alias=""): |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
141 | cpurple.PurpleBlistRequestAddBuddy(account, screenname, group, alias) |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
142 | |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
143 | |
| 14582 | 144 | def aim(uri): |
|
16205
397be242f4a4
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@pidgin.im>
parents:
15987
diff
changeset
|
145 | protocol = "prpl-aim" |
| 16502 | 146 | match = re.match(r"^aim:([^?]*)(\?(.*))", uri) |
| 14582 | 147 | if not match: |
|
37984
6a5ca046a90d
Make all Python files PEP8 compatible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37983
diff
changeset
|
148 | print("Invalid aim URI: %s" % (uri, )) |
| 14582 | 149 | return |
| 150 | ||
|
37444
8c851c1bc85b
Ensure backwards compatibility with Python 2
Daniël van Eeden <hg@myname.nl>
parents:
37443
diff
changeset
|
151 | command = unquote_plus(match.group(1)) |
| 16502 | 152 | paramstring = match.group(3) |
| 14582 | 153 | params = {} |
| 154 | if paramstring: | |
| 155 | for param in paramstring.split("&"): | |
| 156 | key, value = extendlist(param.split("=", 1), 2, "") | |
|
37444
8c851c1bc85b
Ensure backwards compatibility with Python 2
Daniël van Eeden <hg@myname.nl>
parents:
37443
diff
changeset
|
157 | params[key] = unquote_plus(value) |
| 14582 | 158 | accountname = params.get("account", "") |
| 159 | screenname = params.get("screenname", "") | |
| 160 | ||
| 161 | account = findaccount(protocol, accountname) | |
| 162 | ||
|
14597
f6b179d6babb
[gaim-migrate @ 17256]
Richard Laager <rlaager@pidgin.im>
parents:
14582
diff
changeset
|
163 | if command.lower() == "goim": |
| 14582 | 164 | goim(account, screenname, params.get("message")) |
|
14597
f6b179d6babb
[gaim-migrate @ 17256]
Richard Laager <rlaager@pidgin.im>
parents:
14582
diff
changeset
|
165 | elif command.lower() == "gochat": |
| 14582 | 166 | gochat(account, params) |
|
14597
f6b179d6babb
[gaim-migrate @ 17256]
Richard Laager <rlaager@pidgin.im>
parents:
14582
diff
changeset
|
167 | elif command.lower() == "addbuddy": |
| 14582 | 168 | addbuddy(account, screenname, params.get("group", "")) |
| 169 | ||
|
37984
6a5ca046a90d
Make all Python files PEP8 compatible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37983
diff
changeset
|
170 | |
|
17323
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
171 | def gg(uri): |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
172 | protocol = "prpl-gg" |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
173 | match = re.match(r"^gg:(.*)", uri) |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
174 | if not match: |
|
37984
6a5ca046a90d
Make all Python files PEP8 compatible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37983
diff
changeset
|
175 | print("Invalid gg URI: %s" % (uri, )) |
|
17323
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
176 | return |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
177 | |
|
37444
8c851c1bc85b
Ensure backwards compatibility with Python 2
Daniël van Eeden <hg@myname.nl>
parents:
37443
diff
changeset
|
178 | screenname = unquote_plus(match.group(1)) |
|
17323
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
179 | account = findaccount(protocol) |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
180 | goim(account, screenname) |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
181 | |
|
37984
6a5ca046a90d
Make all Python files PEP8 compatible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37983
diff
changeset
|
182 | |
| 14582 | 183 | def icq(uri): |
|
16205
397be242f4a4
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@pidgin.im>
parents:
15987
diff
changeset
|
184 | protocol = "prpl-icq" |
| 16502 | 185 | match = re.match(r"^icq:([^?]*)(\?(.*))", uri) |
|
16205
397be242f4a4
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@pidgin.im>
parents:
15987
diff
changeset
|
186 | if not match: |
|
37984
6a5ca046a90d
Make all Python files PEP8 compatible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37983
diff
changeset
|
187 | print("Invalid icq URI: %s" % (uri, )) |
|
16205
397be242f4a4
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@pidgin.im>
parents:
15987
diff
changeset
|
188 | return |
|
397be242f4a4
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@pidgin.im>
parents:
15987
diff
changeset
|
189 | |
|
37444
8c851c1bc85b
Ensure backwards compatibility with Python 2
Daniël van Eeden <hg@myname.nl>
parents:
37443
diff
changeset
|
190 | command = unquote_plus(match.group(1)) |
| 16502 | 191 | paramstring = match.group(3) |
|
16205
397be242f4a4
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@pidgin.im>
parents:
15987
diff
changeset
|
192 | params = {} |
|
397be242f4a4
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@pidgin.im>
parents:
15987
diff
changeset
|
193 | if paramstring: |
|
397be242f4a4
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@pidgin.im>
parents:
15987
diff
changeset
|
194 | for param in paramstring.split("&"): |
|
397be242f4a4
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@pidgin.im>
parents:
15987
diff
changeset
|
195 | key, value = extendlist(param.split("=", 1), 2, "") |
|
37444
8c851c1bc85b
Ensure backwards compatibility with Python 2
Daniël van Eeden <hg@myname.nl>
parents:
37443
diff
changeset
|
196 | params[key] = unquote_plus(value) |
|
16205
397be242f4a4
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@pidgin.im>
parents:
15987
diff
changeset
|
197 | accountname = params.get("account", "") |
|
397be242f4a4
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@pidgin.im>
parents:
15987
diff
changeset
|
198 | screenname = params.get("screenname", "") |
|
397be242f4a4
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@pidgin.im>
parents:
15987
diff
changeset
|
199 | |
|
397be242f4a4
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@pidgin.im>
parents:
15987
diff
changeset
|
200 | account = findaccount(protocol, accountname) |
|
397be242f4a4
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@pidgin.im>
parents:
15987
diff
changeset
|
201 | |
|
397be242f4a4
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@pidgin.im>
parents:
15987
diff
changeset
|
202 | if command.lower() == "goim": |
|
397be242f4a4
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@pidgin.im>
parents:
15987
diff
changeset
|
203 | goim(account, screenname, params.get("message")) |
|
397be242f4a4
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@pidgin.im>
parents:
15987
diff
changeset
|
204 | elif command.lower() == "gochat": |
|
397be242f4a4
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@pidgin.im>
parents:
15987
diff
changeset
|
205 | gochat(account, params) |
|
397be242f4a4
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@pidgin.im>
parents:
15987
diff
changeset
|
206 | elif command.lower() == "addbuddy": |
|
397be242f4a4
Trac Ticket #149 from JensenDied
Richard Laager <rlaager@pidgin.im>
parents:
15987
diff
changeset
|
207 | addbuddy(account, screenname, params.get("group", "")) |
| 14582 | 208 | |
|
37984
6a5ca046a90d
Make all Python files PEP8 compatible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37983
diff
changeset
|
209 | |
|
17323
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
210 | def irc(uri): |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
211 | protocol = "prpl-irc" |
|
30530
8f5fecc9b6c8
Some fixes to IRC handling in purple-url-handler, mainly to fix
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
26065
diff
changeset
|
212 | match = re.match(r"^irc:(//([^/]*))?/?([^?]*)(\?(.*))?", uri) |
|
17323
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
213 | if not match: |
|
37984
6a5ca046a90d
Make all Python files PEP8 compatible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37983
diff
changeset
|
214 | print("Invalid irc URI: %s" % (uri, )) |
|
17323
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
215 | return |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
216 | |
|
37444
8c851c1bc85b
Ensure backwards compatibility with Python 2
Daniël van Eeden <hg@myname.nl>
parents:
37443
diff
changeset
|
217 | server = unquote_plus(match.group(2) or "") |
|
17323
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
218 | target = match.group(3) or "" |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
219 | query = match.group(5) or "" |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
220 | |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
221 | modifiers = {} |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
222 | if target: |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
223 | for modifier in target.split(",")[1:]: |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
224 | modifiers[modifier] = True |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
225 | |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
226 | paramstring = match.group(5) |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
227 | params = {} |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
228 | if paramstring: |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
229 | for param in paramstring.split("&"): |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
230 | key, value = extendlist(param.split("=", 1), 2, "") |
|
37444
8c851c1bc85b
Ensure backwards compatibility with Python 2
Daniël van Eeden <hg@myname.nl>
parents:
37443
diff
changeset
|
231 | params[key] = unquote_plus(value) |
|
17323
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
232 | |
|
23564
9ccc8c1ddc6b
Make irc:// URLs use an account on the right server, not just the first IRC
Will Thompson <resiak@pidgin.im>
parents:
23563
diff
changeset
|
233 | def correct_server(account): |
|
9ccc8c1ddc6b
Make irc:// URLs use an account on the right server, not just the first IRC
Will Thompson <resiak@pidgin.im>
parents:
23563
diff
changeset
|
234 | username = cpurple.PurpleAccountGetUsername(account) |
|
37984
6a5ca046a90d
Make all Python files PEP8 compatible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37983
diff
changeset
|
235 | return (server == "" or |
|
6a5ca046a90d
Make all Python files PEP8 compatible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37983
diff
changeset
|
236 | "@" in username and server == username.split("@")[1]) |
|
23564
9ccc8c1ddc6b
Make irc:// URLs use an account on the right server, not just the first IRC
Will Thompson <resiak@pidgin.im>
parents:
23563
diff
changeset
|
237 | |
|
9ccc8c1ddc6b
Make irc:// URLs use an account on the right server, not just the first IRC
Will Thompson <resiak@pidgin.im>
parents:
23563
diff
changeset
|
238 | account = findaccount(protocol, matcher=correct_server) |
|
17323
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
239 | |
|
37984
6a5ca046a90d
Make all Python files PEP8 compatible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37983
diff
changeset
|
240 | if target != "": |
|
37985
c3bab3be9695
Remove some "clever" Python code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37984
diff
changeset
|
241 | if "isnick" in modifiers: |
|
37984
6a5ca046a90d
Make all Python files PEP8 compatible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37983
diff
changeset
|
242 | goim(account, unquote_plus(target.split(",")[0]), |
|
6a5ca046a90d
Make all Python files PEP8 compatible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37983
diff
changeset
|
243 | params.get("msg")) |
|
23564
9ccc8c1ddc6b
Make irc:// URLs use an account on the right server, not just the first IRC
Will Thompson <resiak@pidgin.im>
parents:
23563
diff
changeset
|
244 | else: |
|
37444
8c851c1bc85b
Ensure backwards compatibility with Python 2
Daniël van Eeden <hg@myname.nl>
parents:
37443
diff
changeset
|
245 | channel = unquote_plus(target.split(",")[0]) |
|
17323
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
246 | if channel[0] != "#": |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
247 | channel = "#" + channel |
|
37984
6a5ca046a90d
Make all Python files PEP8 compatible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37983
diff
changeset
|
248 | gochat(account, |
|
6a5ca046a90d
Make all Python files PEP8 compatible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37983
diff
changeset
|
249 | {"server": server, |
|
6a5ca046a90d
Make all Python files PEP8 compatible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37983
diff
changeset
|
250 | "channel": channel, |
|
6a5ca046a90d
Make all Python files PEP8 compatible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37983
diff
changeset
|
251 | "password": params.get("key", "")}, |
|
6a5ca046a90d
Make all Python files PEP8 compatible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37983
diff
changeset
|
252 | params.get("msg")) |
|
6a5ca046a90d
Make all Python files PEP8 compatible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37983
diff
changeset
|
253 | |
|
17323
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
254 | |
| 14582 | 255 | def msnim(uri): |
| 256 | protocol = "prpl-msn" | |
| 257 | match = re.match(r"^msnim:([^?]*)(\?(.*))", uri) | |
| 258 | if not match: | |
|
37984
6a5ca046a90d
Make all Python files PEP8 compatible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37983
diff
changeset
|
259 | print("Invalid msnim URI: %s" % (uri, )) |
| 14582 | 260 | return |
| 261 | ||
|
37444
8c851c1bc85b
Ensure backwards compatibility with Python 2
Daniël van Eeden <hg@myname.nl>
parents:
37443
diff
changeset
|
262 | command = unquote_plus(match.group(1)) |
| 14582 | 263 | paramstring = match.group(3) |
| 264 | params = {} | |
| 265 | if paramstring: | |
| 266 | for param in paramstring.split("&"): | |
| 267 | key, value = extendlist(param.split("=", 1), 2, "") | |
|
37444
8c851c1bc85b
Ensure backwards compatibility with Python 2
Daniël van Eeden <hg@myname.nl>
parents:
37443
diff
changeset
|
268 | params[key] = unquote_plus(value) |
| 14582 | 269 | screenname = params.get("contact", "") |
| 270 | ||
| 271 | account = findaccount(protocol) | |
| 272 | ||
|
14597
f6b179d6babb
[gaim-migrate @ 17256]
Richard Laager <rlaager@pidgin.im>
parents:
14582
diff
changeset
|
273 | if command.lower() == "chat": |
| 14582 | 274 | goim(account, screenname) |
|
14597
f6b179d6babb
[gaim-migrate @ 17256]
Richard Laager <rlaager@pidgin.im>
parents:
14582
diff
changeset
|
275 | elif command.lower() == "add": |
| 14582 | 276 | addbuddy(account, screenname) |
| 277 | ||
|
37984
6a5ca046a90d
Make all Python files PEP8 compatible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37983
diff
changeset
|
278 | |
|
17323
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
279 | def sip(uri): |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
280 | protocol = "prpl-simple" |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
281 | match = re.match(r"^sip:(.*)", uri) |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
282 | if not match: |
|
37984
6a5ca046a90d
Make all Python files PEP8 compatible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37983
diff
changeset
|
283 | print("Invalid sip URI: %s" % (uri, )) |
|
17323
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
284 | return |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
285 | |
|
37444
8c851c1bc85b
Ensure backwards compatibility with Python 2
Daniël van Eeden <hg@myname.nl>
parents:
37443
diff
changeset
|
286 | screenname = unquote_plus(match.group(1)) |
|
17323
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
287 | account = findaccount(protocol) |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
288 | goim(account, screenname) |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
289 | |
|
37984
6a5ca046a90d
Make all Python files PEP8 compatible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37983
diff
changeset
|
290 | |
|
17323
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
291 | def xmpp(uri): |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
292 | protocol = "prpl-jabber" |
|
37984
6a5ca046a90d
Make all Python files PEP8 compatible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37983
diff
changeset
|
293 | match = re.match( |
|
6a5ca046a90d
Make all Python files PEP8 compatible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37983
diff
changeset
|
294 | r"^xmpp:(//([^/?#]*)/?)?([^?#]*)(\?([^;#]*)(;([^#]*))?)?(#(.*))?", |
|
6a5ca046a90d
Make all Python files PEP8 compatible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37983
diff
changeset
|
295 | uri) |
|
17323
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
296 | if not match: |
|
37984
6a5ca046a90d
Make all Python files PEP8 compatible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37983
diff
changeset
|
297 | print("Invalid xmpp URI: %s" % (uri, )) |
|
17323
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
298 | return |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
299 | |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
300 | tmp = match.group(2) |
|
37984
6a5ca046a90d
Make all Python files PEP8 compatible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37983
diff
changeset
|
301 | if tmp: |
|
37444
8c851c1bc85b
Ensure backwards compatibility with Python 2
Daniël van Eeden <hg@myname.nl>
parents:
37443
diff
changeset
|
302 | accountname = unquote_plus(tmp) |
|
17323
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
303 | else: |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
304 | accountname = "" |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
305 | |
|
37444
8c851c1bc85b
Ensure backwards compatibility with Python 2
Daniël van Eeden <hg@myname.nl>
parents:
37443
diff
changeset
|
306 | screenname = unquote_plus(match.group(3)) |
|
17323
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
307 | |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
308 | tmp = match.group(5) |
|
37984
6a5ca046a90d
Make all Python files PEP8 compatible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37983
diff
changeset
|
309 | if tmp: |
|
37444
8c851c1bc85b
Ensure backwards compatibility with Python 2
Daniël van Eeden <hg@myname.nl>
parents:
37443
diff
changeset
|
310 | command = unquote_plus(tmp) |
|
17323
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
311 | else: |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
312 | command = "" |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
313 | |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
314 | paramstring = match.group(7) |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
315 | params = {} |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
316 | if paramstring: |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
317 | for param in paramstring.split(";"): |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
318 | key, value = extendlist(param.split("=", 1), 2, "") |
|
37444
8c851c1bc85b
Ensure backwards compatibility with Python 2
Daniël van Eeden <hg@myname.nl>
parents:
37443
diff
changeset
|
319 | params[key] = unquote_plus(value) |
|
17323
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
320 | |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
321 | account = findaccount(protocol, accountname) |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
322 | |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
323 | if command.lower() == "message": |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
324 | goim(account, screenname, params.get("body")) |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
325 | elif command.lower() == "join": |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
326 | room, server = screenname.split("@") |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
327 | gochat(account, {"room": room, "server": server}) |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
328 | elif command.lower() == "roster": |
|
37984
6a5ca046a90d
Make all Python files PEP8 compatible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37983
diff
changeset
|
329 | addbuddy(account, screenname, params.get("group", ""), |
|
6a5ca046a90d
Make all Python files PEP8 compatible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37983
diff
changeset
|
330 | params.get("name", "")) |
|
17323
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
331 | else: |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
332 | goim(account, screenname) |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
333 | |
|
37984
6a5ca046a90d
Make all Python files PEP8 compatible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37983
diff
changeset
|
334 | |
|
25327
f24162b33a66
Extend purple-url-handler to handle "gtalk" URIs. Fixes #7889
Paul Aurich <darkrain42@pidgin.im>
parents:
23565
diff
changeset
|
335 | def gtalk(uri): |
|
f24162b33a66
Extend purple-url-handler to handle "gtalk" URIs. Fixes #7889
Paul Aurich <darkrain42@pidgin.im>
parents:
23565
diff
changeset
|
336 | protocol = "prpl-jabber" |
|
f24162b33a66
Extend purple-url-handler to handle "gtalk" URIs. Fixes #7889
Paul Aurich <darkrain42@pidgin.im>
parents:
23565
diff
changeset
|
337 | match = re.match(r"^gtalk:([^?]*)(\?(.*))", uri) |
|
f24162b33a66
Extend purple-url-handler to handle "gtalk" URIs. Fixes #7889
Paul Aurich <darkrain42@pidgin.im>
parents:
23565
diff
changeset
|
338 | if not match: |
|
37984
6a5ca046a90d
Make all Python files PEP8 compatible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37983
diff
changeset
|
339 | print("Invalid gtalk URI: %s" % (uri, )) |
|
25327
f24162b33a66
Extend purple-url-handler to handle "gtalk" URIs. Fixes #7889
Paul Aurich <darkrain42@pidgin.im>
parents:
23565
diff
changeset
|
340 | return |
|
f24162b33a66
Extend purple-url-handler to handle "gtalk" URIs. Fixes #7889
Paul Aurich <darkrain42@pidgin.im>
parents:
23565
diff
changeset
|
341 | |
|
37444
8c851c1bc85b
Ensure backwards compatibility with Python 2
Daniël van Eeden <hg@myname.nl>
parents:
37443
diff
changeset
|
342 | command = unquote_plus(match.group(1)) |
|
25327
f24162b33a66
Extend purple-url-handler to handle "gtalk" URIs. Fixes #7889
Paul Aurich <darkrain42@pidgin.im>
parents:
23565
diff
changeset
|
343 | paramstring = match.group(3) |
|
f24162b33a66
Extend purple-url-handler to handle "gtalk" URIs. Fixes #7889
Paul Aurich <darkrain42@pidgin.im>
parents:
23565
diff
changeset
|
344 | params = {} |
|
f24162b33a66
Extend purple-url-handler to handle "gtalk" URIs. Fixes #7889
Paul Aurich <darkrain42@pidgin.im>
parents:
23565
diff
changeset
|
345 | if paramstring: |
|
f24162b33a66
Extend purple-url-handler to handle "gtalk" URIs. Fixes #7889
Paul Aurich <darkrain42@pidgin.im>
parents:
23565
diff
changeset
|
346 | for param in paramstring.split("&"): |
|
f24162b33a66
Extend purple-url-handler to handle "gtalk" URIs. Fixes #7889
Paul Aurich <darkrain42@pidgin.im>
parents:
23565
diff
changeset
|
347 | key, value = extendlist(param.split("=", 1), 2, "") |
|
37444
8c851c1bc85b
Ensure backwards compatibility with Python 2
Daniël van Eeden <hg@myname.nl>
parents:
37443
diff
changeset
|
348 | params[key] = unquote_plus(value) |
|
25327
f24162b33a66
Extend purple-url-handler to handle "gtalk" URIs. Fixes #7889
Paul Aurich <darkrain42@pidgin.im>
parents:
23565
diff
changeset
|
349 | accountname = params.get("from_jid", "") |
|
f24162b33a66
Extend purple-url-handler to handle "gtalk" URIs. Fixes #7889
Paul Aurich <darkrain42@pidgin.im>
parents:
23565
diff
changeset
|
350 | jid = params.get("jid", "") |
|
f24162b33a66
Extend purple-url-handler to handle "gtalk" URIs. Fixes #7889
Paul Aurich <darkrain42@pidgin.im>
parents:
23565
diff
changeset
|
351 | |
|
f24162b33a66
Extend purple-url-handler to handle "gtalk" URIs. Fixes #7889
Paul Aurich <darkrain42@pidgin.im>
parents:
23565
diff
changeset
|
352 | account = findaccount(protocol, accountname) |
|
f24162b33a66
Extend purple-url-handler to handle "gtalk" URIs. Fixes #7889
Paul Aurich <darkrain42@pidgin.im>
parents:
23565
diff
changeset
|
353 | |
|
f24162b33a66
Extend purple-url-handler to handle "gtalk" URIs. Fixes #7889
Paul Aurich <darkrain42@pidgin.im>
parents:
23565
diff
changeset
|
354 | if command.lower() == "chat": |
|
f24162b33a66
Extend purple-url-handler to handle "gtalk" URIs. Fixes #7889
Paul Aurich <darkrain42@pidgin.im>
parents:
23565
diff
changeset
|
355 | goim(account, jid) |
|
f24162b33a66
Extend purple-url-handler to handle "gtalk" URIs. Fixes #7889
Paul Aurich <darkrain42@pidgin.im>
parents:
23565
diff
changeset
|
356 | elif command.lower() == "call": |
|
f24162b33a66
Extend purple-url-handler to handle "gtalk" URIs. Fixes #7889
Paul Aurich <darkrain42@pidgin.im>
parents:
23565
diff
changeset
|
357 | # XXX V&V prompt to establish call |
|
f24162b33a66
Extend purple-url-handler to handle "gtalk" URIs. Fixes #7889
Paul Aurich <darkrain42@pidgin.im>
parents:
23565
diff
changeset
|
358 | goim(account, jid) |
|
f24162b33a66
Extend purple-url-handler to handle "gtalk" URIs. Fixes #7889
Paul Aurich <darkrain42@pidgin.im>
parents:
23565
diff
changeset
|
359 | |
|
37984
6a5ca046a90d
Make all Python files PEP8 compatible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37983
diff
changeset
|
360 | |
| 14582 | 361 | def ymsgr(uri): |
| 362 | protocol = "prpl-yahoo" | |
| 363 | match = re.match(r"^ymsgr:([^?]*)(\?([^&]*)(&(.*))?)", uri) | |
| 364 | if not match: | |
|
37984
6a5ca046a90d
Make all Python files PEP8 compatible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37983
diff
changeset
|
365 | print("Invalid ymsgr URI: %s" % (uri, )) |
| 14582 | 366 | return |
| 367 | ||
|
37444
8c851c1bc85b
Ensure backwards compatibility with Python 2
Daniël van Eeden <hg@myname.nl>
parents:
37443
diff
changeset
|
368 | command = unquote_plus(match.group(1)) |
|
8c851c1bc85b
Ensure backwards compatibility with Python 2
Daniël van Eeden <hg@myname.nl>
parents:
37443
diff
changeset
|
369 | screenname = unquote_plus(match.group(3)) |
| 14582 | 370 | paramstring = match.group(5) |
| 371 | params = {} | |
| 372 | if paramstring: | |
| 373 | for param in paramstring.split("&"): | |
| 374 | key, value = extendlist(param.split("=", 1), 2, "") | |
|
37444
8c851c1bc85b
Ensure backwards compatibility with Python 2
Daniël van Eeden <hg@myname.nl>
parents:
37443
diff
changeset
|
375 | params[key] = unquote_plus(value) |
| 14582 | 376 | |
| 377 | account = findaccount(protocol) | |
| 378 | ||
|
14601
8aa717885b14
[gaim-migrate @ 17260]
Richard Laager <rlaager@pidgin.im>
parents:
14597
diff
changeset
|
379 | if command.lower() == "sendim": |
| 14582 | 380 | goim(account, screenname, params.get("m")) |
|
14597
f6b179d6babb
[gaim-migrate @ 17256]
Richard Laager <rlaager@pidgin.im>
parents:
14582
diff
changeset
|
381 | elif command.lower() == "chat": |
| 14582 | 382 | gochat(account, {"room": screenname}) |
|
14597
f6b179d6babb
[gaim-migrate @ 17256]
Richard Laager <rlaager@pidgin.im>
parents:
14582
diff
changeset
|
383 | elif command.lower() == "addfriend": |
| 14582 | 384 | addbuddy(account, screenname) |
| 385 | ||
| 386 | ||
| 387 | def main(argv=sys.argv): | |
|
23237
7ec42e06496f
Import a patch (with changes) from Debian:
Ari Pollak <ari@debian.org>
parents:
22141
diff
changeset
|
388 | if len(argv) != 2 or argv[1] == "--help" or argv[1] == "-h": |
|
37984
6a5ca046a90d
Make all Python files PEP8 compatible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37983
diff
changeset
|
389 | print("Usage: %s URI" % (argv[0], )) |
|
6a5ca046a90d
Make all Python files PEP8 compatible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37983
diff
changeset
|
390 | print("Example: %s \"xmpp:romeo@montague.net?message\"" % (argv[0], )) |
|
23237
7ec42e06496f
Import a patch (with changes) from Debian:
Ari Pollak <ari@debian.org>
parents:
22141
diff
changeset
|
391 | |
|
7ec42e06496f
Import a patch (with changes) from Debian:
Ari Pollak <ari@debian.org>
parents:
22141
diff
changeset
|
392 | if len(argv) != 2: |
|
7ec42e06496f
Import a patch (with changes) from Debian:
Ari Pollak <ari@debian.org>
parents:
22141
diff
changeset
|
393 | sys.exit(1) |
|
7ec42e06496f
Import a patch (with changes) from Debian:
Ari Pollak <ari@debian.org>
parents:
22141
diff
changeset
|
394 | else: |
|
7ec42e06496f
Import a patch (with changes) from Debian:
Ari Pollak <ari@debian.org>
parents:
22141
diff
changeset
|
395 | return 0 |
| 14582 | 396 | |
| 397 | uri = argv[1] | |
|
17323
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
398 | type = uri.split(":")[0] |
| 14582 | 399 | |
|
16207
b4b168c28673
Print decent error messages instead of stack traces if there's a problem.
Richard Laager <rlaager@pidgin.im>
parents:
16205
diff
changeset
|
400 | try: |
|
b4b168c28673
Print decent error messages instead of stack traces if there's a problem.
Richard Laager <rlaager@pidgin.im>
parents:
16205
diff
changeset
|
401 | if type == "aim": |
|
b4b168c28673
Print decent error messages instead of stack traces if there's a problem.
Richard Laager <rlaager@pidgin.im>
parents:
16205
diff
changeset
|
402 | aim(uri) |
|
b4b168c28673
Print decent error messages instead of stack traces if there's a problem.
Richard Laager <rlaager@pidgin.im>
parents:
16205
diff
changeset
|
403 | elif type == "gg": |
|
17323
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
404 | gg(uri) |
|
16207
b4b168c28673
Print decent error messages instead of stack traces if there's a problem.
Richard Laager <rlaager@pidgin.im>
parents:
16205
diff
changeset
|
405 | elif type == "icq": |
|
b4b168c28673
Print decent error messages instead of stack traces if there's a problem.
Richard Laager <rlaager@pidgin.im>
parents:
16205
diff
changeset
|
406 | icq(uri) |
|
17323
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
407 | elif type == "irc": |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
408 | irc(uri) |
|
16207
b4b168c28673
Print decent error messages instead of stack traces if there's a problem.
Richard Laager <rlaager@pidgin.im>
parents:
16205
diff
changeset
|
409 | elif type == "msnim": |
|
b4b168c28673
Print decent error messages instead of stack traces if there's a problem.
Richard Laager <rlaager@pidgin.im>
parents:
16205
diff
changeset
|
410 | msnim(uri) |
|
17323
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
411 | elif type == "sip": |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
412 | sip(uri) |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
413 | elif type == "xmpp": |
|
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
414 | xmpp(uri) |
|
25327
f24162b33a66
Extend purple-url-handler to handle "gtalk" URIs. Fixes #7889
Paul Aurich <darkrain42@pidgin.im>
parents:
23565
diff
changeset
|
415 | elif type == "gtalk": |
|
f24162b33a66
Extend purple-url-handler to handle "gtalk" URIs. Fixes #7889
Paul Aurich <darkrain42@pidgin.im>
parents:
23565
diff
changeset
|
416 | gtalk(uri) |
|
16207
b4b168c28673
Print decent error messages instead of stack traces if there's a problem.
Richard Laager <rlaager@pidgin.im>
parents:
16205
diff
changeset
|
417 | elif type == "ymsgr": |
|
b4b168c28673
Print decent error messages instead of stack traces if there's a problem.
Richard Laager <rlaager@pidgin.im>
parents:
16205
diff
changeset
|
418 | ymsgr(uri) |
|
17323
f92574b24329
Restore the protocol specific URL handlers in purple-url-handler for those
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17145
diff
changeset
|
419 | else: |
|
37984
6a5ca046a90d
Make all Python files PEP8 compatible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37983
diff
changeset
|
420 | print("Unknown protocol: %s" % (type, )) |
|
37443
78408ad717bd
Make purlpe-url-handler work with Python 3
Daniël van Eeden <hg@myname.nl>
parents:
31582
diff
changeset
|
421 | except dbus.DBusException as e: |
|
37983
7d134a4a87b2
Ensure all Python scripts are Py3k compatible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37910
diff
changeset
|
422 | print("Error: %s" % (str(e), )) |
|
23562
312323547538
Handle D-Bus errors more helpfully in purple-url-handler.
Will Thompson <resiak@pidgin.im>
parents:
23237
diff
changeset
|
423 | sys.exit(1) |
| 14582 | 424 | |
|
37984
6a5ca046a90d
Make all Python files PEP8 compatible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37983
diff
changeset
|
425 | |
| 14582 | 426 | if __name__ == "__main__": |
| 427 | main() |