From b439f7fdccf3157241ebc39c7ce000fae299219b Mon Sep 17 00:00:00 2001
From: Rouven Czerwinski <rouven@czerwinskis.de>
Date: Sun, 4 Dec 2022 16:32:27 +0100
Subject: [PATCH] client: convert to python3

Conversion done by 2to3 and manual fixup afterwards.

Signed-off-by: Rouven Czerwinski <rouven@czerwinskis.de>
---
 python/client.py | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/python/client.py b/python/client.py
index 9dbbd91..063050f 100644
--- a/python/client.py
+++ b/python/client.py
@@ -9,18 +9,18 @@ SPLIT_I = 0
 
 SPLIT = os.environ.get("SPLIT")
 if SPLIT:
-  SPLIT = map(int, SPLIT.split('/'))
+  SPLIT = list(map(int, SPLIT.split('/')))
   SPLIT_N = SPLIT[1]
   SPLIT_I = SPLIT[0]-1
 
 NUM_SEG_X = 96
 NUM_SEG_Y = 10
 PWIDTH = 5
-WIDTH = PWIDTH*NUM_SEG_X/SPLIT_N
-WOFFSET = WIDTH*SPLIT_I
+WIDTH = int(PWIDTH*NUM_SEG_X/SPLIT_N)
+WOFFSET = (WIDTH*SPLIT_I)
 PHEIGHT = 7
 PPAD = 5
-HEIGHT = PHEIGHT*NUM_SEG_Y
+HEIGHT = int(PHEIGHT*NUM_SEG_Y)
 
 import sys
 
@@ -58,7 +58,7 @@ def set_pixels(pixels):
 def blit(x, y, w, h, pixels, rec=True):
   x += WOFFSET
   assert w*h == len(pixels)
-  msg = struct.pack('<Biiii', 1, x, y, w, h)+b''.join(map(chr, pixels))
+  msg = struct.pack('<Biiii', 1, x, y, w, h)+bytes(pixels)
   socket.send_multipart([msg, b''])
   if rec:
     rx = socket.recv()
@@ -100,11 +100,11 @@ def screenbuf_render():
 def char_to_pixel_segment(c):
     pixels = [0] * PWIDTH * PHEIGHT
 
-    if(c not in bitmapfont.FONT.keys()):
-        c = u"☐";
+    if(c not in list(bitmapfont.FONT.keys())):
+        c = "☐";
 
-    for x in xrange(0, PWIDTH):
-        for y in xrange(0, PHEIGHT):
+    for x in range(0, PWIDTH):
+        for y in range(0, PHEIGHT):
             pix = (bitmapfont.FONT[c][x] & (1<<y)) >> y
             pixels[y * PWIDTH + x] = pix * 255
     return pixels
-- 
GitLab