summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rwxr-xr-xexamples/client/python/contact-list.py2
-rwxr-xr-xexamples/client/python/ensure-channel.py6
-rwxr-xr-xexamples/client/python/file-transfer.py17
-rw-r--r--examples/client/python/ft-handler.py11
-rwxr-xr-xexamples/client/python/stream-tube-accepter.py19
-rwxr-xr-xexamples/client/python/stream-tube-offerer.py33
-rwxr-xr-xexamples/client/python/text-handler.py7
7 files changed, 50 insertions, 45 deletions
diff --git a/examples/client/python/contact-list.py b/examples/client/python/contact-list.py
index df854f19b..19d0dc4a5 100755
--- a/examples/client/python/contact-list.py
+++ b/examples/client/python/contact-list.py
@@ -21,7 +21,7 @@ def manager_prepared_cb(manager, result, loop):
connection.get_contact_list_state() == Tp.ContactListState.SUCCESS:
contacts = connection.dup_contact_list()
for contact in contacts:
- print "%s (%s)" % (contact.get_identifier(), contact.get_contact_groups())
+ print("%s (%s)" % (contact.get_identifier(), contact.get_contact_groups()))
loop.quit()
if __name__ == '__main__':
diff --git a/examples/client/python/ensure-channel.py b/examples/client/python/ensure-channel.py
index 9e46239ff..2f8070a9e 100755
--- a/examples/client/python/ensure-channel.py
+++ b/examples/client/python/ensure-channel.py
@@ -10,9 +10,9 @@ gi.require_version('TelepathyGLib', '0.12')
from gi.repository import TelepathyGLib
def usage():
- print "%s ACCOUNT [text|audio|video] CONTACT" % sys.argv[0]
- print "ACCOUNT is a Telepathy account name, use 'mc-tool list' to list all your accounts"
- print "CONTACT is a contact id such as badger@gmail.com"
+ print("%s ACCOUNT [text|audio|video] CONTACT" % sys.argv[0])
+ print("ACCOUNT is a Telepathy account name, use 'mc-tool list' to list all your accounts")
+ print("CONTACT is a contact id such as badger@gmail.com")
sys.exit(1)
diff --git a/examples/client/python/file-transfer.py b/examples/client/python/file-transfer.py
index f56fa1831..7dab55304 100755
--- a/examples/client/python/file-transfer.py
+++ b/examples/client/python/file-transfer.py
@@ -1,4 +1,5 @@
#!/usr/bin/env python
+from __future__ import print_function
import sys
import os
import mimetypes
@@ -13,21 +14,21 @@ gi.require_version('TelepathyGLib', '0.12')
from gi.repository import TelepathyGLib
def usage():
- print "%s ACCOUNT CONTACT FILE" % sys.argv[0]
- print "ACCOUNT is a Telepathy account name, use 'mc-tool list' to list all your accounts"
- print "CONTACT is a contact id such as badger@nyan.cat"
- print "FILE is a path to the local file you want sent"
+ print("%s ACCOUNT CONTACT FILE" % sys.argv[0])
+ print("ACCOUNT is a Telepathy account name, use 'mc-tool list' to list all your accounts")
+ print("CONTACT is a contact id such as badger@nyan.cat")
+ print("FILE is a path to the local file you want sent")
sys.exit(1)
def provide_file_cb(channel, result, data):
if not channel.provide_file_finish(result):
- print 'failed to provide'
+ print('failed to provide')
def state_changed_cb(channel, pspec, data):
main_loop, file_path = data
state, _ = channel.get_state()
- print 'state is now', state
+ print('state is now', state)
if state == TelepathyGLib.FileTransferState.ACCEPTED:
file = Gio.File.new_for_path(file_path)
@@ -38,8 +39,8 @@ def create_channel_cb(request, result, data):
(chan, context) = request.create_and_handle_channel_finish(result)
chan.connect('notify::state', state_changed_cb, data)
- except GObject.GError, e:
- print "Failed to create channel: %s" % e
+ except GObject.GError as e:
+ print("Failed to create channel: %s" % e)
sys.exit(1)
if __name__ == '__main__':
diff --git a/examples/client/python/ft-handler.py b/examples/client/python/ft-handler.py
index fe6f24f79..04604b3e7 100644
--- a/examples/client/python/ft-handler.py
+++ b/examples/client/python/ft-handler.py
@@ -1,4 +1,5 @@
#!/usr/bin/env python
+from __future__ import print_function
import sys
import gi
@@ -11,18 +12,18 @@ gi.require_version('TelepathyGLib', '0.12')
from gi.repository import TelepathyGLib
def usage():
- print "%s FILE" % sys.argv[0]
- print "FILE is a path to the location you want the file saved to"
+ print("%s FILE" % sys.argv[0])
+ print("FILE is a path to the location you want the file saved to")
sys.exit(1)
def state_changed_cb(channel, pspec, data):
state, _ = channel.get_state()
- print 'State is now:', state
+ print('State is now:', state)
def accept_cb(channel, result, data):
if not channel.accept_file_finish(result):
- print 'Failed to accept file'
+ print('Failed to accept file')
def handle_channels_cb(handler, account, connection, channels, requests,
user_action_time, context, filename):
@@ -33,7 +34,7 @@ def handle_channels_cb(handler, account, connection, channels, requests,
chan.connect('notify::state', state_changed_cb, None)
- print 'Handling FileTransfer channel:', chan.get_identifier()
+ print('Handling FileTransfer channel:', chan.get_identifier())
file = Gio.File.new_for_path(filename)
chan.accept_file_async(file, 0, accept_cb, None)
diff --git a/examples/client/python/stream-tube-accepter.py b/examples/client/python/stream-tube-accepter.py
index b5ed6773d..b956b480a 100755
--- a/examples/client/python/stream-tube-accepter.py
+++ b/examples/client/python/stream-tube-accepter.py
@@ -1,5 +1,6 @@
#!/usr/bin/env python
+from __future__ import print_function
import os
import gi
@@ -8,20 +9,20 @@ gi.require_version('TelepathyGLib', '0.12')
from gi.repository import TelepathyGLib as Tp
def tube_conn_closed(tube, error):
- print "Tube connection has been closed", error.message
+ print("Tube connection has been closed", error.message)
def tube_accept_cb(tube, result, loop):
try:
tube_conn = tube.accept_finish(result)
- except GObject.GError, e:
- print "Failed to accept tube: %s" % e
+ except GObject.GError as e:
+ print("Failed to accept tube: %s" % e)
sys.exit(1)
tube_conn.connect('closed', tube_conn_closed)
contact = tube_conn.get_contact();
- print "Got IOStream to", contact.get_identifier()
+ print("Got IOStream to", contact.get_identifier())
conn = tube_conn.get_socket_connection();
@@ -30,14 +31,14 @@ def tube_accept_cb(tube, result, loop):
in_stream = Gio.DataInputStream (base_stream=conn.get_input_stream())
out_stream = conn.get_output_stream()
- print "Sending: Ping"
+ print("Sending: Ping")
out_stream.write("Ping\n", None)
buf, len = in_stream.read_line_utf8(None)
- print "Received:", buf
+ print("Received:", buf)
def tube_invalidated_cb(tube, domain, code, message, loop):
- print "tube has been invalidated:", message
+ print("tube has been invalidated:", message)
loop.quit()
def handle_channels_cb(handler, account, connection, channels, requests,
@@ -46,7 +47,7 @@ def handle_channels_cb(handler, account, connection, channels, requests,
if not isinstance(channel, Tp.StreamTubeChannel):
continue
- print "Accepting tube"
+ print("Accepting tube")
channel.connect('invalidated', tube_invalidated_cb, loop)
@@ -71,5 +72,5 @@ if __name__ == '__main__':
handler.register()
- print "Waiting for tube offer"
+ print("Waiting for tube offer")
loop.run()
diff --git a/examples/client/python/stream-tube-offerer.py b/examples/client/python/stream-tube-offerer.py
index 69b533242..b88f18042 100755
--- a/examples/client/python/stream-tube-offerer.py
+++ b/examples/client/python/stream-tube-offerer.py
@@ -1,5 +1,6 @@
#!/usr/bin/env python
+from __future__ import print_function
import sys
import os
@@ -9,31 +10,31 @@ gi.require_version('TelepathyGLib', '0.12')
from gi.repository import TelepathyGLib as Tp
def usage():
- print "%s ACCOUNT CONTACT" % sys.argv[0]
- print "ACCOUNT is a Telepathy account name, use 'mc-tool list' to list all your accounts"
- print "CONTACT is a contact id such as badger@nyan.cat"
+ print("%s ACCOUNT CONTACT" % sys.argv[0])
+ print("ACCOUNT is a Telepathy account name, use 'mc-tool list' to list all your accounts")
+ print("CONTACT is a contact id such as badger@nyan.cat")
sys.exit(1)
def offer_channel_cb(tube, result, loop):
try:
tube.offer_finish(result)
- print "tube offered"
+ print("tube offered")
- except GObject.GError, e:
- print "Failed to offer tube: %s" % e
+ except GObject.GError as e:
+ print("Failed to offer tube: %s" % e)
sys.exit(1)
def tube_conn_closed(tube, error):
- print "Tube connection has been closed", error.message
+ print("Tube connection has been closed", error.message)
def channel_close_cb(tube, result, loop):
try:
tube.close_finish(result)
- print "tube channel closed"
+ print("tube channel closed")
- except GObject.GError, e:
- print "Failed to close tube channel: %s" % e
+ except GObject.GError as e:
+ print("Failed to close tube channel: %s" % e)
sys.exit(1)
def tube_incoming_cb(tube, tube_conn, loop):
@@ -41,7 +42,7 @@ def tube_incoming_cb(tube, tube_conn, loop):
contact = tube_conn.get_contact();
- print "Got IOStream from", contact.get_identifier()
+ print("Got IOStream from", contact.get_identifier())
conn = tube_conn.get_socket_connection();
@@ -51,15 +52,15 @@ def tube_incoming_cb(tube, tube_conn, loop):
out_stream = conn.get_output_stream()
buf, len = in_stream.read_line_utf8(None)
- print "Received:", buf
+ print("Received:", buf)
- print "Sending: Pong"
+ print("Sending: Pong")
out_stream.write("Pong\n", None)
tube.close_async(channel_close_cb, contact)
def tube_invalidated_cb(tube, domain, code, message, loop):
- print "tube has been invalidated:", message
+ print("tube has been invalidated:", message)
loop.quit()
def create_channel_cb(request, result, loop):
@@ -71,8 +72,8 @@ def create_channel_cb(request, result, loop):
chan.offer_async({}, offer_channel_cb, loop)
- except GObject.GError, e:
- print "Failed to create channel: %s" % e
+ except GObject.GError as e:
+ print("Failed to create channel: %s" % e)
sys.exit(1)
if __name__ == '__main__':
diff --git a/examples/client/python/text-handler.py b/examples/client/python/text-handler.py
index 7a1d6e87b..a0b33a440 100755
--- a/examples/client/python/text-handler.py
+++ b/examples/client/python/text-handler.py
@@ -1,5 +1,6 @@
#!/usr/bin/env python
+from __future__ import print_function
import gi
from gi.repository import GObject
@@ -12,9 +13,9 @@ def echo_message(channel, msg, pending):
text, flags = msg.to_text()
if pending:
- print "pending: %s" % (text)
+ print("pending: %s" % (text))
else:
- print "received: %s" % (text)
+ print("received: %s" % (text))
reply = TelepathyGLib.ClientMessage.new_text(
TelepathyGLib.ChannelTextMessageType.NORMAL, text.upper())
@@ -42,7 +43,7 @@ def handle_channels_cb(handler, account, connection, channels, requests,
if not isinstance(channel, TelepathyGLib.TextChannel):
continue
- print "Handling text channel with", channel.get_identifier()
+ print("Handling text channel with", channel.get_identifier())
channel.connect('message-received', message_received_cb)