From c274867571b32fcfbaef04bd3869c175148dbd7e Mon Sep 17 00:00:00 2001 From: Ruud Date: Sun, 1 Jul 2012 00:43:34 +0200 Subject: [PATCH] Use settings datadir again. fix #518 --- CouchPotato.py | 3 +-- couchpotato/runner.py | 19 +++++++++++++------ 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/CouchPotato.py b/CouchPotato.py index 1c16275..21b208a 100755 --- a/CouchPotato.py +++ b/CouchPotato.py @@ -37,10 +37,9 @@ class Loader(object): # Create data dir if needed if self.options.data_dir: self.data_dir = self.options.data_dir - else: self.data_dir = os.path.expanduser(Env.setting('data_dir')) - + if self.data_dir == '': self.data_dir = getDataDir() diff --git a/couchpotato/runner.py b/couchpotato/runner.py index 5f838c7..31a8ce3 100644 --- a/couchpotato/runner.py +++ b/couchpotato/runner.py @@ -20,14 +20,12 @@ import warnings def getOptions(base_path, args): - data_dir = getDataDir() - # Options parser = ArgumentParser(prog = 'CouchPotato.py') - parser.add_argument('--config_file', default = os.path.join(data_dir, 'settings.conf'), - dest = 'config_file', help = 'Absolute or ~/ path of the settings file (default ./_data/settings.conf)') - parser.add_argument('--data_dir', default = data_dir, + parser.add_argument('--data_dir', dest = 'data_dir', help = 'Absolute or ~/ path of the data dir') + parser.add_argument('--config_file', + dest = 'config_file', help = 'Absolute or ~/ path of the settings file (default DATA_DIR/settings.conf)') parser.add_argument('--debug', action = 'store_true', dest = 'debug', help = 'Debug mode') parser.add_argument('--console_log', action = 'store_true', @@ -36,12 +34,21 @@ def getOptions(base_path, args): dest = 'quiet', help = 'No console logging') parser.add_argument('--daemon', action = 'store_true', dest = 'daemon', help = 'Daemonize the app') - parser.add_argument('--pid_file', default = os.path.join(data_dir, 'couchpotato.pid'), + parser.add_argument('--pid_file', dest = 'pid_file', help = 'Path to pidfile needed for daemon') options = parser.parse_args(args) + data_dir = os.path.expanduser(options.data_dir if options.data_dir else getDataDir()) + + if not options.config_file: + options.config_file = os.path.join(data_dir, 'settings.conf') + + if not options.pid_file: + options.pid_file = os.path.join(data_dir, 'couchpotato.pid') + options.config_file = os.path.expanduser(options.config_file) + options.pid_file = os.path.expanduser(options.pid_file) return options