makemetricsfiles.py #1

  • //
  • guest/
  • russell_jackson/
  • metrics/
  • makemetricsfiles.py
  • View
  • Commits
  • Open Download .zip Download (1 KB)
#!/usr/local/bin/python
# makemetricsfiles.py

import sys, os, re

HELPTEXT = """
Usage:
\tpython makemetricsfiles.py [depot path] [Previous Label] [Current Label]
This command requires the depot path, the previous build label
and the current build label as parameters.
For Example:
\tpython makemetricsfiles.py //depot/... JACKALOPE.16 JACKALOPE.17
"""


def create (depot, prev_label, curr_label):
	os.system ('p4 changes -l ' + depot + '@' + prev_label + '> ' + prev_label + '.txt')	
	os.system ('p4 changes -l ' + depot + '@' + curr_label + '> ' + curr_label + '.txt')

	os.system ('diff ' + prev_label + '.txt ' + curr_label + '.txt > ' + curr_label + '.temp')
	file = open (curr_label + '.temp', 'r')
	outfile = open (curr_label + '.diff', 'w')
	for line in file.readlines():
		if re.match( r"^\>", line ):
			outfile.write (line)
	file.close()
	outfile.close()
	os.remove (curr_label + '.temp')
	return 0

def createlabel (depot, prev_label, curr_label):
	

	os.system ('p4 files @' + prev_label + ' > ' + prev_label + '.label')	
	os.system ('p4 files @' + curr_label + ' > ' + curr_label + '.label')
	
	return 0
	
if __name__ == '__main__':
	stat = 0
	if len(sys.argv) < 4:
		print HELPTEXT
		sys.exit(1)
	else:
		create (sys.argv[1], sys.argv[2], sys.argv[3])
		createlabel (sys.argv[1], sys.argv[2], sys.argv[3])
	
# end of makemetricsfiles.py
# Change User Description Committed
#1 514 Russell C. Jackson (Rusty) Source code metrics scripts.

See metrics.py for usage.