Merge "Add test-scheduler dir to verity"
[bottlenecks.git] / test-scheduler / server / src / conductor_processor / task.py
1 ##############################################################################
2 # Copyright (c) 2018 Huawei Technologies Co.,Ltd. and others
3 #
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ##############################################################################
9
10 import json
11 import os
12
13
14 class TaskFile(object):
15     def __init__(self, taskName='task_0'):
16         self._defaultConfFile = self._getFilePath("defaultTaskFile.json")
17         with open(self._defaultConfFile) as defaultConf:
18             self._jsonObj = json.load(defaultConf)
19         self._jsonObj['name'] = taskName
20
21     def generateFromStep(self, stepObject):
22         self._jsonObj['name'] = stepObject.getName()
23         print "taskFile:", self._jsonObj['name']
24         return self._jsonObj
25
26     def _getFilePath(self, fileName):
27         dirPath = os.path.dirname(os.path.realpath(__file__))
28         return os.path.join(dirPath, fileName)