59
54
_upload_data(run_details['application_name'], app_run_details)
62
def _upload_data(test_name, run_json):
64
run_json_string = json.dumps(run_json)
65
except ValueError as e:
66
print("Error: Data does not appear to be valid json: %s" % e)
57
# def _upload_data(test_name, run_json):
59
# run_json_string = json.dumps(run_json)
60
# except ValueError as e:
61
# print("Error: Data does not appear to be valid json: %s" % e)
69
print("Uploading data for :memevent:-", test_name)
73
upload_process = subprocess.Popen(
74
[upload_script, nfss_config, 'memevent', test_name],
75
stdin=subprocess.PIPE,
76
stdout=subprocess.PIPE,
77
stderr=subprocess.PIPE,
79
stdout, stderr = upload_process.communicate(
80
input=run_json_string.encode()
82
print("stdout: {}\n\nstderr: {}".format(stdout, stderr))
83
except Exception as e:
84
print("Something went terribly wrong: ", e)
85
if upload_process.returncode != 0:
86
raise subprocess.CalledProcessError('Failed to upload to nfss')
64
# print("Uploading data for :memevent:-", test_name)
65
# global upload_script
68
# upload_process = subprocess.Popen(
69
# [upload_script, nfss_config, 'memevent', test_name],
70
# stdin=subprocess.PIPE,
71
# stdout=subprocess.PIPE,
72
# stderr=subprocess.PIPE,
74
# stdout, stderr = upload_process.communicate(
75
# input=run_json_string.encode()
77
# print("stdout: {}\n\nstderr: {}".format(stdout, stderr))
78
# except Exception as e:
79
# print("Something went terribly wrong: ", e)
80
# if upload_process.returncode != 0:
81
# raise subprocess.CalledProcessError('Failed to upload to nfss')
89
84
def _get_files_app_name_and_test(filename):
131
126
return app_result
134
def map_files_to_applications():
135
"""For any memory result files that exist, return a dictionary whos keys
136
are the applications name mapped to the file.
129
def map_files_to_applications(source_file_path):
130
"""For any memory result files that exist at **source_file_path**, return a
131
dictionary whos keys are the applications name and the values the file path
132
for that apps results.
138
134
We can then produce a single json result for each application regardless of
139
135
there being many tests / results for it.
143
global source_file_path
144
138
json_results_filename_pattern = os.path.join(
145
139
source_file_path,
146
140
"memory_usage_*.json"
156
print("{} <source file path> <nfss upload script> <nfss config file>"
157
.format(sys.argv[0]))
150
print("{} <source file path> <destination file>".format(sys.argv[0]))
153
def raise_on_invalid_args(argv):
157
def parse_args(argv):
159
source_file_path = argv[0]
160
destination_file = argv[1]
161
return (source_file_path, destination_file)
163
raise RuntimeError("Need both source path and destination file.")
166
def get_all_applications_details(source_file_path):
168
file_map = map_files_to_applications(source_file_path)
169
for app_name in file_map.keys():
170
app_details[app_name] = get_application_details(file_map[app_name])
161
if len(sys.argv) != 4:
177
raise_on_invalid_args(sys.argv)
178
source_file_path, destination_file = parse_args(sys.argv)
179
except RuntimeError as e:
165
global source_file_path
166
source_file_path = sys.argv[1]
169
upload_script = sys.argv[2]
172
nfss_config = sys.argv[3]
175
file_map = map_files_to_applications()
176
for app_name in file_map.keys():
177
app_details[app_name] = get_application_details(file_map[app_name])
183
app_details = get_all_applications_details(source_file_path)
179
185
for app_name in app_details.keys():
180
186
run_details = _get_run_details(app_name)
181
upload_json_details(run_details, app_details[app_name])
187
# upload_json_details(run_details, app_details[app_name])
189
# Write single large json blob to file.
184
192
if __name__ == '__main__':