Skip to content

Commit

Permalink
halibot: add optional working directory override to core
Browse files Browse the repository at this point in the history
  • Loading branch information
richteer authored and sjrct committed Oct 25, 2017
1 parent 1d86cab commit d705c9c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions halibot/halibot.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ def __init__(self, **kwargs):

self.use_config = kwargs.get("use_config", True)
self.use_auth = kwargs.get("use_auth", True)
self.workdir = kwargs.get("workdir", ".")

self.auth = HalAuth()
self.objects = ObjectDict()
Expand Down Expand Up @@ -89,12 +90,12 @@ def add_instance(self, name, inst):
self.log.info("Instantiated object '" + name + "'")

def _load_config(self):
with open("config.json","r") as f:
with open(os.path.join(self.workdir, "config.json"), "r") as f:
self.config = json.loads(f.read())
halibot.packages.__path__ = self.config.get("package-path", [])

def _write_config(self):
with open("config.json", "w") as f:
with open(os.path.join(self.workdir, "config.json"), "w") as f:
f.write(json.dumps(self.config, sort_keys=True, indent=4))


Expand Down

0 comments on commit d705c9c

Please sign in to comment.