Skip to content

Commit

Permalink
Erlangga Add team_configuration property (#72)
Browse files Browse the repository at this point in the history
* add get team configuration

* change read json path
  • Loading branch information
erlanggakrisnamukti authored and pancaprima committed Aug 21, 2018
1 parent 6deb213 commit 9224ec8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
6 changes: 4 additions & 2 deletions locust/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,16 @@ class ClientConfiguration:

config_data = None

def read_json(self):
def read_json(self, path=None):
"""
Will get the data of configuration as JSON.
It reads configuration file once.
"""
if self.config_data is None:
if path is None:
path = CONFIG_PATH
try:
with open((os.environ['PYTHONPATH'].split(os.pathsep))[-1] + CONFIG_PATH, "r") as data_file:
with open((os.environ['PYTHONPATH'].split(os.pathsep))[-1] + path, "r") as data_file:
self.config_data = json.load(data_file)
except Exception as err:
logger.info(err)
Expand Down
7 changes: 7 additions & 0 deletions locust/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,13 @@ def configuration(self):
"""
return self.config.read_json()

def team_configuration(self, path):
"""
Reference to get_team_config func in configuration.py
"""
config = ClientConfiguration()
return config.get_team_config(path)

@property
def runners(self):
"""
Expand Down

0 comments on commit 9224ec8

Please sign in to comment.