mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-19 07:18:27 +01:00
Config file error messages. Close #423
This commit is contained in:
@@ -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
@@ -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
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user