svghmi/svghmi.py
branchsvghmi
changeset 2834 6ac6a9dff594
parent 2831 6c9cfdbe94dc
child 2866 59a855c17aa6
equal deleted inserted replaced
2833:e74123b966ac 2834:6ac6a9dff594
   473 
   473 
   474             # load svg as a DOM with Etree
   474             # load svg as a DOM with Etree
   475             svgdom = etree.parse(svgfile)
   475             svgdom = etree.parse(svgfile)
   476 
   476 
   477             # call xslt transform on Inkscape's SVG to generate XHTML
   477             # call xslt transform on Inkscape's SVG to generate XHTML
   478             try:
   478             try: 
   479                 result = transform.transform(svgdom)
   479                 result = transform.transform(svgdom)
   480             except XSLTApplyError as e:
   480             except XSLTApplyError as e:
   481                 self.FatalError("SVGHMI " + view_name  + ": " + e.message)
   481                 self.FatalError("SVGHMI " + view_name  + ": " + e.message)
       
   482             finally:
       
   483                 for entry in transform.get_error_log():
       
   484                     message = "SVGHMI: "+ entry.message + "\n" 
       
   485                     self.GetCTRoot().logger.write_warning(message)
   482 
   486 
   483             result.write(target_file, encoding="utf-8")
   487             result.write(target_file, encoding="utf-8")
   484             # print(str(result))
   488             # print(str(result))
   485             # print(transform.xslt.error_log)
   489             # print(transform.xslt.error_log)
   486 
   490 
   506         for thing in ["Start", "Stop", "Watchdog"]:
   510         for thing in ["Start", "Stop", "Watchdog"]:
   507              given_command = self.GetParamsAttributes("SVGHMI.On"+thing)["value"]
   511              given_command = self.GetParamsAttributes("SVGHMI.On"+thing)["value"]
   508              svghmi_cmds[thing] = (
   512              svghmi_cmds[thing] = (
   509                 "Popen(" +
   513                 "Popen(" +
   510                 repr(shlex.split(given_command.format(port="8008", name=view_name))) +
   514                 repr(shlex.split(given_command.format(port="8008", name=view_name))) +
   511                 ")") if given_command else "# no command given"
   515                 ")") if given_command else "pass # no command given"
   512 
   516 
   513         runtimefile_path = os.path.join(buildpath, "runtime_svghmi1_%s.py" % location_str)
   517         runtimefile_path = os.path.join(buildpath, "runtime_svghmi1_%s.py" % location_str)
   514         runtimefile = open(runtimefile_path, 'w')
   518         runtimefile = open(runtimefile_path, 'w')
   515         runtimefile.write("""
   519         runtimefile.write("""
   516 # TODO : multiple watchdog (one for each svghmi instance)
   520 # TODO : multiple watchdog (one for each svghmi instance)