Add command line option for output directory.

Add a -o, --out-dir option to specify an output directory.

Change-Id: I0c8ac1aba309f9a34b2562b18da644efd9f37f4e
Reviewed-on: https://review.openstack.org/20839
Reviewed-by: Jeremy Stanley <fungi@yuggoth.org>
Approved: Dan Prince <dprince@redhat.com>
Reviewed-by: Dan Prince <dprince@redhat.com>
Tested-by: Jenkins
This commit is contained in:
Elizabeth Krumbach 2013-01-30 14:27:45 -08:00 committed by Jenkins
parent e1a83e0b35
commit 9bbbafddb9
2 changed files with 13 additions and 4 deletions

View File

@ -6,6 +6,15 @@ from reviewday.util import create_report
from reviewday.launchpad import LaunchPad
from reviewday.mergeprop import MergeProp
from reviewday.smokestack import SmokeStack
from optparse import OptionParser
optparser = OptionParser()
optparser.add_option('-o', '--out-dir', dest='out_dir',
help='set output directory [default = %default]',
default='out_report', type='string')
(options, args) = optparser.parse_args()
lp = LaunchPad()
smoker = SmokeStack('http://smokestack.openstack.org/jobs.json?limit=10000')
@ -25,4 +34,5 @@ for project in ['nova', 'glance', 'keystone', 'swift', 'quantum', 'cinder']:
dts = str(datetime.utcnow())[0:19]
name_space = {"projects": projects, "dts": dts}
create_report(name_space)
out_dir = options.out_dir
create_report(out_dir, name_space)

View File

@ -4,19 +4,18 @@ from Cheetah.Template import Template
from distutils.dir_util import copy_tree
def prep_out_dir(out_dir='out_report'):
def prep_out_dir(out_dir):
src_dir = os.path.dirname(__file__)
report_files_dir = os.path.join(src_dir, 'report_files')
copy_tree(report_files_dir, out_dir)
def create_report(name_space={}):
def create_report(out_dir, name_space={}):
filename = os.path.join(os.path.dirname(__file__), 'report.html')
report_text = open(filename).read()
name_space['helper'] = html_helper
t = Template(report_text, searchList=[name_space])
out_dir = 'out_report'
prep_out_dir(out_dir)
out_file = open(os.path.join(out_dir, 'index.html'), "w")