6.23.7.1. Execute Python Script

Comienzo python section to interscript/frames/processf.py[2 /3 ] Siguiente Previo Primero Ăšltimo
    73: #line 95 "process_frame.ipk"
    74:   def py_exec(self,py,file,count,dict):
    75:     # get a lock here, release it later
    76:     try:
    77:       if 'script' in self.trace: print 'Executing',py
    78:       code  = compile(py,file + "[%2d]" % count,'exec')
    79:       exec code in dict,dict
    80:     except KeyboardInterrupt:
    81:       self.update_files = 0
    82:       raise process_fault,'Keyboard Interrupt'
    83:     except eoi: raise
    84:     except process_fault: raise
    85:     except:
    86:       print '-------------------------------------'
    87:       print 'ERROR EXECUTING CLIENT PYTHON SCRIPT'
    88:       fileid = file+'[%2d]' % count
    89:       print 'CONTEXT'
    90:       print 'File:', fileid
    91:       code_lines = string.split(py,'\n')
    92:       i = 1
    93:       for line in code_lines:
    94:         print '  %2d:' % i,line
    95:         i = i + 1
    96:       #traceback.print_exc()
    97:       print 'TRACEBACK (innermost last)'
    98:       exc_type, exc_value, exc_traceback = sys.exc_info()
    99:       tr = traceback.extract_tb(exc_traceback)
   100:       for filename, lineno, function, line in tr:
   101:         if function != '?': location= function
   102:         else: location= 'mainline'
   103:         print '  File:',filename,'[%2d]'%lineno,'in',location
   104:         if line: print '  ->',line
   105:         elif fileid== filename:
   106:           print '  +>',code_lines[lineno-1]
   107: 
   108:       print 'EXCEPTION:',
   109:       exc_desc=traceback.format_exception_only(exc_type, exc_value)
   110:       lines = string.split(string.join(exc_desc,'\n'),'\n')
   111:       lines = filter(None, lines)
   112:       if len(lines)!=1:
   113:         print
   114:         for line in lines:
   115:           if line: print ' ',line
   116:       else: print ' ',lines[0]
   117: 
   118:       del exc_type, exc_value, exc_traceback
   119:       try: raise eoi
   120:       except: pass
   121: 
   122:       if self.break_on_error:
   123:         self.update_files = 0
   124:         print 'BREAKING ON ERROR'
   125:         print '-------------------------------------'
   126:         raise process_fault,'Unexpected Exception'
   127:       else:
   128:         print 'IGNORING ERROR, CONTINUING'
   129:         print '-------------------------------------'
   130: 
End python section to interscript/frames/processf.py[2]