docutil/docsvg.py
author |
Andrey Skvortsov <andrej.skvortzov@gmail.com> |
|
Tue, 05 Mar 2019 11:19:36 +0300 |
changeset 2519 |
27955f010b23 |
parent 2431 |
6923074540dd
|
child 2628 |
40c4449001df |
permissions |
-rw-r--r-- |
Fix crash if LD input contact isn't connected
Traceback (most recent call last):
File "/home/developer/WorkData/PLC/beremiz/beremiz/BeremizIDE.py", line 339, in OnMethod
obj.CTR.CallMethod('_'+meth)
File "/home/developer/WorkData/PLC/beremiz/beremiz/ProjectController.py", line 1996, in CallMethod
getattr(self, method)()
File "/home/developer/WorkData/PLC/beremiz/beremiz/ProjectController.py", line 1134, in _Build
IECGenRes = self._Generate_SoftPLC()
File "/home/developer/WorkData/PLC/beremiz/beremiz/ProjectController.py", line 746, in _Generate_SoftPLC
if self._Generate_PLC_ST():
File "/home/developer/WorkData/PLC/beremiz/beremiz/ProjectController.py", line 763, in _Generate_PLC_ST
self._getIECgeneratedcodepath())
File "/home/developer/WorkData/PLC/beremiz/beremiz/PLCControler.py", line 456, in GenerateProgram
self.ProgramChunks = GenerateCurrentProgram(self, self.Project, errors, warnings)
File "/home/developer/WorkData/PLC/beremiz/beremiz/PLCGenerator.py", line 1762, in GenerateCurrentProgram
generator.GenerateProgram()
File "/home/developer/WorkData/PLC/beremiz/beremiz/PLCGenerator.py", line 478, in GenerateProgram
self.GeneratePouProgram(pou_name)
File "/home/developer/WorkData/PLC/beremiz/beremiz/PLCGenerator.py", line 260, in GeneratePouProgram
program = pou_program.GenerateProgram(pou)
File "/home/developer/WorkData/PLC/beremiz/beremiz/PLCGenerator.py", line 1718, in GenerateProgram
self.ComputeProgram(pou)
File "/home/developer/WorkData/PLC/beremiz/beremiz/PLCGenerator.py", line 1028, in ComputeProgram
self.GenerateBlock(instance, block_infos, body, None)
File "/home/developer/WorkData/PLC/beremiz/beremiz/PLCGenerator.py", line 1144, in GenerateBlock
expression = self.ComputeExpression(body, connections, executionOrderId > 0)
File "/home/developer/WorkData/PLC/beremiz/beremiz/PLCGenerator.py", line 1373, in ComputeExpression
paths = self.GeneratePaths(connections, body, order, to_inout)
File "/home/developer/WorkData/PLC/beremiz/beremiz/PLCGenerator.py", line 1344, in GeneratePaths
elif isinstance(result[0], list):
IndexError: list index out of range
Close #70
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# This file is part of Beremiz, a Integrated Development Environment for
# programming IEC 61131-3 automates supporting plcopen standard and CanFestival.
#
# Copyright (C) 2007: Edouard TISSERANT and Laurent BESSARD
#
# See COPYING file for copyrights details.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
from __future__ import absolute_import
import os
import subprocess
import wx
def get_inkscape_path():
""" Return the Inkscape path """
from six.moves import winreg
try:
svgexepath = winreg.QueryValue(winreg.HKEY_LOCAL_MACHINE,
'Software\\Classes\\svgfile\\shell\\Inkscape\\command')
except OSError:
svgexepath = winreg.QueryValue(winreg.HKEY_LOCAL_MACHINE,
'Software\\Classes\\inkscape.svg\\shell\\open\\command')
svgexepath = svgexepath.replace('"%1"', '')
return svgexepath.replace('"', '')
def open_win_svg(svgexepath, svgfile):
""" Open Inkscape on Windows platform """
popenargs = [svgexepath]
if svgfile is not None:
popenargs.append(svgfile)
subprocess.Popen(popenargs)
def open_lin_svg(svgexepath, svgfile):
""" Open Inkscape on Linux platform """
if os.path.isfile("/usr/bin/inkscape"):
os.system("%s %s &" % (svgexepath, svgfile))
def open_svg(svgfile):
""" Generic function to open SVG file """
if wx.Platform == '__WXMSW__':
try:
open_win_svg(get_inkscape_path(), svgfile)
except Exception:
wx.MessageBox("Inkscape is not found or installed !")
return None
else:
svgexepath = os.path.join("/usr/bin", "inkscape")
if os.path.isfile(svgexepath):
open_lin_svg(svgexepath, svgfile)
else:
wx.MessageBox("Inkscape is not found or installed !")
return None