summaryrefslogtreecommitdiff
path: root/examples/example-service.py
diff options
context:
space:
mode:
authorSimon McVittie <smcv@collabora.com>2021-07-20 10:13:24 +0100
committerSimon McVittie <smcv@collabora.com>2021-07-20 10:34:20 +0100
commitce5fa75f01a7197908f462a422237af09cb73a73 (patch)
tree725f4360ca7c605119c87ce181743589736ca9a0 /examples/example-service.py
parent2860c6873169ffc0f950b748f1865ad39402840c (diff)
examples: Convert to Python 3
Python 2 reached EOL more than 18 months ago. For the gconf example, which is only still here because it provides an example of implementing a FallbackObject, use a mock implementation if the deprecated gconf module is no longer available. Signed-off-by: Simon McVittie <smcv@collabora.com>
Diffstat (limited to 'examples/example-service.py')
-rwxr-xr-xexamples/example-service.py18
1 files changed, 10 insertions, 8 deletions
diff --git a/examples/example-service.py b/examples/example-service.py
index 12c81d9..e1ed325 100755
--- a/examples/example-service.py
+++ b/examples/example-service.py
@@ -1,10 +1,12 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
+
+from __future__ import print_function
usage = """Usage:
-python example-service.py &
-python example-client.py
-python example-async-client.py
-python example-client.py --exit-service
+python3 example-service.py &
+python3 example-client.py
+python3 example-async-client.py
+python3 example-client.py --exit-service
"""
# Copyright (C) 2004-2006 Red Hat Inc. <http://www.redhat.com/>
@@ -46,7 +48,7 @@ class SomeObject(dbus.service.Object):
@dbus.service.method("com.example.SampleInterface",
in_signature='s', out_signature='as')
def HelloWorld(self, hello_message):
- print (str(hello_message))
+ print("service:", str(hello_message))
return ["Hello", " from example-service.py", "with unique name",
session_bus.get_unique_name()]
@@ -80,6 +82,6 @@ if __name__ == '__main__':
object = SomeObject(session_bus, '/SomeObject')
mainloop = GLib.MainLoop()
- print "Running example service."
- print usage
+ print("Running example service.")
+ print(usage)
mainloop.run()