From 9c209cb9e9e589ca30d6b2e16e6e8a39a6726101 Mon Sep 17 00:00:00 2001 From: Diederik Date: Wed, 20 Jun 2012 15:36:57 -0400 Subject: [PATCH] Added command line option to specify output directory. --- gerritstats/classes.py | 6 ++---- gerritstats/stats.py | 10 ++++++++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/gerritstats/classes.py b/gerritstats/classes.py index 7807c88..6d62a0c 100644 --- a/gerritstats/classes.py +++ b/gerritstats/classes.py @@ -78,8 +78,8 @@ class Gerrit(object): This object contains the setings to interact with the gerrit server, nothing fancy these are just sensible defaults. ''' - def __init__(self): - self.data_location = 'data' + def __init__(self, args): + self.data_location = args.output self.host = 'gerrit.wikimedia.org' self.port = 29418 self.format = 'JSON' @@ -207,9 +207,7 @@ class YamlConfig(object): self.set_charttype() filename = '%s.yaml' % (self.repo.determine_filename()) - print self.repo.directory full_path = os.path.join(self.repo.directory, filename) - print 'filename: %s' % filename fh = open(full_path, 'w') fh.write(self.buffer.getvalue()) fh.close() \ No newline at end of file diff --git a/gerritstats/stats.py b/gerritstats/stats.py index 0866e5d..1dd59a2 100755 --- a/gerritstats/stats.py +++ b/gerritstats/stats.py @@ -21,7 +21,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. import subprocess import json import sys -import os +import argparse from datetime import datetime from classes import Gerrit, Settings, Metric, Repo, YamlConfig @@ -162,9 +162,15 @@ def construct_dataset(settings, repos, metric, output, gerrit): repo.touched = True +def parse_commandline(): + parser = argparse.ArgumentParser(description='Process some integers.') + parser.add_argument('--output', help='Specify the absolute path to store the gerrit-stats datasets.') + return parser.parse_args() + def main(): - gerrit = Gerrit() + args = parse_commandline() + gerrit = Gerrit(args) settings = Settings(gerrit) print 'Fetching list of all gerrit repositories...\n' repos = create_repo_set(gerrit, settings) -- 1.7.0.4