Python – remove the words translation

#!/usr/bin/env python

#                       Python – CPSC236

#changes
#
#1. send the origional file to p2cc not the file.c
#
#2. change the output file so as to remove the words translation complete when error…
#
#
#
#

from sys import *
import os
import commands
from string import *

Output=”p2c ”
Output=Output + argv[1]
Output=Output + ” > junk 2>good ”

print Output
os.system(Output)

tmpOutStr1=”grep \”Warning:\” junk”
warnings_found_if0, devnull = commands.getstatusoutput(tmpOutStr1)

tmpOutStr2=”grep \”error\” good”
errors_found_if0, devnull = commands.getstatusoutput(tmpOutStr2)

if (warnings_found_if0==0):
print “Their were warnings found: ”
os.system(“cat junk | more”)

print “”

#if (errors_found_if0==0):
#   print “Their were errors found: ”
#   os.system(“cat good | more”)

if (warnings_found_if0!=0):
#Now try p2cc

new_c_file_str=replace(argv[1],”.pas”,”.c”,1)
Output=”p2cc ”
Output=Output + new_c_file_str
Output=Output + ” > junk 2>good ”
print Output
os.system(Output)

tmpOutStr1=”grep \”Warning:\” junk”
warnings_found_if0, devnull = commands.getstatusoutput(tmpOutStr1)

tmpOutStr2=”grep \”errors\” good”
errors_found_if0, devnull = commands.getstatusoutput(tmpOutStr2)

if ((errors_found_if0 != 0) & (warnings_found_if0 != 0)):
print “Created: ”
print new_c_file_str
print “Sent to p2cc”
print “Success!”
print “Your output is in: a.out”
else:
print “Their were errors found: ”
os.system(“cat good | more”)
os.system(“cat junk | more”)

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>