本文整理汇总了Python中sickbeard.webserveInit.SRWebServer.start方法的典型用法代码示例。如果您正苦于以下问题:Python SRWebServer.start方法的具体用法?Python SRWebServer.start怎么用?Python SRWebServer.start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sickbeard.webserveInit.SRWebServer
的用法示例。
在下文中一共展示了SRWebServer.start方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: SickRage
# 需要导入模块: from sickbeard.webserveInit import SRWebServer [as 别名]
# 或者: from sickbeard.webserveInit.SRWebServer import start [as 别名]
class SickRage(object):
# pylint: disable=too-many-instance-attributes
"""
Main SickRage module
"""
def __init__(self):
# system event callback for shutdown/restart
sickbeard.events = Events(self.shutdown)
# daemon constants
self.run_as_daemon = False
self.create_pid = False
self.pid_file = ''
# web server constants
self.web_server = None
self.forced_port = None
self.no_launch = False
self.web_host = '0.0.0.0'
self.start_port = sickbeard.WEB_PORT
self.web_options = {}
self.log_dir = None
self.console_logging = True
@staticmethod
def clear_cache():
"""
Remove the Mako cache directory
"""
try:
cache_folder = ek(os.path.join, sickbeard.CACHE_DIR, 'mako')
if os.path.isdir(cache_folder):
shutil.rmtree(cache_folder)
except Exception: # pylint: disable=broad-except
logger.log('Unable to remove the cache/mako directory!', logger.WARNING)
@staticmethod
def help_message():
"""
Print help message for commandline options
"""
help_msg = __doc__
help_msg = help_msg.replace('SickBeard.py', sickbeard.MY_FULLNAME)
help_msg = help_msg.replace('SickRage directory', sickbeard.PROG_DIR)
return help_msg
def start(self): # pylint: disable=too-many-branches,too-many-statements
"""
Start SickRage
"""
# do some preliminary stuff
sickbeard.MY_FULLNAME = ek(os.path.normpath, ek(os.path.abspath, __file__))
sickbeard.MY_NAME = ek(os.path.basename, sickbeard.MY_FULLNAME)
sickbeard.PROG_DIR = ek(os.path.dirname, sickbeard.MY_FULLNAME)
sickbeard.DATA_DIR = sickbeard.PROG_DIR
sickbeard.MY_ARGS = sys.argv[1:]
try:
locale.setlocale(locale.LC_ALL, '')
sickbeard.SYS_ENCODING = locale.getpreferredencoding()
except (locale.Error, IOError):
sickbeard.SYS_ENCODING = 'UTF-8'
# pylint: disable=no-member
if not sickbeard.SYS_ENCODING or sickbeard.SYS_ENCODING.lower() in ('ansi_x3.4-1968', 'us-ascii', 'ascii', 'charmap') or \
(sys.platform.startswith('win') and sys.getwindowsversion()[0] >= 6 and str(getattr(sys.stdout, 'device', sys.stdout).encoding).lower() in ('cp65001', 'charmap')):
sickbeard.SYS_ENCODING = 'UTF-8'
# TODO: Continue working on making this unnecessary, this hack creates all sorts of hellish problems
if not hasattr(sys, 'setdefaultencoding'):
reload(sys)
try:
# On non-unicode builds this will raise an AttributeError, if encoding type is not valid it throws a LookupError
sys.setdefaultencoding(sickbeard.SYS_ENCODING) # pylint: disable=no-member
except (AttributeError, LookupError):
sys.exit('Sorry, you MUST add the SickRage folder to the PYTHONPATH environment variable\n'
'or find another way to force Python to use %s for string encoding.' % sickbeard.SYS_ENCODING)
# Need console logging for SickBeard.py and SickBeard-console.exe
self.console_logging = (not hasattr(sys, 'frozen')) or (sickbeard.MY_NAME.lower().find('-console') > 0)
# Rename the main thread
threading.currentThread().name = 'MAIN'
try:
opts, _ = getopt.getopt(
sys.argv[1:], 'hqdp::',
['help', 'quiet', 'nolaunch', 'daemon', 'pidfile=', 'port=', 'datadir=', 'config=', 'noresize']
)
except getopt.GetoptError:
sys.exit(self.help_message())
for option, value in opts:
# Prints help message
if option in ('-h', '--help'):
#.........这里部分代码省略.........
示例2: SickRage
# 需要导入模块: from sickbeard.webserveInit import SRWebServer [as 别名]
# 或者: from sickbeard.webserveInit.SRWebServer import start [as 别名]
class SickRage(object):
# pylint: disable=too-many-instance-attributes
# Too many instance attributes
def __init__(self):
# system event callback for shutdown/restart
sickbeard.events = Events(self.shutdown)
# daemon constants
self.runAsDaemon = False
self.CREATEPID = False
self.PIDFILE = ''
# webserver constants
self.webserver = None
self.forcedPort = None
self.noLaunch = False
self.webhost = '0.0.0.0'
self.startPort = sickbeard.WEB_PORT
self.web_options = {}
self.log_dir = None
self.consoleLogging = True
@staticmethod
def help_message():
"""
print help message for commandline options
"""
help_msg = "\n"
help_msg += "Usage: " + sickbeard.MY_FULLNAME + " <option> <another option>\n"
help_msg += "\n"
help_msg += "Options:\n"
help_msg += "\n"
help_msg += " -h --help Prints this message\n"
help_msg += " -q --quiet Disables logging to console\n"
help_msg += " --nolaunch Suppress launching web browser on startup\n"
if sys.platform == 'win32' or sys.platform == 'darwin':
help_msg += " -d --daemon Running as real daemon is not supported on Windows\n"
help_msg += " On Windows and MAC, --daemon is substituted with: --quiet --nolaunch\n"
else:
help_msg += " -d --daemon Run as double forked daemon (includes options --quiet --nolaunch)\n"
help_msg += " --pidfile=<path> Combined with --daemon creates a pidfile (full path including filename)\n"
help_msg += " -p <port> --port=<port> Override default/configured port to listen on\n"
help_msg += " --datadir=<path> Override folder (full path) as location for\n"
help_msg += " storing database, configfile, cache, logfiles \n"
help_msg += " Default: " + sickbeard.PROG_DIR + "\n"
help_msg += " --config=<path> Override config filename (full path including filename)\n"
help_msg += " to load configuration from \n"
help_msg += " Default: config.ini in " + sickbeard.PROG_DIR + " or --datadir location\n"
help_msg += " --noresize Prevent resizing of the banner/posters even if PIL is installed\n"
return help_msg
# pylint: disable=too-many-branches,too-many-statements
# Too many branches
# Too many statements
def start(self):
# do some preliminary stuff
sickbeard.MY_FULLNAME = ek(os.path.normpath, ek(os.path.abspath, __file__))
sickbeard.MY_NAME = ek(os.path.basename, sickbeard.MY_FULLNAME)
sickbeard.PROG_DIR = ek(os.path.dirname, sickbeard.MY_FULLNAME)
sickbeard.DATA_DIR = sickbeard.PROG_DIR
sickbeard.MY_ARGS = sys.argv[1:]
try:
locale.setlocale(locale.LC_ALL, "")
sickbeard.SYS_ENCODING = locale.getpreferredencoding()
except (locale.Error, IOError):
sickbeard.SYS_ENCODING = 'UTF-8'
# pylint: disable=no-member
if not sickbeard.SYS_ENCODING or sickbeard.SYS_ENCODING.lower() in ('ansi_x3.4-1968', 'us-ascii', 'ascii', 'charmap') or \
(sys.platform.startswith('win') and sys.getwindowsversion()[0] >= 6 and str(getattr(sys.stdout, 'device', sys.stdout).encoding).lower() in ('cp65001', 'charmap')):
sickbeard.SYS_ENCODING = 'UTF-8'
# TODO: Continue working on making this unnecessary, this hack creates all sorts of hellish problems
if not hasattr(sys, "setdefaultencoding"):
reload(sys)
try:
# pylint: disable=no-member
# On non-unicode builds this will raise an AttributeError, if encoding type is not valid it throws a LookupError
sys.setdefaultencoding(sickbeard.SYS_ENCODING)
except Exception:
sys.exit("Sorry, you MUST add the SickRage folder to the PYTHONPATH environment variable\n" +
"or find another way to force Python to use " + sickbeard.SYS_ENCODING + " for string encoding.")
# Need console logging for SickBeard.py and SickBeard-console.exe
self.consoleLogging = (not hasattr(sys, "frozen")) or (sickbeard.MY_NAME.lower().find('-console') > 0)
# Rename the main thread
threading.currentThread().name = u"MAIN"
try:
opts, _ = getopt.getopt(
sys.argv[1:], "hqdp::",
['help', 'quiet', 'nolaunch', 'daemon', 'pidfile=', 'port=', 'datadir=', 'config=', 'noresize']
#.........这里部分代码省略.........
示例3: SickRage
# 需要导入模块: from sickbeard.webserveInit import SRWebServer [as 别名]
# 或者: from sickbeard.webserveInit.SRWebServer import start [as 别名]
class SickRage(object):
def __init__(self):
# signal and event handlers
signal.signal(signal.SIGINT, sickbeard.sig_handler)
signal.signal(signal.SIGTERM, sickbeard.sig_handler)
sickbeard.events = Events(self.shutdown)
# daemon constants
self.runAsDaemon = False
self.CREATEPID = False
self.PIDFILE = ''
# webserver constants
self.webserver = None
self.forcedPort = None
self.noLaunch = False
self.webhost = '0.0.0.0'
self.startPort = sickbeard.WEB_PORT
self.web_options = {}
self.log_dir = None
self.consoleLogging = True
@staticmethod
def help_message():
"""
print help message for commandline options
"""
help_msg = "\n"
help_msg += "Usage: " + sickbeard.MY_FULLNAME + " <option> <another option>\n"
help_msg += "\n"
help_msg += "Options:\n"
help_msg += "\n"
help_msg += " -h --help Prints this message\n"
help_msg += " -q --quiet Disables logging to console\n"
help_msg += " --nolaunch Suppress launching web browser on startup\n"
if sys.platform == 'win32' or sys.platform == 'darwin':
help_msg += " -d --daemon Running as real daemon is not supported on Windows\n"
help_msg += " On Windows and MAC, --daemon is substituted with: --quiet --nolaunch\n"
else:
help_msg += " -d --daemon Run as double forked daemon (includes options --quiet --nolaunch)\n"
help_msg += " --pidfile=<path> Combined with --daemon creates a pidfile (full path including filename)\n"
help_msg += " -p <port> --port=<port> Override default/configured port to listen on\n"
help_msg += " --datadir=<path> Override folder (full path) as location for\n"
help_msg += " storing database, configfile, cache, logfiles \n"
help_msg += " Default: " + sickbeard.PROG_DIR + "\n"
help_msg += " --config=<path> Override config filename (full path including filename)\n"
help_msg += " to load configuration from \n"
help_msg += " Default: config.ini in " + sickbeard.PROG_DIR + " or --datadir location\n"
help_msg += " --noresize Prevent resizing of the banner/posters even if PIL is installed\n"
return help_msg
def start(self):
# map the following codecs to utf-8
codecs.register(lambda name: codecs.lookup('utf-8') if name == 'cp65001' else None)
codecs.register(lambda name: codecs.lookup('utf-8') if name == 'cp1252' else None)
# get locale encoding
try:
locale.setlocale(locale.LC_ALL, "")
sickbeard.SYS_ENCODING = locale.getpreferredencoding()
except (locale.Error, IOError):
sickbeard.SYS_ENCODING = None
# enforce UTF-8
if not sickbeard.SYS_ENCODING or codecs.lookup(sickbeard.SYS_ENCODING).name == 'ascii':
sickbeard.SYS_ENCODING = 'UTF-8'
# do some preliminary stuff
sickbeard.MY_FULLNAME = ek(os.path.normpath, ek(os.path.abspath,__file__))
sickbeard.MY_NAME = ek(os.path.basename, sickbeard.MY_FULLNAME)
sickbeard.PROG_DIR = ek(os.path.dirname, sickbeard.MY_FULLNAME)
sickbeard.DATA_DIR = sickbeard.PROG_DIR
sickbeard.MY_ARGS = sys.argv[1:]
# Need console logging for SickBeard.py and SickBeard-console.exe
self.consoleLogging = (not hasattr(sys, "frozen")) or (sickbeard.MY_NAME.lower().find('-console') > 0)
# Rename the main thread
threading.currentThread().name = u"MAIN"
# Do this before importing sickbeard, to prevent locked files and incorrect import
oldtornado = ek(os.path.abspath, ek(os.path.join, ek(os.path.dirname, __file__), 'tornado'))
if ek(os.path.isdir, oldtornado):
ek(shutil.move, oldtornado, oldtornado + '_kill')
ek(removetree, oldtornado + '_kill')
try:
opts, _ = getopt.getopt(
sys.argv[1:], "hqdp::",
['help', 'quiet', 'nolaunch', 'daemon', 'pidfile=', 'port=', 'datadir=', 'config=', 'noresize']
)
except getopt.GetoptError:
sys.exit(self.help_message())
for o, a in opts:
#.........这里部分代码省略.........
示例4: SickRage
# 需要导入模块: from sickbeard.webserveInit import SRWebServer [as 别名]
# 或者: from sickbeard.webserveInit.SRWebServer import start [as 别名]
class SickRage(object):
# pylint: disable=R0902
def __init__(self):
# system event callback for shutdown/restart
sickbeard.events = Events(self.shutdown)
# daemon constants
self.runAsDaemon = False
self.CREATEPID = False
self.PIDFILE = ''
# webserver constants
self.webserver = None
self.forcedPort = None
self.noLaunch = False
self.webhost = '0.0.0.0'
self.startPort = sickbeard.WEB_PORT
self.web_options = {}
self.log_dir = None
self.consoleLogging = True
@staticmethod
def help_message():
"""
print help message for commandline options
"""
help_msg = "\n"
help_msg += "Usage: " + sickbeard.MY_FULLNAME + " <option> <another option>\n"
help_msg += "\n"
help_msg += "Options:\n"
help_msg += "\n"
help_msg += " -h --help Prints this message\n"
help_msg += " -q --quiet Disables logging to console\n"
help_msg += " --nolaunch Suppress launching web browser on startup\n"
if sys.platform == 'win32' or sys.platform == 'darwin':
help_msg += " -d --daemon Running as real daemon is not supported on Windows\n"
help_msg += " On Windows and MAC, --daemon is substituted with: --quiet --nolaunch\n"
else:
help_msg += " -d --daemon Run as double forked daemon (includes options --quiet --nolaunch)\n"
help_msg += " --pidfile=<path> Combined with --daemon creates a pidfile (full path including filename)\n"
help_msg += " -p <port> --port=<port> Override default/configured port to listen on\n"
help_msg += " --datadir=<path> Override folder (full path) as location for\n"
help_msg += " storing database, configfile, cache, logfiles \n"
help_msg += " Default: " + sickbeard.PROG_DIR + "\n"
help_msg += " --config=<path> Override config filename (full path including filename)\n"
help_msg += " to load configuration from \n"
help_msg += " Default: config.ini in " + sickbeard.PROG_DIR + " or --datadir location\n"
help_msg += " --noresize Prevent resizing of the banner/posters even if PIL is installed\n"
return help_msg
@staticmethod
def fix_clients_nonsense():
filenames = [
"sickbeard/clients/download_station.py",
"sickbeard/clients/utorrent.py",
"sickbeard/clients/qbittorrent.py",
"sickbeard/clients/transmission.py",
"sickbeard/clients/deluge.py",
"sickbeard/clients/deluged.py",
"sickbeard/clients/rtorrent.py"
]
for filename in filenames:
filename = ek(os.path.join, sickbeard.PROG_DIR, filename)
try:
if ek(os.path.exists, filename):
ek(os.remove, filename)
except Exception:
pass
try:
if ek(os.path.exists, filename + "c"):
ek(os.remove, filename + "c")
except Exception:
pass
# pylint: disable=R0912,R0915
def start(self):
# do some preliminary stuff
sickbeard.MY_FULLNAME = os.path.normpath(os.path.abspath(__file__))
sickbeard.MY_NAME = os.path.basename(sickbeard.MY_FULLNAME)
sickbeard.PROG_DIR = os.path.dirname(sickbeard.MY_FULLNAME)
sickbeard.DATA_DIR = sickbeard.PROG_DIR
sickbeard.MY_ARGS = sys.argv[1:]
sickbeard.SYS_ENCODING = None
try:
locale.setlocale(locale.LC_ALL, "")
sickbeard.SYS_ENCODING = locale.getpreferredencoding()
except (locale.Error, IOError):
pass
# For OSes that are poorly configured I'll just randomly force UTF-8
if not sickbeard.SYS_ENCODING or sickbeard.SYS_ENCODING in ('ANSI_X3.4-1968', 'US-ASCII', 'ASCII'):
#.........这里部分代码省略.........
示例5: SickRage
# 需要导入模块: from sickbeard.webserveInit import SRWebServer [as 别名]
# 或者: from sickbeard.webserveInit.SRWebServer import start [as 别名]
class SickRage(object):
# pylint: disable=too-many-instance-attributes
"""
Main SickRage module
"""
def __init__(self):
# system event callback for shutdown/restart
sickbeard.events = Events(self.shutdown)
# daemon constants
self.run_as_daemon = False
self.create_pid = False
self.pid_file = ""
# web server constants
self.web_server = None
self.forced_port = None
self.no_launch = False
self.web_host = "0.0.0.0"
self.start_port = sickbeard.WEB_PORT
self.web_options = {}
self.log_dir = None
self.console_logging = True
@staticmethod
def clear_cache():
"""
Remove the Mako cache directory
"""
try:
cache_folder = ek(os.path.join, sickbeard.CACHE_DIR, "mako")
if os.path.isdir(cache_folder):
shutil.rmtree(cache_folder)
except Exception: # pylint: disable=broad-except
logger.log("Unable to remove the cache/mako directory!", logger.WARNING) # pylint: disable=no-member
@staticmethod
def help_message():
"""
Print help message for commandline options
"""
help_msg = __doc__
help_msg = help_msg.replace("SickBeard.py", sickbeard.MY_FULLNAME)
help_msg = help_msg.replace("SickRage directory", sickbeard.PROG_DIR)
return help_msg
def start(self): # pylint: disable=too-many-branches,too-many-statements
"""
Start SickRage
"""
# do some preliminary stuff
sickbeard.MY_FULLNAME = ek(os.path.normpath, ek(os.path.abspath, __file__))
sickbeard.MY_NAME = ek(os.path.basename, sickbeard.MY_FULLNAME)
sickbeard.PROG_DIR = ek(os.path.dirname, sickbeard.MY_FULLNAME)
sickbeard.DATA_DIR = sickbeard.PROG_DIR
sickbeard.MY_ARGS = sys.argv[1:]
try:
locale.setlocale(locale.LC_ALL, "")
sickbeard.SYS_ENCODING = locale.getpreferredencoding()
except (locale.Error, IOError):
sickbeard.SYS_ENCODING = "UTF-8"
# pylint: disable=no-member
if (
not sickbeard.SYS_ENCODING
or sickbeard.SYS_ENCODING.lower() in ("ansi_x3.4-1968", "us-ascii", "ascii", "charmap")
or (
sys.platform.startswith("win")
and sys.getwindowsversion()[0] >= 6
and str(getattr(sys.stdout, "device", sys.stdout).encoding).lower() in ("cp65001", "charmap")
)
):
sickbeard.SYS_ENCODING = "UTF-8"
# TODO: Continue working on making this unnecessary, this hack creates all sorts of hellish problems
if not hasattr(sys, "setdefaultencoding"):
reload(sys)
try:
# On non-unicode builds this will raise an AttributeError, if encoding type is not valid it throws a LookupError
sys.setdefaultencoding(sickbeard.SYS_ENCODING) # pylint: disable=no-member
except (AttributeError, LookupError):
sys.exit(
"Sorry, you MUST add the SickRage folder to the PYTHONPATH environment variable\n"
"or find another way to force Python to use %s for string encoding." % sickbeard.SYS_ENCODING
)
# Need console logging for SickBeard.py and SickBeard-console.exe
self.console_logging = (not hasattr(sys, "frozen")) or (sickbeard.MY_NAME.lower().find("-console") > 0)
# Rename the main thread
threading.currentThread().name = "MAIN"
try:
opts, _ = getopt.getopt(
#.........这里部分代码省略.........
示例6: SickRage
# 需要导入模块: from sickbeard.webserveInit import SRWebServer [as 别名]
# 或者: from sickbeard.webserveInit.SRWebServer import start [as 别名]
class SickRage(object):
# pylint: disable=R0902
# Too many instance attributes
def __init__(self):
# system event callback for shutdown/restart
sickbeard.events = Events(self.shutdown)
# daemon constants
self.runAsDaemon = False
self.CREATEPID = False
self.PIDFILE = ""
# webserver constants
self.webserver = None
self.forcedPort = None
self.noLaunch = False
self.webhost = "0.0.0.0"
self.startPort = sickbeard.WEB_PORT
self.web_options = {}
self.log_dir = None
self.consoleLogging = True
@staticmethod
def help_message():
"""
print help message for commandline options
"""
help_msg = "\n"
help_msg += "Usage: " + sickbeard.MY_FULLNAME + " <option> <another option>\n"
help_msg += "\n"
help_msg += "Options:\n"
help_msg += "\n"
help_msg += " -h --help Prints this message\n"
help_msg += " -q --quiet Disables logging to console\n"
help_msg += " --nolaunch Suppress launching web browser on startup\n"
if sys.platform == "win32" or sys.platform == "darwin":
help_msg += " -d --daemon Running as real daemon is not supported on Windows\n"
help_msg += " On Windows and MAC, --daemon is substituted with: --quiet --nolaunch\n"
else:
help_msg += " -d --daemon Run as double forked daemon (includes options --quiet --nolaunch)\n"
help_msg += " --pidfile=<path> Combined with --daemon creates a pidfile (full path including filename)\n"
help_msg += " -p <port> --port=<port> Override default/configured port to listen on\n"
help_msg += " --datadir=<path> Override folder (full path) as location for\n"
help_msg += " storing database, configfile, cache, logfiles \n"
help_msg += " Default: " + sickbeard.PROG_DIR + "\n"
help_msg += " --config=<path> Override config filename (full path including filename)\n"
help_msg += " to load configuration from \n"
help_msg += (
" Default: config.ini in "
+ sickbeard.PROG_DIR
+ " or --datadir location\n"
)
help_msg += (
" --noresize Prevent resizing of the banner/posters even if PIL is installed\n"
)
return help_msg
# pylint: disable=R0912,R0915
# Too many branches
# Too many statements
def start(self):
# do some preliminary stuff
sickbeard.MY_FULLNAME = os.path.normpath(os.path.abspath(__file__))
sickbeard.MY_NAME = os.path.basename(sickbeard.MY_FULLNAME)
sickbeard.PROG_DIR = os.path.dirname(sickbeard.MY_FULLNAME)
sickbeard.DATA_DIR = sickbeard.PROG_DIR
sickbeard.MY_ARGS = sys.argv[1:]
try:
locale.setlocale(locale.LC_ALL, "")
sickbeard.SYS_ENCODING = locale.getpreferredencoding()
except (locale.Error, IOError):
sickbeard.SYS_ENCODING = "UTF-8"
# pylint: disable=E1101
if (
not sickbeard.SYS_ENCODING
or sickbeard.SYS_ENCODING.lower() in ("ansi_x3.4-1968", "us-ascii", "ascii", "charmap")
or (
sys.platform.startswith("win")
and sys.getwindowsversion()[0] >= 6
and getattr(sys.stdout, "device", sys.stdout).encoding.lower() in ("cp65001", "charmap")
)
):
sickbeard.SYS_ENCODING = "UTF-8"
# TODO: Continue working on making this unnecessary, this hack creates all sorts of hellish problems
if not hasattr(sys, "setdefaultencoding"):
reload(sys)
try:
# pylint: disable=E1101
# On non-unicode builds this will raise an AttributeError, if encoding type is not valid it throws a LookupError
sys.setdefaultencoding(sickbeard.SYS_ENCODING)
except Exception:
#.........这里部分代码省略.........