def updateJobHistoryInfo(): while True: command = getJobsHistory() content = executeCommand(command) write_data(jobs_historyfile(), content) time.sleep(60)
def save_prediction(job_params): """ Save prediction values of the job into a file :param job_params (string) data to be saved """ prediction_file = "%s/prediction.json" % settings.get_temp_dir() write_data(prediction_file, job_params)
def writeJobRunning(job_output): """ append job execution results to a file :param job_output (string) job output data """ path = settings.get_temp_dir() + "/job_log.json" job_remote_dataset = json.loads(read_data_oneline(path)) job_remote_dataset["data"].append(json.loads(job_output)) write_data(path, json.dumps(job_remote_dataset, indent=2))
def test_update_json(self): path = settings.get_temp_dir() + "/job_log.json" content = read_data(path) content = ''.join(content) content = content.replace("\n", "") content = content.strip() content = json.loads(content) gid = "3" for x in content["jobs"]["job"]: if x["gid"] == gid: x["step"] = "20" write_data(path, json.dumps(content))
def test_add_entry_json(self): # from pudb import set_trace; set_trace() path = settings.get_temp_dir() + "/job_log.json" content = read_data(path) content = ''.join(content) content = content.replace("\n", "") content = content.strip() content = json.loads(content) gid = "40" for x in content["jobs"]["job"]: if x["gid"] == gid: x["step"] = "20" content["jobs"]["job"].append({"gid": "40", "command": "test", "step": "1"}) write_data(path, json.dumps(content))