mirror of
https://github.com/SickGear/SickGear.git
synced 2025-01-05 17:43:37 +00:00
Change improve handling of SIGINT CTRL+C, SIGINT CTRL+BREAK(Windows) and SIGTERM.
This commit is contained in:
parent
f65bbcff14
commit
1e8edb80b7
4 changed files with 44 additions and 26 deletions
|
@ -106,10 +106,12 @@
|
|||
* Add "Test NZBGet" client to Search Settings/NZB Search/NZBGet
|
||||
* Change include x265 category when searching IPT provider
|
||||
* Change init.systemd to use python2 binary and recommended installation paths
|
||||
* Change improve handling of SIGINT CTRL+C, SIGINT CTRL+BREAK(Windows) and SIGTERM
|
||||
|
||||
[develop changelog]
|
||||
* Change send nzb data to NZBGet for Anizb instead of url
|
||||
* Change ensure KAT URL is available
|
||||
* Change revert test_common.py include file placement so Travis builds don't fail
|
||||
|
||||
|
||||
### 0.11.12 (2016-06-20 02:20:00 UTC)
|
||||
|
|
26
SickBeard.py
26
SickBeard.py
|
@ -21,16 +21,17 @@
|
|||
from __future__ import print_function
|
||||
from __future__ import with_statement
|
||||
|
||||
import time
|
||||
import datetime
|
||||
import errno
|
||||
import getopt
|
||||
import locale
|
||||
import os
|
||||
import signal
|
||||
import sys
|
||||
import shutil
|
||||
import subprocess
|
||||
import os
|
||||
import locale
|
||||
import datetime
|
||||
import time
|
||||
import threading
|
||||
import getopt
|
||||
|
||||
if sys.version_info < (2, 6):
|
||||
print('Sorry, requires Python 2.6 or 2.7.')
|
||||
|
@ -61,12 +62,15 @@ from sickbeard.tv import TVShow
|
|||
from sickbeard.webserveInit import WebServer
|
||||
from sickbeard.databases.mainDB import MIN_DB_VERSION, MAX_DB_VERSION
|
||||
from sickbeard.event_queue import Events
|
||||
from sickbeard.exceptions import ex
|
||||
from lib.configobj import ConfigObj
|
||||
|
||||
throwaway = datetime.datetime.strptime('20110101', '%Y%m%d')
|
||||
|
||||
signal.signal(signal.SIGINT, sickbeard.sig_handler)
|
||||
signal.signal(signal.SIGTERM, sickbeard.sig_handler)
|
||||
if 'win32' == sys.platform:
|
||||
signal.signal(signal.SIGBREAK, sickbeard.sig_handler)
|
||||
|
||||
|
||||
class SickGear(object):
|
||||
|
@ -526,6 +530,12 @@ class SickGear(object):
|
|||
if __name__ == '__main__':
|
||||
if sys.hexversion >= 0x020600F0:
|
||||
freeze_support()
|
||||
|
||||
# start SickGear
|
||||
SickGear().start()
|
||||
try:
|
||||
try:
|
||||
# start SickGear
|
||||
SickGear().start()
|
||||
except IOError as e:
|
||||
if e.errno != errno.EINTR:
|
||||
raise
|
||||
except Exception as e:
|
||||
logger.log('SickGear.Start() exception caught %s' % ex(e))
|
||||
|
|
|
@ -17,35 +17,36 @@
|
|||
# along with SickGear. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from __future__ import with_statement
|
||||
|
||||
import webbrowser
|
||||
import datetime
|
||||
import socket
|
||||
import os
|
||||
import re
|
||||
|
||||
from threading import Lock
|
||||
|
||||
import datetime
|
||||
import os
|
||||
import re
|
||||
import signal
|
||||
import socket
|
||||
import webbrowser
|
||||
|
||||
# apparently py2exe won't build these unless they're imported somewhere
|
||||
import sys
|
||||
import os.path
|
||||
import uuid
|
||||
import ast
|
||||
import base64
|
||||
import os.path
|
||||
import sys
|
||||
import uuid
|
||||
|
||||
sys.path.insert(1, os.path.abspath('../lib'))
|
||||
from sickbeard import helpers, logger, db, naming, metadata, providers, scene_exceptions, scene_numbering, \
|
||||
from sickbeard import helpers, encodingKludge as ek
|
||||
from sickbeard import db, logger, naming, metadata, providers, scene_exceptions, scene_numbering, \
|
||||
scheduler, auto_post_processer, search_queue, search_propers, search_recent, search_backlog, \
|
||||
show_queue, show_updater, subtitles, traktChecker, version_checker
|
||||
from sickbeard.config import CheckSection, check_setting_int, check_setting_str, ConfigMigrator, minimax
|
||||
from sickbeard.common import SD, SKIPPED
|
||||
from sickbeard.databases import mainDB, cache_db, failed_db
|
||||
from sickbeard.exceptions import ex
|
||||
from sickbeard.providers.generic import GenericProvider
|
||||
from indexers.indexer_config import INDEXER_TVDB
|
||||
from indexers.indexer_api import indexerApi
|
||||
from indexers.indexer_exceptions import indexer_shownotfound, indexer_exception, indexer_error, \
|
||||
indexer_episodenotfound, indexer_attributenotfound, indexer_seasonnotfound, indexer_userabort, indexerExcepts
|
||||
from sickbeard.exceptions import ex
|
||||
from sickbeard.providers.generic import GenericProvider
|
||||
from sickbeard import encodingKludge as ek
|
||||
from lib.adba.aniDBerrors import (AniDBError, AniDBBannedError)
|
||||
from lib.configobj import ConfigObj
|
||||
from lib.libtrakt import TraktAPI
|
||||
|
@ -1376,9 +1377,14 @@ def halt():
|
|||
|
||||
|
||||
def sig_handler(signum=None, frame=None):
|
||||
if isinstance(signum, type(None)):
|
||||
logger.log(u'Signal %i caught, saving and exiting...' % int(signum))
|
||||
is_ctrlbreak = 'win32' == sys.platform and signal.SIGBREAK == signum
|
||||
msg = u'Signal "%s" found' % (signal.SIGINT == signum and 'CTRL-C' or is_ctrlbreak and 'CTRL+BREAK' or
|
||||
signal.SIGTERM == signum and 'Termination' or signum)
|
||||
if None is signum or signum in (signal.SIGINT, signal.SIGTERM) or is_ctrlbreak:
|
||||
logger.log('%s, saving and exiting...' % msg)
|
||||
events.put(events.SystemEvent.SHUTDOWN)
|
||||
else:
|
||||
logger.log('%s, not exiting' % msg)
|
||||
|
||||
|
||||
def save_all():
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
from sickbeard import common
|
||||
|
||||
import unittest
|
||||
|
||||
import sys
|
||||
import os.path
|
||||
sys.path.insert(1, os.path.abspath('..'))
|
||||
|
||||
from sickbeard import common
|
||||
|
||||
|
||||
class QualityTests(unittest.TestCase):
|
||||
|
||||
|
|
Loading…
Reference in a new issue