plugins/python/python.py
changeset 367 a76ee5307bb7
parent 366 cd90e4c10261
child 418 01f6bfc01251
equal deleted inserted replaced
366:cd90e4c10261 367:a76ee5307bb7
   242         plc_python_filepath = os.path.join(os.path.split(__file__)[0], "plc_python.c")
   242         plc_python_filepath = os.path.join(os.path.split(__file__)[0], "plc_python.c")
   243         plc_python_file = open(plc_python_filepath, 'r')
   243         plc_python_file = open(plc_python_filepath, 'r')
   244         plc_python_code = plc_python_file.read()
   244         plc_python_code = plc_python_file.read()
   245         plc_python_file.close()
   245         plc_python_file.close()
   246         python_eval_fb_list = []
   246         python_eval_fb_list = []
   247         for v in plugin_root._VariablesList :
   247         for v in plugin_root._VariablesList:
   248             if v["vartype"] == "FB" and v["type"] in ["PYTHON_EVAL","PYTHON_POLL"]:
   248             if v["vartype"] == "FB" and v["type"] in ["PYTHON_EVAL","PYTHON_POLL"]:
   249                 python_eval_fb_list.append(v)
   249                 python_eval_fb_list.append(v)
   250         python_eval_fb_count = max(1, len(python_eval_fb_list))
   250         python_eval_fb_count = max(1, len(python_eval_fb_list))
   251         
   251         
   252         # prepare python code
   252         # prepare python code
   260         pythonfile.close()
   260         pythonfile.close()
   261         
   261         
   262         runtimefile_path = os.path.join(buildpath, "runtime_%s.py"%location_str)
   262         runtimefile_path = os.path.join(buildpath, "runtime_%s.py"%location_str)
   263         runtimefile = open(runtimefile_path, 'w')
   263         runtimefile = open(runtimefile_path, 'w')
   264         runtimefile.write(self.GetPythonCode())
   264         runtimefile.write(self.GetPythonCode())
   265         runtimefile.write("""
       
   266 def _runtime_%(location)s_begin():
       
   267     print "runtime_begin"
       
   268 
       
   269 def _runtime_%(location)s_cleanup():
       
   270     print "runtime_cleanup"
       
   271 
       
   272 """ % {"location": location_str})
       
   273         runtimefile.close()
   265         runtimefile.close()
   274         
   266         
   275         if wx.Platform == '__WXMSW__':
   267         if wx.Platform == '__WXMSW__':
   276             matiec_flags = " -I../../matiec/lib"
   268             matiec_flags = " -I../../matiec/lib"
   277         else:
   269         else: