本文整理汇总了Python中sickbeard.webserveInit.SRWebServer.shutdown方法的典型用法代码示例。如果您正苦于以下问题:Python SRWebServer.shutdown方法的具体用法?Python SRWebServer.shutdown怎么用?Python SRWebServer.shutdown使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sickbeard.webserveInit.SRWebServer
的用法示例。
在下文中一共展示了SRWebServer.shutdown方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: SickChill
# 需要导入模块: from sickbeard.webserveInit import SRWebServer [as 别名]
# 或者: from sickbeard.webserveInit.SRWebServer import shutdown [as 别名]
class SickChill(object):
# pylint: disable=too-many-instance-attributes
"""
Main SickChill 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('SickChill directory', sickbeard.PROG_DIR)
return help_msg
def start(self): # pylint: disable=too-many-branches,too-many-statements
"""
Start SickChill
"""
# 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.LOCALE_DIR = ek(os.path.join, sickbeard.PROG_DIR, 'locale')
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_module(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 SickChill folder to the PYTHONPATH environment variable\n'
'or find another way to force Python to use {} for string encoding.'.format(sickbeard.SYS_ENCODING))
# Rename the main thread
threading.currentThread().name = 'MAIN'
args = SickChillArgumentParser(sickbeard.PROG_DIR).parse_args()
if args.force_update:
result = self.force_update()
sys.exit(int(not result)) # Ok -> 0 , Error -> 1
# Need console logging for SickBeard.py and SickBeard-console.exe
sickbeard.NO_RESIZE = args.noresize
self.console_logging = (not hasattr(sys, 'frozen')) or (sickbeard.MY_NAME.lower().find('-console') > 0) and not args.quiet
self.no_launch = args.nolaunch
self.forced_port = args.port
if args.daemon:
self.run_as_daemon = platform.system() != 'Windows'
#.........这里部分代码省略.........