2013-04-12 02:56:55 +04:00
|
|
|
import json
|
|
|
|
import os
|
2013-11-14 05:24:24 +04:00
|
|
|
from django.conf import settings
|
2013-04-12 02:56:55 +04:00
|
|
|
|
2013-08-20 00:45:44 +04:00
|
|
|
|
2013-04-12 02:56:55 +04:00
|
|
|
class SampleData(object):
|
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
|
|
|
|
self.job_data_file = "{0}/sample_data/job_data.txt".format(
|
|
|
|
os.path.dirname(__file__)
|
2013-08-20 00:45:44 +04:00
|
|
|
)
|
2013-04-12 02:56:55 +04:00
|
|
|
|
2013-11-14 05:24:24 +04:00
|
|
|
self.resultset_data_file = "{0}/sample_data/resultset_data.json".format(
|
|
|
|
os.path.dirname(__file__)
|
|
|
|
)
|
|
|
|
|
2013-04-12 02:56:55 +04:00
|
|
|
self.raw_pulse_data_file = "{0}/sample_data/raw_pulse_data.txt".format(
|
|
|
|
os.path.dirname(__file__)
|
2013-08-20 00:45:44 +04:00
|
|
|
)
|
2013-06-05 02:51:52 +04:00
|
|
|
self.logs_dir = "{0}/sample_data/logs".format(
|
|
|
|
os.path.dirname(__file__)
|
2013-08-20 00:45:44 +04:00
|
|
|
)
|
|
|
|
|
|
|
|
with open("{0}/sample_data/artifacts/structured_log_artifact.json".format(
|
|
|
|
os.path.dirname(__file__))) as f:
|
|
|
|
self.structured_log_artifact = f.readlines()
|
|
|
|
|
|
|
|
with open("{0}/sample_data/artifacts/job_artifact.json".format(
|
|
|
|
os.path.dirname(__file__))) as f:
|
|
|
|
self.job_artifact = f.readlines()
|
2013-04-12 02:56:55 +04:00
|
|
|
|
|
|
|
self.job_data = []
|
|
|
|
self.raw_pulse_data = []
|
2013-11-14 05:24:24 +04:00
|
|
|
self.resultset_data = []
|
2013-04-12 02:56:55 +04:00
|
|
|
|
|
|
|
self.initialize_data()
|
|
|
|
|
|
|
|
def initialize_data(self):
|
|
|
|
|
|
|
|
with open(self.job_data_file) as f:
|
|
|
|
for line in f.readlines():
|
2013-08-20 00:45:44 +04:00
|
|
|
self.job_data.append(json.loads(line.strip()))
|
2013-04-12 02:56:55 +04:00
|
|
|
|
2013-11-14 05:24:24 +04:00
|
|
|
with open(self.resultset_data_file) as f:
|
|
|
|
|
|
|
|
self.resultset_data = json.loads(f.read())
|
|
|
|
for rs in self.resultset_data:
|
|
|
|
for rev in rs["revisions"]:
|
|
|
|
rev["repository"] = settings.DATABASES["default"]["TEST_NAME"]
|
|
|
|
|
2013-04-12 02:56:55 +04:00
|
|
|
with open(self.raw_pulse_data_file) as f:
|
|
|
|
for line in f.readlines():
|
|
|
|
line = str(line)
|
2013-08-20 00:45:44 +04:00
|
|
|
self.raw_pulse_data.append(json.loads(line.strip()))
|
2013-06-05 02:51:52 +04:00
|
|
|
|
|
|
|
def get_log_path(self, name):
|
|
|
|
"""Returns the full path to a log file"""
|
|
|
|
return "{0}/{1}".format(self.logs_dir, name)
|