Commit f2babb12 authored by Julien Muchembled's avatar Julien Muchembled

Expand ~(user) construction for all paths in configuration

Before, it was only done for 'logfile'.
parent 57481c35
......@@ -5,6 +5,9 @@
# See SafeConfigParser at https://docs.python.org/2/library/configparser.html
# for more information about the syntax.
# ~ and ~user constructions are expanded for all paths, even for those that
# may appear in 'database' option.
# Common parameters.
[DEFAULT]
# The cluster name
......@@ -54,7 +57,7 @@ partitions: 12
[admin]
bind: 127.0.0.1:9999
# Paths to log files can be specified here, but be careful not to do it in a
# common section. ~ and ~user constructions are expanded.
# common section.
;logfile: ~/log/admin.log
# Master nodes
......
......@@ -102,7 +102,7 @@ class ConfigurationManager(object):
return self.__get('wait')
def getDynamicMasterList(self):
return self.__get('dynamic_master_list', optional=True)
return self.__getPath('dynamic_master_list', optional=True)
def getAdapter(self):
return self.__get('adapter')
......
......@@ -14,6 +14,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import os
import cPickle, pickle, time
from bisect import bisect, insort
from collections import deque
......@@ -286,7 +287,7 @@ class ImporterDatabaseManager(DatabaseManager):
def _parse(self, database):
config = SafeConfigParser()
config.read(database)
config.read(os.path.expanduser(database))
sections = config.sections()
# XXX: defaults copy & pasted from elsewhere - refactoring needed
main = {'adapter': 'MySQL', 'wait': 0}
......
......@@ -21,6 +21,7 @@ from MySQLdb.constants.CR import SERVER_GONE_ERROR, SERVER_LOST
from MySQLdb.constants.ER import DATA_TOO_LONG, DUP_ENTRY
from array import array
from hashlib import sha1
import os
import re
import string
import struct
......@@ -57,9 +58,9 @@ class MySQLDatabaseManager(DatabaseManager):
def _parse(self, database):
""" Get the database credentials (username, password, database) """
# expected pattern : [user[:password]@]database[(.|/)unix_socket]
# expected pattern : [user[:password]@]database[(~|.|/)unix_socket]
self.user, self.passwd, self.db, self.socket = re.match(
'(?:([^:]+)(?::(.*))?@)?([^./]+)(.+)?$', database).groups()
'(?:([^:]+)(?::(.*))?@)?([^~./]+)(.+)?$', database).groups()
def close(self):
self.conn.close()
......@@ -69,7 +70,7 @@ class MySQLDatabaseManager(DatabaseManager):
if self.passwd is not None:
kwd['passwd'] = self.passwd
if self.socket:
kwd['unix_socket'] = self.socket
kwd['unix_socket'] = os.path.expanduser(self.socket)
logging.info('connecting to MySQL on the database %s with user %s',
self.db, self.user)
if self._wait < 0:
......
......@@ -14,6 +14,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import os
import sqlite3
from hashlib import sha1
import string
......@@ -70,7 +71,7 @@ class SQLiteDatabaseManager(DatabaseManager):
self._connect()
def _parse(self, database):
self.db = database
self.db = os.path.expanduser(database)
def close(self):
self.conn.close()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment