mirror of
https://github.com/logos-storage/deluge.git
synced 2026-05-28 20:29:33 +00:00
Selected Warning messages disabled in pylintrc: * unused-argument: Quite a large and disruptive change if enabled. * broad-except: Most required in-depth investigation to determine type. * fixme: Not important * protected-access: Complicated to fix * import-error: Too many false-positives * unidiomatic-typecheck: Should be fixed in the next round of checks. * unused-variable: Again large and disruptive changes. * global-statement: Most usage is required. * attribute-defined-outside-init: Should be fixed in next round of checks. * arguments-differ: Possible false-positives, needs revisited. * no-init, non-parent-init-called, super-init-not-called: False-positives? * signature-differs: False-positives?
68 lines
2.1 KiB
Python
68 lines
2.1 KiB
Python
import os
|
|
import sys
|
|
import tempfile
|
|
import time
|
|
from subprocess import PIPE, Popen
|
|
|
|
from twisted.internet.error import CannotListenError
|
|
|
|
import deluge.common
|
|
import deluge.configmanager
|
|
import deluge.core.preferencesmanager
|
|
import deluge.log
|
|
|
|
deluge.log.setup_logger("none")
|
|
|
|
|
|
def disable_new_release_check():
|
|
deluge.core.preferencesmanager.DEFAULT_PREFS["new_release_check"] = False
|
|
|
|
|
|
def set_tmp_config_dir():
|
|
config_directory = tempfile.mkdtemp()
|
|
deluge.configmanager.set_config_dir(config_directory)
|
|
return config_directory
|
|
|
|
|
|
def rpath(*args):
|
|
return os.path.join(os.path.dirname(__file__), *args)
|
|
|
|
# Initialize gettext
|
|
deluge.common.setup_translations()
|
|
|
|
|
|
def start_core(listen_port=58846):
|
|
cwd = os.path.dirname(os.path.dirname(os.path.dirname(__file__)))
|
|
daemon_script = """
|
|
import sys
|
|
import deluge.main
|
|
|
|
sys.argv.extend(['-d', '-c', '%s', '-L', 'info', '-p', '%d'])
|
|
|
|
deluge.main.start_daemon()
|
|
"""
|
|
config_directory = set_tmp_config_dir()
|
|
fp = tempfile.TemporaryFile()
|
|
fp.write(daemon_script % (config_directory, listen_port))
|
|
fp.seek(0)
|
|
|
|
core = Popen([sys.executable], cwd=cwd, stdin=fp, stdout=PIPE, stderr=PIPE)
|
|
while True:
|
|
line = core.stderr.readline()
|
|
if "starting on %d" % listen_port in line:
|
|
time.sleep(0.3) # Slight pause just incase
|
|
break
|
|
elif "Couldn't listen on localhost:%d" % listen_port in line:
|
|
raise CannotListenError("localhost", listen_port, "Could not start deluge test client: %s" % line)
|
|
elif 'Traceback' in line:
|
|
raise SystemExit(
|
|
"Failed to start core daemon. Do \"\"\" %s \"\"\" to see what's "
|
|
"happening" %
|
|
"python -c \"import sys; import tempfile; import deluge.main; "
|
|
"import deluge.configmanager; config_directory = tempfile.mkdtemp(); "
|
|
"deluge.configmanager.set_config_dir(config_directory); "
|
|
"sys.argv.extend(['-d', '-c', config_directory, '-L', 'info']); "
|
|
"deluge.main.start_daemon()\""
|
|
)
|
|
return core
|