[gtk-vnc] gvncviewer.py: fix python3 errors
- From: Daniel P. Berrange <dberrange src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk-vnc] gvncviewer.py: fix python3 errors
- Date: Tue, 8 Dec 2020 14:30:14 +0000 (UTC)
commit 33292f717f1b119c9a0f8d88f947623caf030549
Author: Dr. Matthias St. Pierre <matthias st pierre ncp-e com>
Date: Thu Oct 22 16:49:11 2020 +0200
gvncviewer.py: fix python3 errors
The only change necessary was to convert the print statements
to functions and add a __future__ for python2 compatibility.
examples/gvncviewer.py | 28 +++++++++++++++-------------
1 file changed, 15 insertions(+), 13 deletions(-)
---
diff --git a/examples/gvncviewer.py b/examples/gvncviewer.py
index 091c1f1..bd3aeb2 100755
--- a/examples/gvncviewer.py
+++ b/examples/gvncviewer.py
@@ -18,6 +18,8 @@
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+from __future__ import print_function
+
import gi
gi.require_version('Gtk', '3.0')
gi.require_version('GtkVnc', '2.0')
@@ -27,7 +29,7 @@ from gi.repository import GtkVnc
import sys
if len(sys.argv) != 2 and len(sys.argv) != 3:
- print "syntax: gvncviewer.py host:display [password]"
+ print("syntax: gvncviewer.py host:display [password]")
sys.exit(1)
def set_title(vnc, window, grabbed):
@@ -51,7 +53,7 @@ def vnc_screenshot(src, ev, vnc):
if ev.keyval == Gdk.keyval_from_name("F11"):
pix = vnc.get_pixbuf()
pix.save("gvncviewer.png", "png", { "tEXt::Generator App": "gvncviewer.py" })
- print "Screenshot saved to gvncviewer.png"
+ print("Screenshot saved to gvncviewer.png")
return False
@@ -62,38 +64,38 @@ def vnc_ungrab(src, window):
set_title(src, window, False)
def vnc_connected(src):
- print "Connected to server"
+ print("Connected to server")
def vnc_initialized(src, window):
- print "Connection initialized"
+ print("Connection initialized")
set_title(src, window, False)
window.show_all()
def vnc_disconnected(src):
- print "Disconnected from server"
+ print("Disconnected from server")
Gtk.main_quit()
def send_caf1(src, vnc):
- print "Send Ctrl+Alt+F1"
+ print("Send Ctrl+Alt+F1")
vnc.send_keys(["Control_L", "Alt_L", "F1"])
def send_caf7(src, vnc):
- print "Send Ctrl+Alt+F7"
+ print("Send Ctrl+Alt+F7")
vnc.send_keys(["Control_L", "Alt_L", "F7"])
def send_cad(src, vnc):
- print "Send Ctrl+Alt+Del"
+ print("Send Ctrl+Alt+Del")
vnc.send_keys(["Control_L", "Alt_L", "Del"])
def send_cab(src, vnc):
- print "Send Ctrl+Alt+BackSpace"
+ print("Send Ctrl+Alt+BackSpace")
vnc.send_keys(["Control_L", "Alt_L", "BackSpace"])
def vnc_auth_cred(src, credList):
prompt = 0
data = []
- print type(credList)
+ print(type(credList))
for i in range(credList.n_values):
data.append(None)
if credList.get_nth(i) in (GtkVnc.DisplayCredential.USERNAME, GtkVnc.DisplayCredential.PASSWORD):
@@ -145,10 +147,10 @@ def vnc_auth_cred(src, credList):
for i in range(credList.n_values):
if i < len(data) and data[i] != None:
if src.set_credential(credList.get_nth(i), data[i]):
- print "Cannot set credential type %d" % (credList.get_nth(i))
+ print("Cannot set credential type %d" % (credList.get_nth(i)))
src.close()
else:
- print "Unsupported credential type %d" % (credList.get_nth(i))
+ print("Unsupported credential type %d" % (credList.get_nth(i)))
src.close()
window = Gtk.Window()
@@ -203,7 +205,7 @@ if disp != -1:
else:
host = sys.argv[1]
port = "5900"
-print "Connecting to %s %s" % (host, port)
+print("Connecting to %s %s" % (host, port))
vnc.open_host(host, port)
vnc.connect("vnc-pointer-grab", vnc_grab, window)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]