Updated config
This commit is contained in:
parent
17fc302be4
commit
b7797157cc
4 changed files with 25 additions and 23 deletions
|
@ -1,9 +1,13 @@
|
|||
import click
|
||||
from project.utils import config
|
||||
from project.utils import config, repos
|
||||
|
||||
|
||||
@click.command('sync')
|
||||
def cli():
|
||||
@click.option('--private/--no-private', default=False)
|
||||
def cli(private):
|
||||
if not config.has_basics():
|
||||
print("You do not have all the basic requirements set.")
|
||||
return 1
|
||||
repos.clone_public_data()
|
||||
if private:
|
||||
repos.clone_public_data()
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import os
|
||||
from yaml import load, dump
|
||||
from .constants import DEFAULT_CONFIG_DIR, USER_CONFIG_DIR, REQUIRED_KEYS
|
||||
from . import constants
|
||||
|
||||
try:
|
||||
from yaml import CLoader as Loader, CDumper as Dumper
|
||||
|
@ -21,15 +21,15 @@ def get_config_data(filename):
|
|||
|
||||
def write_user_config(refresh_after=False):
|
||||
try:
|
||||
with open(USER_CONFIG_DIR, 'w') as config_file:
|
||||
with open(constants.USER_CONFIG_DIR, 'w') as config_file:
|
||||
dump(USER_CONFIG, config_file, indent=4, default_flow_style=False, Dumper=Dumper)
|
||||
return "SUCCESS"
|
||||
except Exception as e:
|
||||
return e
|
||||
|
||||
|
||||
DEFAULT_CONFIG = get_config_data(DEFAULT_CONFIG_DIR)
|
||||
USER_CONFIG = get_config_data(os.path.expanduser(USER_CONFIG_DIR))
|
||||
DEFAULT_CONFIG = get_config_data(constants.DEFAULT_CONFIG_DIR)
|
||||
USER_CONFIG = get_config_data(os.path.expanduser(constants.USER_CONFIG_DIR))
|
||||
|
||||
|
||||
def get(key):
|
||||
|
@ -48,7 +48,7 @@ def set(key, value, refresh_after=False):
|
|||
|
||||
|
||||
def has_basics():
|
||||
for key in REQUIRED_KEYS:
|
||||
for key in constants.REQUIRED_KEYS:
|
||||
if not get(key):
|
||||
return False
|
||||
return True
|
||||
|
|
|
@ -1,11 +1,14 @@
|
|||
import os
|
||||
|
||||
|
||||
# Core Directories
|
||||
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
DATA_DIR = os.path.expanduser("~/dfa/")
|
||||
|
||||
|
||||
USER_CONFIG_DIR = os.path.expanduser("~/.dfa.yml")
|
||||
# Config
|
||||
USER_CONFIG_DIR = os.path.join(DATA_DIR, ".dfa.yml")
|
||||
DEFAULT_CONFIG_DIR = os.path.join(BASE_DIR, 'defaults.yml')
|
||||
|
||||
|
||||
REQUIRED_KEYS = ['public_data']
|
||||
|
||||
# Data Directories
|
||||
PRIVATE_DATA_DIR = os.path.join(DATA_DIR, 'private_data')
|
||||
PUBLIC_DATA_DIR = os.path.join(DATA_DIR, 'public_data')
|
||||
|
|
|
@ -1,20 +1,15 @@
|
|||
import os
|
||||
from . import config
|
||||
|
||||
|
||||
def has_repo_cloned():
|
||||
return os.path.isdir('./data')
|
||||
from . import config, constants
|
||||
|
||||
|
||||
def clone_public_data():
|
||||
exit_code = 0
|
||||
exit_code = os.system("git clone -b master --single-branch {} data"
|
||||
.format(config.get('public_repo')))
|
||||
exit_code = os.system("git clone -b master --single-branch {} {}"
|
||||
.format(config.get('public_repo'),
|
||||
constants.PUBLIC_DATA_DIR))
|
||||
return exit_code
|
||||
|
||||
|
||||
def clone_private_data():
|
||||
exit_code = 0
|
||||
exit_code = os.system("git clone -b master --single-branch {} private_data"
|
||||
.format(config.get('private_repo')))
|
||||
exit_code = os.system("git clone -b master --single-branch {} {}"
|
||||
.format(config.get('private_repo'), constants.PRIVATE_DATA_DIR))
|
||||
return exit_code
|
||||
|
|
Reference in a new issue