From 40176d2eaf8d02ad13640ee139b3938923c89d63 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 7 Dec 2019 13:45:01 +0100 Subject: [PATCH] Allow non existing configuration file Fixes #1. --- .gitignore | 8 +++++++- setup.py | 2 +- ucloud/config.py | 9 +++++++-- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 85c35fd..82146fa 100644 --- a/.gitignore +++ b/.gitignore @@ -1,12 +1,18 @@ .idea .vscode -__pycache__ ucloud/docs/build logs.txt ucloud.egg-info +# run artefacts default.etcd +__pycache__ + +# build artefacts ucloud/version.py +build/ +venv/ +dist/ diff --git a/setup.py b/setup.py index d2bd004..9a35f27 100644 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ with open("README.md", "r") as fh: long_description = fh.read() setup(name='ucloud', - version='0.1', + version='0.0.1', description='All ucloud server components.', url='https://code.ungleich.ch/ucloud/ucloud', long_description=long_description, diff --git a/ucloud/config.py b/ucloud/config.py index d5e5b77..7c141a3 100644 --- a/ucloud/config.py +++ b/ucloud/config.py @@ -4,10 +4,15 @@ from ucloud.common.host import HostPool from ucloud.common.request import RequestPool from ucloud.common.vm import VmPool from ucloud.common.storage_handlers import FileSystemBasedImageStorageHandler, CEPHBasedImageStorageHandler -from decouple import Config, RepositoryEnv +from decouple import Config, RepositoryEnv, RepositoryEmpty -env_vars = Config(RepositoryEnv('/etc/ucloud/ucloud.conf')) +# Try importing config, but don't fail if it does not exist +try: + env_vars = Config(RepositoryEnv('/etc/ucloud/ucloud.conf')) +except FileNotFoundError: + env_vars = Config(RepositoryEmpty()) + etcd_wrapper_args = () etcd_wrapper_kwargs = {