X-Git-Url: https://git.kaliko.me/?a=blobdiff_plain;f=sima%2Futils%2Fconfig.py;h=1df4e9e5eb430c013f62a19b8eb12192c7325e82;hb=eead40921859927953e73327840bd6ff090b77fe;hp=a46c0c66493e3519ab1af41cefe7d88e8087ddbf;hpb=d67a78c3f86751a551b370c32aaf3934e772825f;p=mpd-sima.git diff --git a/sima/utils/config.py b/sima/utils/config.py index a46c0c6..1df4e9e 100644 --- a/sima/utils/config.py +++ b/sima/utils/config.py @@ -17,7 +17,6 @@ # You should have received a copy of the GNU General Public License # along with sima. If not, see . # -# pylint: disable=bad-continuation """ Deal with configuration and data files. @@ -30,7 +29,7 @@ import logging import sys from configparser import Error -from os import (access, makedirs, environ, stat, chmod, W_OK) +from os import (access, makedirs, getenv, stat, chmod, W_OK) from os.path import (join, isdir, isfile, dirname, exists) from stat import (S_IMODE, ST_MODE, S_IRWXO, S_IRWXG) @@ -72,7 +71,7 @@ DEFAULT_CONF = { }, 'lastfm': { 'queue_mode': "track", # TODO control values - 'max_art': 10, + 'max_art': 20, 'single_album': False, 'track_to_add': 1, 'album_to_add': 1, @@ -144,9 +143,6 @@ class ConfMan: # CONFIG MANAGER CLASS self.supersedes_config_with_cmd_line_options() # set dbfile self.config['sima']['db_file'] = join(self.config['sima']['var_dir'], 'sima.db') - # Controls files access - self.control_facc() - # Create directories data_dir = self.config['sima']['var_dir'] if not isdir(data_dir): @@ -154,6 +150,9 @@ class ConfMan: # CONFIG MANAGER CLASS makedirs(data_dir) chmod(data_dir, 0o700) + # Controls files access + self.control_facc() + def control_facc(self): """Controls file access. This is relevant only for file provided through the configuration file @@ -190,10 +189,8 @@ class ConfMan: # CONFIG MANAGER CLASS self.log.debug('file permission is: %o', mode) if mode & S_IRWXO or mode & S_IRWXG: self.log.warning('File is readable by "other" and/or' + - ' "group" (actual permission %o octal).' % - mode) - self.log.warning('Consider setting permissions' + - ' to 600 octal.') + ' "group" (actual permission %o octal).', mode) + self.log.warning('Consider setting permissions to 600 octal.') def supersedes_config_with_cmd_line_options(self): """Updates defaults settings with command line options""" @@ -230,10 +227,10 @@ class ConfMan: # CONFIG MANAGER CLASS http://standards.freedesktop.org/basedir-spec/basedir-spec-0.6.html """ - homedir = environ.get('HOME') + homedir = getenv('HOME') - if environ.get('XDG_DATA_HOME'): - data_dir = join(environ.get('XDG_DATA_HOME'), DIRNAME) + if getenv('XDG_DATA_HOME'): + data_dir = join(getenv('XDG_DATA_HOME'), DIRNAME) elif homedir and isdir(homedir) and homedir not in ['/']: data_dir = join(homedir, '.local', 'share', DIRNAME) else: @@ -244,8 +241,8 @@ class ConfMan: # CONFIG MANAGER CLASS if self.startopt.get('conf_file'): # No need to handle conf file location pass - elif environ.get('XDG_CONFIG_HOME'): - conf_dir = join(environ.get('XDG_CONFIG_HOME'), DIRNAME) + elif getenv('XDG_CONFIG_HOME'): + conf_dir = join(getenv('XDG_CONFIG_HOME'), DIRNAME) self.conf_file = join(conf_dir, CONF_FILE) elif homedir and isdir(homedir) and homedir not in ['/']: conf_dir = join(homedir, '.config', DIRNAME)