svghmi/svghmi.py
branchsvghmi
changeset 3274 16066300b254
parent 3270 38f7122ccbf9
child 3277 8e81e4ce9bc6
equal deleted inserted replaced
3273:08a5a019bed2 3274:16066300b254
   533                 self.GetCTRoot().logger.write("    No changes - XSLT transformation skipped\n")
   533                 self.GetCTRoot().logger.write("    No changes - XSLT transformation skipped\n")
   534 
   534 
   535         else:
   535         else:
   536             target_file = open(target_path, 'wb')
   536             target_file = open(target_path, 'wb')
   537             target_file.write("""<!DOCTYPE html>
   537             target_file.write("""<!DOCTYPE html>
   538 <html>
   538 <html xmlns="http://www.w3.org/1999/xhtml">
       
   539 <head>
       
   540 <title>SVGHMI</title>
       
   541 </head>
   539 <body>
   542 <body>
   540 <h1> No SVG file provided </h1>
   543 <h1> No SVG file provided </h1>
   541 </body>
   544 </body>
   542 </html>
   545 </html>
   543 """)
   546 """)
   546         res += ((target_fname, open(target_path, "rb")),)
   549         res += ((target_fname, open(target_path, "rb")),)
   547 
   550 
   548         port = self.GetParamsAttributes("SVGHMI.Port")["value"]
   551         port = self.GetParamsAttributes("SVGHMI.Port")["value"]
   549         interface = self.GetParamsAttributes("SVGHMI.Interface")["value"]
   552         interface = self.GetParamsAttributes("SVGHMI.Interface")["value"]
   550         path = self.GetParamsAttributes("SVGHMI.Path")["value"].format(name=view_name)
   553         path = self.GetParamsAttributes("SVGHMI.Path")["value"].format(name=view_name)
       
   554         if path and path[0]=='/':
       
   555             path = path[1:]
   551         enable_watchdog = self.GetParamsAttributes("SVGHMI.EnableWatchdog")["value"]
   556         enable_watchdog = self.GetParamsAttributes("SVGHMI.EnableWatchdog")["value"]
   552         url="http://"+interface+("" if port==80 else (":"+str(port))
   557         url="http://"+interface+("" if port==80 else (":"+str(port))
   553             ) + (("/"+path) if path else ""
   558             ) + (("/"+path) if path else ""
   554             ) + ("#watchdog" if enable_watchdog else "")
   559             ) + ("#watchdog" if enable_watchdog else "")
   555 
   560 
   670                                       wx.YES_NO | wx.ICON_QUESTION)
   675                                       wx.YES_NO | wx.ICON_QUESTION)
   671             open_inkscape = dialog.ShowModal() == wx.ID_YES
   676             open_inkscape = dialog.ShowModal() == wx.ID_YES
   672             dialog.Destroy()
   677             dialog.Destroy()
   673         if open_inkscape:
   678         if open_inkscape:
   674             if not os.path.isfile(svgfile):
   679             if not os.path.isfile(svgfile):
   675                 svgfile = None
   680                 # make a copy of default svg from source
       
   681                 default = os.path.join(ScriptDirectory, "default.svg")
       
   682                 shutil.copyfile(default, svgfile)
   676             open_svg(svgfile)
   683             open_svg(svgfile)
   677 
   684 
   678     def _StartPOEdit(self, POFile):
   685     def _StartPOEdit(self, POFile):
   679         open_poedit = True
   686         open_poedit = True
   680         if not self.GetCTRoot().CheckProjectPathPerm():
   687         if not self.GetCTRoot().CheckProjectPathPerm():