diff --git a/couchpotato/core/_base/_core/__init__.py b/couchpotato/core/_base/_core/__init__.py index 139c283..5ff0176 100644 --- a/couchpotato/core/_base/_core/__init__.py +++ b/couchpotato/core/_base/_core/__init__.py @@ -69,7 +69,7 @@ config = [{ { 'name': 'data_dir', 'type': 'directory', - 'description': 'Where cache/logs/etc are stored. Keep empty for ./_data.', + 'description': 'Where cache/logs/etc are stored. Keep empty for defaults.', }, { 'name': 'url_base', diff --git a/couchpotato/core/_base/_core/main.py b/couchpotato/core/_base/_core/main.py index 78a8675..df4b0f5 100644 --- a/couchpotato/core/_base/_core/main.py +++ b/couchpotato/core/_base/_core/main.py @@ -45,7 +45,7 @@ class Core(Plugin): if brk: break - time.sleep(1) + time.sleep(300) if restart: self.createFile(self.restartFilePath(), 'This is the most suckiest way to register if CP is restarted. Ever...') diff --git a/couchpotato/core/helpers/variable.py b/couchpotato/core/helpers/variable.py index 0c6cfc7..7645e80 100644 --- a/couchpotato/core/helpers/variable.py +++ b/couchpotato/core/helpers/variable.py @@ -1,7 +1,25 @@ import hashlib import os.path +import platform import re +def getDataDir(): + + # Windows + try: + from win32com.shell import shellcon, shell + return os.path.join(shell.SHGetFolderPath(0, shellcon.CSIDL_APPDATA, 0, 0), 'CouchPotato') + + except ImportError: + dir = os.path.expanduser("~") + + # OSX + if 'darwin' in platform.platform().lower(): + return os.path.join(dir, 'Library', 'Application Support', 'CouchPotato') + + # Linux + return os.path.join(dir, '.couchpotato') + def isDict(object): return isinstance(object, dict) diff --git a/couchpotato/core/plugins/base.py b/couchpotato/core/plugins/base.py index ef38d56..6903b2e 100644 --- a/couchpotato/core/plugins/base.py +++ b/couchpotato/core/plugins/base.py @@ -5,7 +5,7 @@ from couchpotato.core.logger import CPLog from couchpotato.environment import Env from flask.helpers import send_from_directory from flask.templating import render_template_string -from libs.multipartpost import MultipartPostHandler +from multipartpost import MultipartPostHandler from urlparse import urlparse import cookielib import glob diff --git a/couchpotato/runner.py b/couchpotato/runner.py index 27d1e1e..15e8ffe 100644 --- a/couchpotato/runner.py +++ b/couchpotato/runner.py @@ -2,6 +2,7 @@ from argparse import ArgumentParser from couchpotato import web from couchpotato.api import api from couchpotato.core.event import fireEventAsync +from couchpotato.core.helpers.variable import getDataDir from daemon import createDaemon from logging import handlers from werkzeug.contrib.cache import FileSystemCache @@ -11,17 +12,19 @@ import sys def getOptions(base_path, args): + data_dir = getDataDir() + # Options parser = ArgumentParser(prog = 'CouchPotato.py') - parser.add_argument('-c', '--config_file', default = os.path.join(base_path, '_data', 'settings.conf'), + 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('-t', '--test', '--debug', action = 'store_true', + parser.add_argument('--debug', action = 'store_true', dest = 'debug', help = 'Debug mode') - parser.add_argument('-q', '--quiet', action = 'store_true', - dest = 'quiet', help = "Don't log to console") - parser.add_argument('-d', '--daemon', action = 'store_true', + parser.add_argument('--console_log', action = 'store_true', + dest = 'console_log', help = "Log to console") + parser.add_argument('--daemon', action = 'store_true', dest = 'daemonize', help = 'Daemonize the app') - parser.add_argument('-g', '--nogit', action = 'store_true', + parser.add_argument('--nogit', action = 'store_true', dest = 'nogit', help = 'Running from git') options = parser.parse_args(args) @@ -41,7 +44,8 @@ def runCouchPotato(options, base_path, args): # Create data dir if needed data_dir = os.path.expanduser(Env.setting('data_dir')) if data_dir == '': - data_dir = os.path.join(base_path, '_data') + data_dir = getDataDir() + if not os.path.isdir(data_dir): os.makedirs(data_dir) @@ -63,7 +67,7 @@ def runCouchPotato(options, base_path, args): Env.set('db_path', 'sqlite:///' + os.path.join(data_dir, 'couchpotato.db')) Env.set('cache_dir', os.path.join(data_dir, 'cache')) Env.set('cache', FileSystemCache(os.path.join(Env.get('cache_dir'), 'python'))) - Env.set('quiet', options.quiet) + Env.set('console_log', options.console_log) Env.set('daemonize', options.daemonize) Env.set('args', args) Env.set('options', options) @@ -82,7 +86,7 @@ def runCouchPotato(options, base_path, args): logger.setLevel(level) # To screen - if debug and not options.quiet and not options.daemonize: + if (debug or options.console_log) and not options.daemonize: hdlr = logging.StreamHandler(sys.stderr) hdlr.setFormatter(formatter) logger.addHandler(hdlr) diff --git a/init/freebsd b/init/freebsd index c998488..770e22c 100644 --- a/init/freebsd +++ b/init/freebsd @@ -42,7 +42,7 @@ status_cmd="${name}_status" stop_cmd="${name}_stop" command="/usr/sbin/daemon" -command_args="-f -p ${couchpotato_pid} python ${couchpotato_dir}/couchpotato.py ${couchpotato_flags} --quiet" +command_args="-f -p ${couchpotato_pid} python ${couchpotato_dir}/couchpotato.py ${couchpotato_flags}" # Check for wget and refuse to start without it. if [ ! -x "${WGET}" ]; then diff --git a/init/solaris11 b/init/solaris11 index defec4c..e18b2bb 100644 --- a/init/solaris11 +++ b/init/solaris11 @@ -68,7 +68,7 @@ diff --git a/init/ubuntu b/init/ubuntu index 0b3a559..8949682 100644 --- a/init/ubuntu +++ b/init/ubuntu @@ -18,7 +18,7 @@ APP_PATH=/usr/local/sbin/couchpotato DAEMON=/usr/bin/python # startup args -DAEMON_OPTS=" CouchPotato.py -q" +DAEMON_OPTS=" CouchPotato.py" # script name NAME=couchpotato