Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- import subprocess
- import re
- trafficserver_source_dir = "/Users/danielxu/dev/trafficserver"
- def main():
- # Run the unix `grep` command
- try:
- output = subprocess.check_output("grep -Ihr 'Debug(\"' {0}".format(trafficserver_source_dir), shell=True, stderr=subprocess.STDOUT)
- except subprocess.CalledProcessError, e:
- print "Some kind of error happened"
- print e.output
- # Parse results of `grep`
- tags = []
- lines = output.split('\n')
- for line in lines:
- line = line.strip()
- # Hueristic detection of debug statements
- # We only want the tags to `Debug()` functions
- if line[0:6] != "Debug(":
- continue
- # Find the two "'s and extract what's between them
- index1 = line.find('"', 0)
- index2 = line.find('"', index1+1)
- tag = line[index1+1:index2]
- if ' ' not in tag and tag not in tags:
- tags.append(tag)
- #acc = ""
- for tag in tags:
- #acc += tag + ", "
- print tag
- #print acc
- if __name__ == '__main__':
- print 'Recursively grubbing for debug tags in: {0}'.format(trafficserver_source_dir)
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement