grim/local-pipelines

8cfb4410c566
Parents e5b716d5b51b
Children f7706d051812
core: parse env file and return a dict

If there is an IOError or DockerException, then we print the error and
exit.
--- a/pipelines/core.py Tue Jul 26 14:06:57 2016 -0700
+++ b/pipelines/core.py Mon Jul 25 17:39:45 2016 -0700
@@ -9,6 +9,8 @@
import yaml
from docker import Client
+from docker.utils import parse_env_file
+from docker.errors import DockerException
from pipelines import vcs
from pipelines.pipeline import Pipeline
@@ -68,6 +70,21 @@
return k, v
+def _load_env(filenames):
+ # let's maintain the order of variables in the file
+ env = {}
+ for fn in filenames:
+ try:
+ env.update(parse_env_file(fn))
+ except IOError:
+ print("failed to open {}".format(fn))
+ sys.exit(1)
+ except DockerException, de:
+ print("{}".format(de))
+ sys.exit(2)
+ return env
+
+
def main():
args = parse_args()