Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- import sys
- filename = "FILE0"
- funcname = "FUNC0"
- start_writren = True
- if len(sys.argv) < 2:
- print "ERROR: NO FILENAME DIVEN!"
- else:
- inputFile = open( sys.argv[1], "r" )
- filename = sys.argv[1]
- sourceArray = []
- for line in inputFile:
- sourceArray.append( line )
- print "EXEC: Read done."
- # print sourceArray
- if (len(sys.argv) == 3):
- destFile = open(sys.argv[2], "w")
- else:
- destFile = open(sys.argv[1], "w")
- sourceArray[0] = "%s %s" % (sourceArray[0], 'echo "Entered[%s]" >> /tmp/wisc.log\n' % (filename))
- for line in sourceArray:
- # hard
- if(line.find("()") != -1):
- funcname = line[0:line.find("()")+2]
- start_writren = False
- if(line.find("{") == -1 and line.find("}") == -1):
- destFile.write(line)
- else:
- if(line.find("{") != -1 and line.find("}") == -1 and start_writren == False): # found only for the first time{
- destFile.write(line)
- destFile.write('\techo "[%s]:[%s]:[%s]" >> /tmp/wisc.log\n' % (filename, funcname, "start") )
- start_writren = True
- elif(line.find("{") == -1 and line.find("}") != -1 and line == '}\n' ): # found only }
- destFile.write('\techo "[%s]:[%s]:[%s]" >> /tmp/wisc.log\n' % (filename, funcname, "end") )
- destFile.write(line)
- else:
- destFile.write(line)
- # hard done
- destFile.write('echo "Exited[%s]" >> /tmp/wisc.log\n' % (filename))
- print "EXEC: Write done."
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement