svghmi/svghmi.py
changeset 3498 cf4e6a7d40f8
parent 3399 95e0b926a8c3
child 3499 72ee59ff959c
--- a/svghmi/svghmi.py	Wed May 25 09:18:37 2022 +0200
+++ b/svghmi/svghmi.py	Wed May 25 20:00:31 2022 +0200
@@ -299,18 +299,22 @@
         return ret
 
 if wx.Platform == '__WXMSW__':
-    browser_launch_cmd="cmd.exe /c 'start msedge {url}'"
+    default_cmds={
+        "launch":"cmd.exe /c 'start msedge {url}'",
+        "watchdog":"cmd.exe /k 'echo watchdog for {url} !'"}
 else:
-    browser_launch_cmd="chromium {url}"
+    default_cmds={
+        "launch":"chromium {url}",
+        "watchdog":"echo Watchdog for {name} !"}
 
 class SVGHMI(object):
     XSD = """<?xml version="1.0" encoding="utf-8" ?>
     <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
       <xsd:element name="SVGHMI">
         <xsd:complexType>
-          <xsd:attribute name="OnStart" type="xsd:string" use="optional" default="%s"/>
+          <xsd:attribute name="OnStart" type="xsd:string" use="optional" default="%(launch)s"/>
           <xsd:attribute name="OnStop" type="xsd:string" use="optional" default=""/>
-          <xsd:attribute name="OnWatchdog" type="xsd:string" use="optional" default=""/>
+          <xsd:attribute name="OnWatchdog" type="xsd:string" use="optional" default="%(watchdog)s"/>
           <xsd:attribute name="EnableWatchdog" type="xsd:boolean" use="optional" default="false"/>
           <xsd:attribute name="WatchdogInitial" use="optional" default="30">
             <xsd:simpleType>
@@ -342,7 +346,7 @@
         </xsd:complexType>
       </xsd:element>
     </xsd:schema>
-    """%browser_launch_cmd
+    """%default_cmds
 
     EditorType = SVGHMIEditor
 
@@ -399,9 +403,13 @@
         if from_project_path is not None:
             shutil.copyfile(self._getSVGpath(from_project_path),
                             self._getSVGpath())
-            shutil.copyfile(self._getPOTpath(from_project_path),
-                            self._getPOTpath())
-            # XXX TODO copy .PO files
+
+            potpath = self._getPOTpath(from_project_path)
+            if os.path.isfile(potpath):
+                shutil.copyfile(potpath, self._getPOTpath())
+                # copy .PO files
+                for _name, pofile in GetPoFiles(from_project_path):
+                    shutil.copy(pofile, self.CTNPath())
         return True
 
     def GetSVGGeometry(self):