Skip to content
This repository has been archived by the owner on Jun 27, 2019. It is now read-only.

convert-results.py fails if jsonfile exists #24

Open
thSoft opened this issue Dec 11, 2015 · 1 comment
Open

convert-results.py fails if jsonfile exists #24

thSoft opened this issue Dec 11, 2015 · 1 comment

Comments

@thSoft
Copy link
Contributor

thSoft commented Dec 11, 2015

If the file given in the --jsonfile parameter already exists, reporting/convert-results.py fails with:

Traceback (most recent call last):
  File "mondo-sam/reporting/convert_results.py", line 135, in <module>
    convert_results_to_csv(json_objects, args.csvfile)
  File "mondo-sam/reporting/convert_results.py", line 62, in convert_results_to_csv
    keys = set(result["Case"].keys())
TypeError: list indices must be integers, not str
@zkovari
Copy link
Contributor

zkovari commented Dec 11, 2015

Based on the error message, it seems like the Python script cannot parse a json file properly. Note that the convert-results.py script tries to parse every json file that are located in the given directory (given by the -s argument), therefore, one malformed json file can terminate the whole operation. Basically, the keys = set(result["Case"].keys()) statement searches a Case key in the result Map. However, according to the error message, it handles the result object as a List instead of a Map, since it requires a list index instead of a string key.

I see two options. First, one of the json file is empty or malformed due to the fact that the framework didn't save any results. This scenario can occur when your concrete Scenario object doesn't instantiate a CaseDescriptor in its build() method. Second, you saved the merged json file to the same directory where the original (individual) results were found, and thus, by running the converter script again you actually tried to parse the previously merged json file causing this anomaly.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants