From 852070d2efca79106853ac9422d2fb5743f88d66 Mon Sep 17 00:00:00 2001 From: Andre Anjos <andre.anjos@idiap.ch> Date: Wed, 21 Aug 2019 09:14:56 +0200 Subject: [PATCH] [dav] Rename config file as ~/.bdtrc --- bob/devtools/dav.py | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/bob/devtools/dav.py b/bob/devtools/dav.py index 7a3578f9..3145ad84 100644 --- a/bob/devtools/dav.py +++ b/bob/devtools/dav.py @@ -2,8 +2,11 @@ # -*- coding: utf-8 -*- import os +import re import configparser +from distutils.version import StrictVersion + from .log import get_logger, echo_warning, echo_info from .deploy import _setup_webdav_client @@ -13,25 +16,25 @@ logger = get_logger(__name__) def _get_config(): """Returns a dictionary with server parameters, or ask them to the user""" - # tries to figure if we can authenticate using a global configuration - cfgs = ["~/.bdt-webdav.cfg"] + # tries to figure if we can authenticate using a configuration file + cfgs = ["~/.bdt.cfg"] cfgs = [os.path.expanduser(k) for k in cfgs] for k in cfgs: if os.path.exists(k): data = configparser.ConfigParser() data.read(k) if ( - "global" not in data - or "server" not in data["global"] - or "username" not in data["global"] - or "password" not in data["global"] + "webdav" not in data + or "server" not in data["webdav"] + or "username" not in data["webdav"] + or "password" not in data["webdav"] ): assert KeyError, ( "The file %s should contain a single " - '"global" section with 3 variables defined inside: ' + '"dav" section with 3 variables defined inside: ' '"server", "username", "password".' % (k,) ) - return data["global"] + return data["dav"] # ask the user for the information, cache credentials for future use retval = dict() @@ -41,7 +44,7 @@ def _get_config(): # record file for the user data = configparser.ConfigParser() - data["global"] = retval + data["webdav"] = retval with open(cfgs[0], "w") as f: logger.warn('Recorded "%s" configuration file for next queries') data.write(f) @@ -124,7 +127,7 @@ def remove_old_beta_packages(client, path, dry_run, pyver=True): if result is not None: name += "/" + result.string[:4] - target = '/'.join(path, f) + target = '/'.join((path, f)) info = client.info(target) betas.setdefault(name, []).append( -- GitLab