File 0001-Fix-print-and-exception-syntax-for-Python-3-compat.patch of Package horus
From b890b29c5f6e045f7d175a70031476493e20890a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Stefan=20Br=C3=BCns?= <stefan.bruens@rwth-aachen.de>
Date: Sun, 20 Feb 2022 04:41:48 +0100
Subject: [PATCH 1/4] Fix print and exception syntax for Python 3 compat
---
src/horus/engine/driver/uvc/mac/cf_string.py | 2 +-
src/horus/engine/driver/uvc/mac/makefile | 2 +-
src/horus/engine/driver/uvc/mac/raw.py | 30 +++++++++---------
src/horus/engine/scan/ciclop_scan.py | 32 ++++++++++----------
src/horus/gui/util/opengl_helpers.py | 2 +-
5 files changed, 34 insertions(+), 34 deletions(-)
diff --git a/src/horus/engine/driver/uvc/mac/cf_string.py b/src/horus/engine/driver/uvc/mac/cf_string.py
index a4c52dc..329dbbd 100755
--- a/src/horus/engine/driver/uvc/mac/cf_string.py
+++ b/src/horus/engine/driver/uvc/mac/cf_string.py
@@ -71,4 +71,4 @@ def release(cfstring):
if __name__ == '__main__':
cf_pointer = CFSTR("THIS is a Test")
- print cfstring_to_string(cf_pointer)
+ print(cfstring_to_string(cf_pointer)
diff --git a/src/horus/engine/driver/uvc/mac/makefile b/src/horus/engine/driver/uvc/mac/makefile
index f184174..86eda94 100755
--- a/src/horus/engine/driver/uvc/mac/makefile
+++ b/src/horus/engine/driver/uvc/mac/makefile
@@ -20,4 +20,4 @@ uvcc.so: $(OBJ)
.PHONY: clean
clean:
- rm *.so
\ No newline at end of file
+ rm *.so
diff --git a/src/horus/engine/driver/uvc/mac/raw.py b/src/horus/engine/driver/uvc/mac/raw.py
index a02b11b..bf1cfbe 100755
--- a/src/horus/engine/driver/uvc/mac/raw.py
+++ b/src/horus/engine/driver/uvc/mac/raw.py
@@ -249,32 +249,32 @@ def uvccGetVal(control,camera):
if __name__ == '__main__':
uvccInit()
cam_n,cam_list = uvccGetCamList()
- print "detected cameras:",cam_n
+ print("detected cameras:",cam_n)
for i in range(cam_n):
- print "idVendor",hex(cam_list[i].contents.devDesc.idVendor)
- print "idProduct",hex(cam_list[i].contents.devDesc.idProduct)
- print "Location", cam_list[i].contents.idLocation
- print "Product Name:",uvccCamProduct(cam_list[i].contents)
- print "Product Serial:",uvccCamSerialNumber(cam_list[i].contents)
- print "Manufacturer:", uvccCamManufacturer(cam_list[i].contents)
- print "uId:",uvccCamQTUniqueID(cam_list[i].contents)
+ print("idVendor",hex(cam_list[i].contents.devDesc.idVendor))
+ print("idProduct",hex(cam_list[i].contents.devDesc.idProduct))
+ print("Location", cam_list[i].contents.idLocation)
+ print("Product Name:",uvccCamProduct(cam_list[i].contents))
+ print("Product Serial:",uvccCamSerialNumber(cam_list[i].contents))
+ print("Manufacturer:", uvccCamManufacturer(cam_list[i].contents))
+ print("uId:",uvccCamQTUniqueID(cam_list[i].contents))
uid = uvccCamQTUniqueID(cam_list[i].contents)
# manually construct uId: (it looks similar to this: 0x1a11000005ac8510)
# uid = "0x%08x%04x%04x" %(cam_list[i].contents.idLocation,cam_list[i].contents.mId.contents.idVendor,cam_list[i].contents.mId.contents.idProduct)
- # print uvccSendRequest("UVCC_REQ_BRIGHTNESS_ABS",UVC_GET_DEF,cam_list[cam_n-1])
- # print uvccGetVal("UVCC_REQ_BRIGHTNESS_ABS",cam_list[cam_n-1])
- # print set_val(0,"UVCC_REQ_BRIGHTNESS_ABS",cam_list[cam_n-1])
+ # print(uvccSendRequest("UVCC_REQ_BRIGHTNESS_ABS",UVC_GET_DEF,cam_list[cam_n-1]))
+ # print(uvccGetVal("UVCC_REQ_BRIGHTNESS_ABS",cam_list[cam_n-1]))
+ # print(set_val(0,"UVCC_REQ_BRIGHTNESS_ABS",cam_list[cam_n-1]))
__uvcc_dll.uvccReleaseCamList(cam_list,cam_n)
cam = uvccGetCamWithQTUniqueID(uid)
# # cam = uvccGetCamsWithModelID(mid)
if cam:
uvccOpenCam(cam)
- print "Location", cam.contents.idLocation
- print "Product Name:",uvccCamProduct(cam)
- print uvccRequestInfo("UVCC_REQ_EXPOSURE_ABS",cam)
+ print("Location", cam.contents.idLocation)
+ print("Product Name:",uvccCamProduct(cam))
+ print(uvccRequestInfo("UVCC_REQ_EXPOSURE_ABS",cam))
# val = uvccGetVal("UVCC_REQ_BRIGHTNESS_ABS",cam)
- # print uvccSetVal(val-1,"UVCC_REQ_BRIGHTNESS_ABS",cam)
+ # print(uvccSetVal(val-1,"UVCC_REQ_BRIGHTNESS_ABS",cam))
uvccCloseCam(cam)
uvccReleaseCam(cam)
__uvcc_dll.uvccExit()
diff --git a/src/horus/engine/scan/ciclop_scan.py b/src/horus/engine/scan/ciclop_scan.py
index 8717fe2..4e87a22 100644
--- a/src/horus/engine/scan/ciclop_scan.py
+++ b/src/horus/engine/scan/ciclop_scan.py
@@ -96,10 +96,10 @@ class CiclopScan(Scan):
logger.info("Start scan")
if self._debug and system == 'Linux':
string_time = str(datetime.datetime.now())[:-3] + " - "
- print string_time + " elapsed progress: 0 %"
- print string_time + " elapsed time: 0' 0\""
- print string_time + " elapsed angle: 0º"
- print string_time + " capture: 0 ms"
+ print(string_time + " elapsed progress: 0 %")
+ print(string_time + " elapsed time: 0' 0\"")
+ print(string_time + " elapsed angle: 0º")
+ print(string_time + " capture: 0 ms")
# Setup scanner
self.driver.board.lasers_off()
@@ -155,15 +155,15 @@ class CiclopScan(Scan):
if self._debug and system == 'Linux':
# Cursor up + remove lines
- print "\x1b[1A\x1b[1A\x1b[1A\x1b[1A\x1b[2K\x1b[1A"
- print string_time + " elapsed progress: {0} %".format(
- int(self._theta / 3.6))
- print string_time + " elapsed time: {0}".format(
- time.strftime("%M' %S\"", time.gmtime(self._end - self._begin)))
- print string_time + " elapsed angle: {0}º".format(
- float(self._theta))
- print string_time + " capture: {0} ms".format(
- int((self._end - begin) * 1000))
+ print("\x1b[1A\x1b[1A\x1b[1A\x1b[1A\x1b[2K\x1b[1A")
+ print(string_time + " elapsed progress: {0} %".format(
+ int(self._theta / 3.6)))
+ print(string_time + " elapsed time: {0}".format(
+ time.strftime("%M' %S\"", time.gmtime(self._end - self._begin))))
+ print(string_time + " elapsed angle: {0}º".format(
+ float(self._theta)))
+ print(string_time + " capture: {0} ms".format(
+ int((self._end - begin) * 1000)))
# Sleep
time.sleep(self._scan_sleep)
@@ -230,7 +230,7 @@ class CiclopScan(Scan):
# Cursor down
# if self._debug and system == 'Linux':
- # print "\x1b[1C"
+ # print("\x1b[1C")
self.image_capture.stream = True
@@ -288,5 +288,5 @@ class CiclopScan(Scan):
# Print info
"""if self._debug and system == 'Linux':
- print string_time + " process: {0} ms".format(
- int((time.time() - begin) * 1000))"""
+ print(string_time + " process: {0} ms".format(
+ int((time.time() - begin) * 1000)))"""
diff --git a/src/horus/gui/util/opengl_helpers.py b/src/horus/gui/util/opengl_helpers.py
index ca4f812..ff9e534 100755
--- a/src/horus/gui/util/opengl_helpers.py
+++ b/src/horus/gui/util/opengl_helpers.py
@@ -73,7 +73,7 @@ class GLShader(GLReferenceCounter):
raise RuntimeError("Link failure: %s" % (glGetProgramInfoLog(self._program)))
glDeleteShader(vertex_shader)
glDeleteShader(fragment_shader)
- except RuntimeError, e:
+ except RuntimeError as e:
logger.error(str(e))
self._program = None
--
2.35.1