Skip to content

Commit

Permalink
fixes #89 (#90)
Browse files Browse the repository at this point in the history
  • Loading branch information
sglebs authored Apr 16, 2020
1 parent 736cd88 commit a8694b0
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions utilities/xmlkaloi.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""XML KALOI (Keep a Lid On It).
Usage:
xmlkaloi --in=<inputXML> [--maxMetrics=<maxPrjMetrics>] [--xpathForEachMetric=<xpaths>] [--adaptive] [--sonarURL=<sonarURL>] [--sonarPrj=<sonarPrj>] [--sonarUser=<sonarUser>] [--sonarPass=<sonarPass>]
xmlkaloi --in=<inputXML> [--maxMetrics=<maxPrjMetrics>] [--xpathForEachMetric=<xpaths>] [--adaptive] [--outputDir=<path to dir where to save files>] [--outputCSV=<outputCSV>] [--sonarURL=<sonarURL>] [--sonarPrj=<sonarPrj>] [--sonarUser=<sonarUser>] [--sonarPass=<sonarPass>]
Options:
Expand All @@ -13,6 +13,8 @@
--sonarPrj=<sonarPrj> Name of Project in Sonar [default: #]
--sonarUser=<sonarUser> User name for Sonar authentication [default: admin]
--sonarPass=<sonarPass> Password for Sonar authentication [default: admin]
--outputCSV=<outputCSV> Output CSV file path with the current metrics listed at --maxPrjMetrics. Useful with the Jenkins/Plot plugin [default: srcmetrics.csv]
--outputDir=<path> Where files should be generated. [default: .]
Author:
Expand All @@ -31,7 +33,7 @@
from utilities import VERSION
import xml.etree.ElementTree as ET
import re
from utilities.utils import post_metrics_to_sonar
from utilities.utils import post_metrics_to_sonar, save_csv

def load_xml(xml_path):
xml_root = None
Expand Down Expand Up @@ -106,6 +108,13 @@ def main():
print ("%s (Current values: %s)" % (violators, current_values))
if adaptive:
write_json(arguments.get("--maxMetrics", False), current_values)
output_dir = arguments["--outputDir"]
absolute_csv_path = "%s%s%s" % (output_dir, os.sep, arguments["--outputCSV"])
csv_ok = save_csv(absolute_csv_path, current_values)
if csv_ok:
print("+++ Metrics saved to %s" % absolute_csv_path)
else:
print ("\n*** Problems creating CSV file %s" % absolute_csv_path)
post_metrics_to_sonar(arguments, current_values)
end_time = datetime.datetime.now()
print("\r\n--------------------------------------------------")
Expand Down

0 comments on commit a8694b0

Please sign in to comment.