# HG changeset patch # User Edouard Tisserant # Date 1685522453 -7200 # Node ID 3deeda82636ac5af83010bf583be69c91e074fcb # Parent 032bf4f225d095de3fb0b341cab22de09d9fa466 Fix Py3 problems with basic SVGHMI build and run. diff -r 032bf4f225d0 -r 3deeda82636a docutil/docsvg.py --- a/docutil/docsvg.py Wed May 31 10:38:03 2023 +0200 +++ b/docutil/docsvg.py Wed May 31 10:40:53 2023 +0200 @@ -25,6 +25,7 @@ import os +import sys import wx import subprocess from dialogs import MessageBoxOnce @@ -33,8 +34,8 @@ def _get_inkscape_path(): """ Return the Inkscape binary path """ - if wx.Platform == '__WXMSW__': - from six.moves import winreg + if sys.platform.startswith('win32'): + import winreg inkcmd = None tries = [(winreg.HKEY_LOCAL_MACHINE, 'Software\\Classes\\svgfile\\shell\\Inkscape\\command'), (winreg.HKEY_LOCAL_MACHINE, 'Software\\Classes\\inkscape.svg\\shell\\open\\command'), diff -r 032bf4f225d0 -r 3deeda82636a fake_wx.py --- a/fake_wx.py Wed May 31 10:38:03 2023 +0200 +++ b/fake_wx.py Wed May 31 10:40:53 2023 +0200 @@ -98,6 +98,7 @@ ('wx.dataview',['PyDataViewIndexListModel']), ('matplotlib.backends.backend_agg',[]), ('wx.aui',[]), + ('wx.html',['HtmlWindow']), ('mpl_toolkits.mplot3d',[])]: modpath = None parentmod = None diff -r 032bf4f225d0 -r 3deeda82636a svghmi/hmi_tree.py --- a/svghmi/hmi_tree.py Wed May 31 10:38:03 2023 +0200 +++ b/svghmi/hmi_tree.py Wed May 31 10:40:53 2023 +0200 @@ -150,10 +150,10 @@ s = hashlib.new('md5') self._hash(s) # limit size to HMI_HASH_SIZE as in svghmi.c - return list(map(ord,s.digest()))[:8] + return s.digest()[:8] def _hash(self, s): - s.update(str((self.name,self.nodetype))) + s.update(self.name.encode() + self.nodetype.encode()) if hasattr(self, "children"): for c in self.children: c._hash(s) diff -r 032bf4f225d0 -r 3deeda82636a svghmi/svghmi.py --- a/svghmi/svghmi.py Wed May 31 10:38:03 2023 +0200 +++ b/svghmi/svghmi.py Wed May 31 10:40:53 2023 +0200 @@ -427,13 +427,12 @@ InkscapeGeomColumns = ["Id", "x", "y", "w", "h"] inkpath = get_inkscape_path() - if inkpath is None: self.FatalError("SVGHMI: inkscape is not installed.") svgpath = self._getSVGpath() status, result, _err_result = ProcessLogger(self.GetCTRoot().logger, - '"' + inkpath + '" -S "' + svgpath + '"', + [inkpath, '-S', svgpath], no_stdout=True, no_stderr=True).spin() if status != 0: @@ -611,7 +610,7 @@ # print(transform.xslt.error_log) # print(etree.tostring(result.xslt_profile,pretty_print=True)) - with open(hash_path, 'wb') as digest_file: + with open(hash_path, 'w') as digest_file: digest_file.write(digest) else: self.GetCTRoot().logger.write(" No changes - XSLT transformation skipped\n") @@ -677,14 +676,14 @@ factory = HMIWebSocketServerFactory() factory.setProtocolOptions(maxConnections={maxConnections}) - svghmi_root.putChild("ws", WebSocketResource(factory)) + svghmi_root.putChild(b"ws", WebSocketResource(factory)) svghmi_listener = reactor.listenTCP({port}, Site(svghmi_root), interface='{interface}') path_list = [] svghmi_servers["{interface}:{port}"] = (svghmi_root, svghmi_listener, path_list) svghmi_root.putChild( - '{path}', + b'{path}', NoCacheFile('{xhtml}', defaultType='application/xhtml+xml'))