473,385 Members | 1,958 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Redirecting STDIO and STDERR to a pharser and print ERROR

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
1 1451
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

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

Similar topics

4
by: Jan Knop | last post by:
Hello I am writing a Windows application where I need to redirect stdin, stdout and stderr from Python. to my application Is it a simple way of do it ? Has anyone done it using Winsock ?
3
by: David Douard | last post by:
Hi everybody, let me explain by problem: I am working on an application which consists in a C++ dll (numeric computations) and a Python IHM (Python/Tk), which must run under Linux and win32. My...
9
by: Fuzzyman | last post by:
Hello, I'm trying to redirect standard out in a single namespace. I can replace sys.stdout with a custom object - but that affects all namespaces. There will be code running simultaneously...
3
by: GinTon | last post by:
Is the same use _sys.stderr.write('error message'); sys.exit(1)_ than _sys.exit('error message')_ ? Note: help(sys.exit) If the status is omitted or None, it defaults to zero (i.e., success)....
18
by: praetor.michael | last post by:
I have a DLL written in C that writes to stderr. I have a win32 console application that makes calls to the DLL. In the console app I redirect stderr to a file using freopen. The problem I'm...
10
by: SamG | last post by:
How could i make, from inside the program, to have the stdout and stderr to be printed both to a file as well the terminal(as usual).
116
by: dmoran21 | last post by:
Hi All, I am working on a program to take input from a txt file, do some calculations, and then output the results to another txt file. The program that I've written compiles fine for me, however,...
10
by: Guillaume Dargaud | last post by:
Hello all, I have some error checking using the function 'perror', which writes messages on stderr. I'd like to send all error messages to a file instead. Is there some way to do this, short of...
2
by: rparimi | last post by:
I am trying to redirect stderr of a process to a temporary file and then read back the contents of the file, all in the same python script. As a simple exercise, I launched /bin/ls but this doesn't...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.