本文整理匯總了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'
#.........這裏部分代碼省略.........