From 64c548a179e5dfcc8cbf722995f8bbea25377c31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavol=20Gajdo=C5=A1?= Date: Fri, 22 Nov 2024 18:49:49 +0100 Subject: [PATCH 1/2] update for py3.12 --- DS9.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/DS9.py b/DS9.py index c8b046b..c1abb6e 100755 --- a/DS9.py +++ b/DS9.py @@ -157,7 +157,7 @@ import RO.OS import subprocess -_DebugSetup = False +_DebugSetup = True def _addToPATH(newPath): """Add newPath to the PATH environment variable. @@ -440,8 +440,8 @@ def xpaset(cmd, data=None, dataFunc=None, template=_DefTemplate, doRaise = False dataFunc(p.stdin) elif data: p.stdin.write(data) - if data[-1] != "\n": - p.stdin.write("\n") + if data[-1] != b"\n": + p.stdin.write(b"\n") p.stdin.close() reply = p.stdout.read() if reply: @@ -511,7 +511,6 @@ def _splitDict(inDict, keys): outDict[key] = inDict.pop(key) return outDict - class DS9Win: """An object that talks to a particular window on ds9 @@ -632,13 +631,16 @@ def showArray(self, arr, **kargs): arryDict["arch"] = "bigendian" else: arryDict["arch"] = "littleendian" - + self.xpaset( cmd = "array [%s]" % (_formatOptions(arryDict),), - dataFunc = arr.tofile, + #dataFunc = arr.tofile, + #fix for python3 + dataFunc = lambda f: f.write(arr.tobytes()) , ) for keyValue in kargs.items(): + self.xpaset(cmd=" ".join(keyValue)) # showBinFile is commented out because it is broken with ds9 3.0.3 @@ -726,6 +728,10 @@ def xpaset(self, cmd, data=None, dataFunc=None): Raises RuntimeError if anything is written to stdout or stderr. """ + if data is not None: + #fix python3 + data=data.encode() + return xpaset( cmd = cmd, data = data, From 63272e9f49542a2959b7abf7be6f345c063ff15a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavol=20Gajdo=C5=A1?= Date: Fri, 22 Nov 2024 18:53:12 +0100 Subject: [PATCH 2/2] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 1f52fb4..0bd0fb2 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ # RO3 Russel Owen's library ported to Python 3. + +Modification of original RO3 (https://github.com/ApachePointObservatory/RO3) to work with Python 3.12 and the newest version of numpy and astropy. Fixed only the DS9.py file (open images in SAO DS9)! Tested on numpy 1.26.0 and astropy 6.1.2.