By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
439,941 Members | 1,753 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 439,941 IT Pros & Developers. It's quick & easy.

Redirecting STDIO and STDERR to a pharser and print ERROR

P: 1
Im trying to catch all errors from my Phyton compiler.

for that i'm using this code:

This code work great, but i cant pharse the data using the split() function, the parse function comes empty, only calling to the function and returns give me nothing....WHY???

Some problem with CLASSES??

import MOD
import SER
import sys
h=0
j=0

SER.set_speed('9600','8N1')


#Class who CATCH AND PRINT THE ERROR
class SerWriter:
a=''
def write(self,s):
j = parser(s)
SER.send(j)



#CLASS FOR PARSE THE ERROR
def parser(error):
....PHARSE CODE HERE
#line 17
#expected char, string found
return error


#REDIRECTING
sys.stdout = SerWriter()
sys.stderr = SerWriter()


#MAIN
while 1:
SER.send(('Running\r'))
#force an error
SER.send(ord('29'))
MOD.sleep(10)
Apr 5 '08 #1
Share this Question
Share on Google+
1 Reply


Subsciber123
P: 87
Grrrr! Pardon my frustration, but please use [ code=python ] [ /code ] tags (without the spaces). That will make your code readable and syntax-highlighted. Once you have done that, people will be much more likely and/or willing to help you.

Im trying to catch all errors from my Phyton compiler.

for that i'm using this code:

This code work great, but i cant pharse the data using the split() function, the parse function comes empty, only calling to the function and returns give me nothing....WHY???

Some problem with CLASSES??

import MOD
import SER
import sys
h=0
j=0

SER.set_speed('9600','8N1')


#Class who CATCH AND PRINT THE ERROR
class SerWriter:
a=''
def write(self,s):
j = parser(s)
SER.send(j)



#CLASS FOR PARSE THE ERROR
def parser(error):
....PHARSE CODE HERE
#line 17
#expected char, string found
return error


#REDIRECTING
sys.stdout = SerWriter()
sys.stderr = SerWriter()


#MAIN
while 1:
SER.send(('Running\r'))
#force an error
SER.send(ord('29'))
MOD.sleep(10)
Apr 11 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.