Config file error messages. Close #423

This commit is contained in:
Dmitry
2018-01-14 22:04:40 -08:00
parent b88613fdaa
commit 4ceaba37d0
3 changed files with 13 additions and 6 deletions
+1 -1
View File
@@ -23,7 +23,7 @@ class CmdBase(object):
if os.path.isdir(dvc_dir):
return root
root = os.path.dirname(root)
msg = "Not a dvc repository (or any parent up to mount point {})"
msg = "Not a dvc repository (checked up to mount point {})"
raise DvcException(msg.format(root))
def run_cmd(self):
+10 -3
View File
@@ -5,7 +5,6 @@ import os
import configparser
from dvc.exceptions import DvcException
from dvc.logger import Logger
class ConfigError(DvcException):
@@ -16,6 +15,7 @@ class ConfigError(DvcException):
class Config(object):
CONFIG = 'config'
SECTION_GLOBAL = 'Global'
CONFIG_TEMPLATE = '''
[Global]
# Supported clouds: AWS, GCP
@@ -59,9 +59,16 @@ ProjectName =
def __init__(self, dvc_dir):
self.dvc_dir = os.path.abspath(os.path.realpath(dvc_dir))
self.config_file = os.path.join(dvc_dir, self.CONFIG)
self._config = configparser.SafeConfigParser()
self._config.read(self.config_file)
try:
self._config.read(self.config_file)
except configparser.Error as ex:
raise ConfigError(ex.message)
if not self._config.has_section(self.SECTION_GLOBAL):
raise ConfigError(u'section \'{}\' was not found'.format(self.SECTION_GLOBAL))
@staticmethod
def init(dvc_dir):
+2 -2
View File
@@ -1,8 +1,8 @@
import sys
import logging
import colorama
from dvc.config import Config
colorama.init()
@@ -26,7 +26,7 @@ class Logger(object):
def __init__(self, config=None):
if config:
level = config['Global'].get('LogLevel', None)
level = config[Config.SECTION_GLOBAL].get('LogLevel', None)
Logger.set_level(level)
@staticmethod