2012-09-13 15:27:34 +00:00
|
|
|
#!/usr/bin/env python
|
|
|
|
# This file is part of Mylar.
|
|
|
|
#
|
|
|
|
# Mylar is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# Mylar is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with Mylar. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
import os, sys, locale
|
|
|
|
import time
|
IMP: Ability to now specify search provider order (regardless of torrents or nzb) within the config.ini, IMP: (#667) Changed the db module to try to accomodate db locking errors and lowering the amount of actual write transactions that were committed along with a new scheduler system, IMP: Changed sabnzbd directory to post-processing, and included subdirs for sabnzbd & nzbget ComicRN scripts, IMP: NZBGet Post-Processing ComicRN.py script (updated for use with nzbget v11.0+)added & updated in post-processing/nzbget directory (thnx ministoat), FIX: If Issue Location was None, and status was Downloaded would cause error in GUI and break series, IMP: (#689) Minimum # of seeders added (will work with KAT), IMP: (#680) Added Boxcar 2 IO Notifications, IMP: Added PushBullet Notifications, IMP: Cleaned up some notification messages so it's not so cluttered, IMP: Added Clickable series link in History tab, IMP: Added Post-Processed as a status to History tab to show manually post-processed items, IMP: Removed log level dropdown from Logs page & added 'ThreadName' as a column, IMP: Added Force Check Availability & View Future Pull-list to Upcoming sub-tabs, IMP: Added '--safe' option to startup options which will redirect directly to Manage Comics screen incase things are broken, FIX: Added proper month conversions for manual post-processing when doing comparitive issue analysis for matches, FIX: (#613) Allow for negative issue numbers in post-processing when renaming and issue padding is enabled, FIX: File Permissions on post-processing would stop post-processing if couldn't change, now will just log the error and continue, IMP: Added Scheduler (from sickbeard) to allow for threadnaming and better scheduling, IMP: Filenames in the format of ' () ' will now get scanned in, IMP: During manual post-processing will now stop looking for matches upon a successful match, IMP: A Refresh/Weeklypull series check will now just scan in issue data, instead of series info,etc, IMP: Removed some legacy GCD code that is no longer in use, IMP: Exception/traceback handling will now be logged, FIX: Unable to grab torrents from KAT due to content-encoding detection failing, IMP: Added universal date-time conversion to allow for non-english based dates to be properly compared when checking search results against publication dates, FIX: Annuals will now get proper notification (prior was leaving out the word 'annual' from notification/logs), IMP: Improved future pull-list detection and increased retension (now ~5 months), IMP: Will now mark new issues as Wanted on a Refresh Series if autowant upcoming is enabled (was reverting to a status of None previously), IMP: Cannot change status to Downloaded if current status is Skipped or Wanted, FIX: (#704) UnSkipped will now work (X in options column on comic details page), IMP: future_check will check upcoming future issues (future pull-list) that have no series data yet (ie. #1's) and auto-add them to watchlist when the data is available and auto-want accordingly, IMP: (#706) Downloading issues to local machine (via comicdetails screen) with special characters in filename now will work, IMP: improved comparison checks during weekly pull list and improved speed abit since only refreshing issue data now instead of entire series, Other Referenced issues: (#670)(#690) and some others....
2014-05-25 18:32:11 +00:00
|
|
|
import threading
|
2014-10-23 08:06:38 +00:00
|
|
|
import signal
|
2012-09-13 15:27:34 +00:00
|
|
|
|
|
|
|
from lib.configobj import ConfigObj
|
|
|
|
|
|
|
|
import mylar
|
|
|
|
|
2014-06-04 20:31:26 +00:00
|
|
|
from mylar import webstart, logger, filechecker, versioncheck
|
2012-09-13 15:27:34 +00:00
|
|
|
|
|
|
|
try:
|
|
|
|
import argparse
|
|
|
|
except ImportError:
|
|
|
|
import lib.argparse as argparse
|
2014-10-23 08:06:38 +00:00
|
|
|
|
|
|
|
def handler_sigterm(signum, frame):
|
|
|
|
mylar.SIGNAL = 'shutdown'
|
2012-09-13 15:27:34 +00:00
|
|
|
|
|
|
|
def main():
|
|
|
|
|
|
|
|
# Fixed paths to mylar
|
|
|
|
if hasattr(sys, 'frozen'):
|
|
|
|
mylar.FULL_PATH = os.path.abspath(sys.executable)
|
|
|
|
else:
|
|
|
|
mylar.FULL_PATH = os.path.abspath(__file__)
|
|
|
|
|
|
|
|
mylar.PROG_DIR = os.path.dirname(mylar.FULL_PATH)
|
|
|
|
mylar.ARGS = sys.argv[1:]
|
|
|
|
|
|
|
|
# From sickbeard
|
|
|
|
mylar.SYS_ENCODING = None
|
|
|
|
|
|
|
|
try:
|
|
|
|
locale.setlocale(locale.LC_ALL, "")
|
|
|
|
mylar.SYS_ENCODING = locale.getpreferredencoding()
|
|
|
|
except (locale.Error, IOError):
|
|
|
|
pass
|
|
|
|
|
|
|
|
# for OSes that are poorly configured I'll just force UTF-8
|
|
|
|
if not mylar.SYS_ENCODING or mylar.SYS_ENCODING in ('ANSI_X3.4-1968', 'US-ASCII', 'ASCII'):
|
|
|
|
mylar.SYS_ENCODING = 'UTF-8'
|
|
|
|
|
|
|
|
# Set up and gather command line arguments
|
|
|
|
parser = argparse.ArgumentParser(description='Comic Book add-on for SABnzbd+')
|
|
|
|
|
|
|
|
parser.add_argument('-v', '--verbose', action='store_true', help='Increase console logging verbosity')
|
|
|
|
parser.add_argument('-q', '--quiet', action='store_true', help='Turn off console logging')
|
|
|
|
parser.add_argument('-d', '--daemon', action='store_true', help='Run as a daemon')
|
|
|
|
parser.add_argument('-p', '--port', type=int, help='Force mylar to run on a specified port')
|
|
|
|
parser.add_argument('--datadir', help='Specify a directory where to store your data files')
|
|
|
|
parser.add_argument('--config', help='Specify a config file to use')
|
|
|
|
parser.add_argument('--nolaunch', action='store_true', help='Prevent browser from launching on startup')
|
|
|
|
parser.add_argument('--pidfile', help='Create a pid file (only relevant when running as a daemon)')
|
IMP: Ability to now specify search provider order (regardless of torrents or nzb) within the config.ini, IMP: (#667) Changed the db module to try to accomodate db locking errors and lowering the amount of actual write transactions that were committed along with a new scheduler system, IMP: Changed sabnzbd directory to post-processing, and included subdirs for sabnzbd & nzbget ComicRN scripts, IMP: NZBGet Post-Processing ComicRN.py script (updated for use with nzbget v11.0+)added & updated in post-processing/nzbget directory (thnx ministoat), FIX: If Issue Location was None, and status was Downloaded would cause error in GUI and break series, IMP: (#689) Minimum # of seeders added (will work with KAT), IMP: (#680) Added Boxcar 2 IO Notifications, IMP: Added PushBullet Notifications, IMP: Cleaned up some notification messages so it's not so cluttered, IMP: Added Clickable series link in History tab, IMP: Added Post-Processed as a status to History tab to show manually post-processed items, IMP: Removed log level dropdown from Logs page & added 'ThreadName' as a column, IMP: Added Force Check Availability & View Future Pull-list to Upcoming sub-tabs, IMP: Added '--safe' option to startup options which will redirect directly to Manage Comics screen incase things are broken, FIX: Added proper month conversions for manual post-processing when doing comparitive issue analysis for matches, FIX: (#613) Allow for negative issue numbers in post-processing when renaming and issue padding is enabled, FIX: File Permissions on post-processing would stop post-processing if couldn't change, now will just log the error and continue, IMP: Added Scheduler (from sickbeard) to allow for threadnaming and better scheduling, IMP: Filenames in the format of ' () ' will now get scanned in, IMP: During manual post-processing will now stop looking for matches upon a successful match, IMP: A Refresh/Weeklypull series check will now just scan in issue data, instead of series info,etc, IMP: Removed some legacy GCD code that is no longer in use, IMP: Exception/traceback handling will now be logged, FIX: Unable to grab torrents from KAT due to content-encoding detection failing, IMP: Added universal date-time conversion to allow for non-english based dates to be properly compared when checking search results against publication dates, FIX: Annuals will now get proper notification (prior was leaving out the word 'annual' from notification/logs), IMP: Improved future pull-list detection and increased retension (now ~5 months), IMP: Will now mark new issues as Wanted on a Refresh Series if autowant upcoming is enabled (was reverting to a status of None previously), IMP: Cannot change status to Downloaded if current status is Skipped or Wanted, FIX: (#704) UnSkipped will now work (X in options column on comic details page), IMP: future_check will check upcoming future issues (future pull-list) that have no series data yet (ie. #1's) and auto-add them to watchlist when the data is available and auto-want accordingly, IMP: (#706) Downloading issues to local machine (via comicdetails screen) with special characters in filename now will work, IMP: improved comparison checks during weekly pull list and improved speed abit since only refreshing issue data now instead of entire series, Other Referenced issues: (#670)(#690) and some others....
2014-05-25 18:32:11 +00:00
|
|
|
parser.add_argument('--safe', action='store_true', help='redirect the startup page to point to the Manage Comics screen on startup')
|
2014-06-04 20:31:26 +00:00
|
|
|
#parser.add_argument('-u', '--update', action='store_true', help='force mylar to perform an update as if in GUI')
|
2012-09-13 15:27:34 +00:00
|
|
|
|
|
|
|
args = parser.parse_args()
|
|
|
|
|
|
|
|
if args.verbose:
|
|
|
|
mylar.VERBOSE = 2
|
|
|
|
elif args.quiet:
|
|
|
|
mylar.VERBOSE = 0
|
|
|
|
|
2014-06-04 20:31:26 +00:00
|
|
|
#if args.update:
|
|
|
|
# print('Attempting to update Mylar so things can work again...')
|
|
|
|
# try:
|
|
|
|
# versioncheck.update()
|
|
|
|
# except Exception, e:
|
|
|
|
# sys.exit('Mylar failed to update.')
|
|
|
|
|
|
|
|
|
2012-09-13 15:27:34 +00:00
|
|
|
if args.daemon:
|
IMP: Ability to now specify search provider order (regardless of torrents or nzb) within the config.ini, IMP: (#667) Changed the db module to try to accomodate db locking errors and lowering the amount of actual write transactions that were committed along with a new scheduler system, IMP: Changed sabnzbd directory to post-processing, and included subdirs for sabnzbd & nzbget ComicRN scripts, IMP: NZBGet Post-Processing ComicRN.py script (updated for use with nzbget v11.0+)added & updated in post-processing/nzbget directory (thnx ministoat), FIX: If Issue Location was None, and status was Downloaded would cause error in GUI and break series, IMP: (#689) Minimum # of seeders added (will work with KAT), IMP: (#680) Added Boxcar 2 IO Notifications, IMP: Added PushBullet Notifications, IMP: Cleaned up some notification messages so it's not so cluttered, IMP: Added Clickable series link in History tab, IMP: Added Post-Processed as a status to History tab to show manually post-processed items, IMP: Removed log level dropdown from Logs page & added 'ThreadName' as a column, IMP: Added Force Check Availability & View Future Pull-list to Upcoming sub-tabs, IMP: Added '--safe' option to startup options which will redirect directly to Manage Comics screen incase things are broken, FIX: Added proper month conversions for manual post-processing when doing comparitive issue analysis for matches, FIX: (#613) Allow for negative issue numbers in post-processing when renaming and issue padding is enabled, FIX: File Permissions on post-processing would stop post-processing if couldn't change, now will just log the error and continue, IMP: Added Scheduler (from sickbeard) to allow for threadnaming and better scheduling, IMP: Filenames in the format of ' () ' will now get scanned in, IMP: During manual post-processing will now stop looking for matches upon a successful match, IMP: A Refresh/Weeklypull series check will now just scan in issue data, instead of series info,etc, IMP: Removed some legacy GCD code that is no longer in use, IMP: Exception/traceback handling will now be logged, FIX: Unable to grab torrents from KAT due to content-encoding detection failing, IMP: Added universal date-time conversion to allow for non-english based dates to be properly compared when checking search results against publication dates, FIX: Annuals will now get proper notification (prior was leaving out the word 'annual' from notification/logs), IMP: Improved future pull-list detection and increased retension (now ~5 months), IMP: Will now mark new issues as Wanted on a Refresh Series if autowant upcoming is enabled (was reverting to a status of None previously), IMP: Cannot change status to Downloaded if current status is Skipped or Wanted, FIX: (#704) UnSkipped will now work (X in options column on comic details page), IMP: future_check will check upcoming future issues (future pull-list) that have no series data yet (ie. #1's) and auto-add them to watchlist when the data is available and auto-want accordingly, IMP: (#706) Downloading issues to local machine (via comicdetails screen) with special characters in filename now will work, IMP: improved comparison checks during weekly pull list and improved speed abit since only refreshing issue data now instead of entire series, Other Referenced issues: (#670)(#690) and some others....
2014-05-25 18:32:11 +00:00
|
|
|
if sys.platform == 'win32':
|
|
|
|
print "Daemonize not supported under Windows, starting normally"
|
|
|
|
else:
|
|
|
|
mylar.DAEMON=True
|
|
|
|
mylar.VERBOSE=0
|
|
|
|
|
|
|
|
if args.pidfile :
|
2014-06-04 20:31:26 +00:00
|
|
|
mylar.PIDFILE = str(args.pidfile)
|
IMP: Ability to now specify search provider order (regardless of torrents or nzb) within the config.ini, IMP: (#667) Changed the db module to try to accomodate db locking errors and lowering the amount of actual write transactions that were committed along with a new scheduler system, IMP: Changed sabnzbd directory to post-processing, and included subdirs for sabnzbd & nzbget ComicRN scripts, IMP: NZBGet Post-Processing ComicRN.py script (updated for use with nzbget v11.0+)added & updated in post-processing/nzbget directory (thnx ministoat), FIX: If Issue Location was None, and status was Downloaded would cause error in GUI and break series, IMP: (#689) Minimum # of seeders added (will work with KAT), IMP: (#680) Added Boxcar 2 IO Notifications, IMP: Added PushBullet Notifications, IMP: Cleaned up some notification messages so it's not so cluttered, IMP: Added Clickable series link in History tab, IMP: Added Post-Processed as a status to History tab to show manually post-processed items, IMP: Removed log level dropdown from Logs page & added 'ThreadName' as a column, IMP: Added Force Check Availability & View Future Pull-list to Upcoming sub-tabs, IMP: Added '--safe' option to startup options which will redirect directly to Manage Comics screen incase things are broken, FIX: Added proper month conversions for manual post-processing when doing comparitive issue analysis for matches, FIX: (#613) Allow for negative issue numbers in post-processing when renaming and issue padding is enabled, FIX: File Permissions on post-processing would stop post-processing if couldn't change, now will just log the error and continue, IMP: Added Scheduler (from sickbeard) to allow for threadnaming and better scheduling, IMP: Filenames in the format of ' () ' will now get scanned in, IMP: During manual post-processing will now stop looking for matches upon a successful match, IMP: A Refresh/Weeklypull series check will now just scan in issue data, instead of series info,etc, IMP: Removed some legacy GCD code that is no longer in use, IMP: Exception/traceback handling will now be logged, FIX: Unable to grab torrents from KAT due to content-encoding detection failing, IMP: Added universal date-time conversion to allow for non-english based dates to be properly compared when checking search results against publication dates, FIX: Annuals will now get proper notification (prior was leaving out the word 'annual' from notification/logs), IMP: Improved future pull-list detection and increased retension (now ~5 months), IMP: Will now mark new issues as Wanted on a Refresh Series if autowant upcoming is enabled (was reverting to a status of None previously), IMP: Cannot change status to Downloaded if current status is Skipped or Wanted, FIX: (#704) UnSkipped will now work (X in options column on comic details page), IMP: future_check will check upcoming future issues (future pull-list) that have no series data yet (ie. #1's) and auto-add them to watchlist when the data is available and auto-want accordingly, IMP: (#706) Downloading issues to local machine (via comicdetails screen) with special characters in filename now will work, IMP: improved comparison checks during weekly pull list and improved speed abit since only refreshing issue data now instead of entire series, Other Referenced issues: (#670)(#690) and some others....
2014-05-25 18:32:11 +00:00
|
|
|
|
|
|
|
# If the pidfile already exists, mylar may still be running, so exit
|
|
|
|
if os.path.exists(mylar.PIDFILE):
|
|
|
|
sys.exit("PID file '" + mylar.PIDFILE + "' already exists. Exiting.")
|
|
|
|
|
|
|
|
# The pidfile is only useful in daemon mode, make sure we can write the file properly
|
|
|
|
if mylar.DAEMON:
|
2014-06-04 20:31:26 +00:00
|
|
|
mylar.CREATEPID = True
|
IMP: Ability to now specify search provider order (regardless of torrents or nzb) within the config.ini, IMP: (#667) Changed the db module to try to accomodate db locking errors and lowering the amount of actual write transactions that were committed along with a new scheduler system, IMP: Changed sabnzbd directory to post-processing, and included subdirs for sabnzbd & nzbget ComicRN scripts, IMP: NZBGet Post-Processing ComicRN.py script (updated for use with nzbget v11.0+)added & updated in post-processing/nzbget directory (thnx ministoat), FIX: If Issue Location was None, and status was Downloaded would cause error in GUI and break series, IMP: (#689) Minimum # of seeders added (will work with KAT), IMP: (#680) Added Boxcar 2 IO Notifications, IMP: Added PushBullet Notifications, IMP: Cleaned up some notification messages so it's not so cluttered, IMP: Added Clickable series link in History tab, IMP: Added Post-Processed as a status to History tab to show manually post-processed items, IMP: Removed log level dropdown from Logs page & added 'ThreadName' as a column, IMP: Added Force Check Availability & View Future Pull-list to Upcoming sub-tabs, IMP: Added '--safe' option to startup options which will redirect directly to Manage Comics screen incase things are broken, FIX: Added proper month conversions for manual post-processing when doing comparitive issue analysis for matches, FIX: (#613) Allow for negative issue numbers in post-processing when renaming and issue padding is enabled, FIX: File Permissions on post-processing would stop post-processing if couldn't change, now will just log the error and continue, IMP: Added Scheduler (from sickbeard) to allow for threadnaming and better scheduling, IMP: Filenames in the format of ' () ' will now get scanned in, IMP: During manual post-processing will now stop looking for matches upon a successful match, IMP: A Refresh/Weeklypull series check will now just scan in issue data, instead of series info,etc, IMP: Removed some legacy GCD code that is no longer in use, IMP: Exception/traceback handling will now be logged, FIX: Unable to grab torrents from KAT due to content-encoding detection failing, IMP: Added universal date-time conversion to allow for non-english based dates to be properly compared when checking search results against publication dates, FIX: Annuals will now get proper notification (prior was leaving out the word 'annual' from notification/logs), IMP: Improved future pull-list detection and increased retension (now ~5 months), IMP: Will now mark new issues as Wanted on a Refresh Series if autowant upcoming is enabled (was reverting to a status of None previously), IMP: Cannot change status to Downloaded if current status is Skipped or Wanted, FIX: (#704) UnSkipped will now work (X in options column on comic details page), IMP: future_check will check upcoming future issues (future pull-list) that have no series data yet (ie. #1's) and auto-add them to watchlist when the data is available and auto-want accordingly, IMP: (#706) Downloading issues to local machine (via comicdetails screen) with special characters in filename now will work, IMP: improved comparison checks during weekly pull list and improved speed abit since only refreshing issue data now instead of entire series, Other Referenced issues: (#670)(#690) and some others....
2014-05-25 18:32:11 +00:00
|
|
|
try:
|
|
|
|
file(mylar.PIDFILE, 'w').write("pid\n")
|
|
|
|
except IOError, e:
|
|
|
|
raise SystemExit("Unable to write PID file: %s [%d]" % (e.strerror, e.errno))
|
|
|
|
else:
|
|
|
|
logger.warn("Not running in daemon mode. PID file creation disabled.")
|
|
|
|
|
2012-09-13 15:27:34 +00:00
|
|
|
|
|
|
|
if args.datadir:
|
|
|
|
mylar.DATA_DIR = args.datadir
|
|
|
|
else:
|
|
|
|
mylar.DATA_DIR = mylar.PROG_DIR
|
|
|
|
|
|
|
|
if args.config:
|
|
|
|
mylar.CONFIG_FILE = args.config
|
|
|
|
else:
|
|
|
|
mylar.CONFIG_FILE = os.path.join(mylar.DATA_DIR, 'config.ini')
|
|
|
|
|
IMP: Ability to now specify search provider order (regardless of torrents or nzb) within the config.ini, IMP: (#667) Changed the db module to try to accomodate db locking errors and lowering the amount of actual write transactions that were committed along with a new scheduler system, IMP: Changed sabnzbd directory to post-processing, and included subdirs for sabnzbd & nzbget ComicRN scripts, IMP: NZBGet Post-Processing ComicRN.py script (updated for use with nzbget v11.0+)added & updated in post-processing/nzbget directory (thnx ministoat), FIX: If Issue Location was None, and status was Downloaded would cause error in GUI and break series, IMP: (#689) Minimum # of seeders added (will work with KAT), IMP: (#680) Added Boxcar 2 IO Notifications, IMP: Added PushBullet Notifications, IMP: Cleaned up some notification messages so it's not so cluttered, IMP: Added Clickable series link in History tab, IMP: Added Post-Processed as a status to History tab to show manually post-processed items, IMP: Removed log level dropdown from Logs page & added 'ThreadName' as a column, IMP: Added Force Check Availability & View Future Pull-list to Upcoming sub-tabs, IMP: Added '--safe' option to startup options which will redirect directly to Manage Comics screen incase things are broken, FIX: Added proper month conversions for manual post-processing when doing comparitive issue analysis for matches, FIX: (#613) Allow for negative issue numbers in post-processing when renaming and issue padding is enabled, FIX: File Permissions on post-processing would stop post-processing if couldn't change, now will just log the error and continue, IMP: Added Scheduler (from sickbeard) to allow for threadnaming and better scheduling, IMP: Filenames in the format of ' () ' will now get scanned in, IMP: During manual post-processing will now stop looking for matches upon a successful match, IMP: A Refresh/Weeklypull series check will now just scan in issue data, instead of series info,etc, IMP: Removed some legacy GCD code that is no longer in use, IMP: Exception/traceback handling will now be logged, FIX: Unable to grab torrents from KAT due to content-encoding detection failing, IMP: Added universal date-time conversion to allow for non-english based dates to be properly compared when checking search results against publication dates, FIX: Annuals will now get proper notification (prior was leaving out the word 'annual' from notification/logs), IMP: Improved future pull-list detection and increased retension (now ~5 months), IMP: Will now mark new issues as Wanted on a Refresh Series if autowant upcoming is enabled (was reverting to a status of None previously), IMP: Cannot change status to Downloaded if current status is Skipped or Wanted, FIX: (#704) UnSkipped will now work (X in options column on comic details page), IMP: future_check will check upcoming future issues (future pull-list) that have no series data yet (ie. #1's) and auto-add them to watchlist when the data is available and auto-want accordingly, IMP: (#706) Downloading issues to local machine (via comicdetails screen) with special characters in filename now will work, IMP: improved comparison checks during weekly pull list and improved speed abit since only refreshing issue data now instead of entire series, Other Referenced issues: (#670)(#690) and some others....
2014-05-25 18:32:11 +00:00
|
|
|
if args.safe:
|
|
|
|
mylar.SAFESTART = True
|
|
|
|
else:
|
|
|
|
mylar.SAFESTART = False
|
|
|
|
|
2012-09-13 15:27:34 +00:00
|
|
|
# Try to create the DATA_DIR if it doesn't exist
|
2013-04-22 03:43:57 +00:00
|
|
|
#if not os.path.exists(mylar.DATA_DIR):
|
|
|
|
# try:
|
|
|
|
# os.makedirs(mylar.DATA_DIR)
|
|
|
|
# except OSError:
|
|
|
|
# raise SystemExit('Could not create data directory: ' + mylar.DATA_DIR + '. Exiting....')
|
|
|
|
|
|
|
|
filechecker.validateAndCreateDirectory(mylar.DATA_DIR, True)
|
2012-09-13 15:27:34 +00:00
|
|
|
|
|
|
|
# Make sure the DATA_DIR is writeable
|
|
|
|
if not os.access(mylar.DATA_DIR, os.W_OK):
|
|
|
|
raise SystemExit('Cannot write to the data directory: ' + mylar.DATA_DIR + '. Exiting...')
|
|
|
|
|
|
|
|
# Put the database in the DATA_DIR
|
|
|
|
mylar.DB_FILE = os.path.join(mylar.DATA_DIR, 'mylar.db')
|
|
|
|
|
|
|
|
mylar.CFG = ConfigObj(mylar.CONFIG_FILE, encoding='utf-8')
|
IMP: Ability to now specify search provider order (regardless of torrents or nzb) within the config.ini, IMP: (#667) Changed the db module to try to accomodate db locking errors and lowering the amount of actual write transactions that were committed along with a new scheduler system, IMP: Changed sabnzbd directory to post-processing, and included subdirs for sabnzbd & nzbget ComicRN scripts, IMP: NZBGet Post-Processing ComicRN.py script (updated for use with nzbget v11.0+)added & updated in post-processing/nzbget directory (thnx ministoat), FIX: If Issue Location was None, and status was Downloaded would cause error in GUI and break series, IMP: (#689) Minimum # of seeders added (will work with KAT), IMP: (#680) Added Boxcar 2 IO Notifications, IMP: Added PushBullet Notifications, IMP: Cleaned up some notification messages so it's not so cluttered, IMP: Added Clickable series link in History tab, IMP: Added Post-Processed as a status to History tab to show manually post-processed items, IMP: Removed log level dropdown from Logs page & added 'ThreadName' as a column, IMP: Added Force Check Availability & View Future Pull-list to Upcoming sub-tabs, IMP: Added '--safe' option to startup options which will redirect directly to Manage Comics screen incase things are broken, FIX: Added proper month conversions for manual post-processing when doing comparitive issue analysis for matches, FIX: (#613) Allow for negative issue numbers in post-processing when renaming and issue padding is enabled, FIX: File Permissions on post-processing would stop post-processing if couldn't change, now will just log the error and continue, IMP: Added Scheduler (from sickbeard) to allow for threadnaming and better scheduling, IMP: Filenames in the format of ' () ' will now get scanned in, IMP: During manual post-processing will now stop looking for matches upon a successful match, IMP: A Refresh/Weeklypull series check will now just scan in issue data, instead of series info,etc, IMP: Removed some legacy GCD code that is no longer in use, IMP: Exception/traceback handling will now be logged, FIX: Unable to grab torrents from KAT due to content-encoding detection failing, IMP: Added universal date-time conversion to allow for non-english based dates to be properly compared when checking search results against publication dates, FIX: Annuals will now get proper notification (prior was leaving out the word 'annual' from notification/logs), IMP: Improved future pull-list detection and increased retension (now ~5 months), IMP: Will now mark new issues as Wanted on a Refresh Series if autowant upcoming is enabled (was reverting to a status of None previously), IMP: Cannot change status to Downloaded if current status is Skipped or Wanted, FIX: (#704) UnSkipped will now work (X in options column on comic details page), IMP: future_check will check upcoming future issues (future pull-list) that have no series data yet (ie. #1's) and auto-add them to watchlist when the data is available and auto-want accordingly, IMP: (#706) Downloading issues to local machine (via comicdetails screen) with special characters in filename now will work, IMP: improved comparison checks during weekly pull list and improved speed abit since only refreshing issue data now instead of entire series, Other Referenced issues: (#670)(#690) and some others....
2014-05-25 18:32:11 +00:00
|
|
|
|
|
|
|
# Rename the main thread
|
|
|
|
threading.currentThread().name = "MAIN"
|
2012-09-13 15:27:34 +00:00
|
|
|
|
|
|
|
# Read config & start logging
|
|
|
|
mylar.initialize()
|
|
|
|
|
|
|
|
if mylar.DAEMON:
|
|
|
|
mylar.daemonize()
|
|
|
|
|
|
|
|
# Force the http port if neccessary
|
|
|
|
if args.port:
|
|
|
|
http_port = args.port
|
|
|
|
logger.info('Starting Mylar on foced port: %i' % http_port)
|
|
|
|
else:
|
|
|
|
http_port = int(mylar.HTTP_PORT)
|
|
|
|
|
|
|
|
# Try to start the server.
|
|
|
|
webstart.initialize({
|
|
|
|
'http_port': http_port,
|
|
|
|
'http_host': mylar.HTTP_HOST,
|
|
|
|
'http_root': mylar.HTTP_ROOT,
|
|
|
|
'http_username': mylar.HTTP_USERNAME,
|
|
|
|
'http_password': mylar.HTTP_PASSWORD,
|
|
|
|
})
|
|
|
|
|
|
|
|
logger.info('Starting Mylar on port: %i' % http_port)
|
|
|
|
|
|
|
|
if mylar.LAUNCH_BROWSER and not args.nolaunch:
|
|
|
|
mylar.launch_browser(mylar.HTTP_HOST, http_port, mylar.HTTP_ROOT)
|
|
|
|
|
|
|
|
# Start the background threads
|
|
|
|
mylar.start()
|
2014-10-23 08:06:38 +00:00
|
|
|
|
|
|
|
signal.signal(signal.SIGTERM, handler_sigterm)
|
2012-09-13 15:27:34 +00:00
|
|
|
|
|
|
|
while True:
|
|
|
|
if not mylar.SIGNAL:
|
2014-06-04 20:31:26 +00:00
|
|
|
try:
|
|
|
|
time.sleep(1)
|
|
|
|
except KeyboardInterrupt:
|
|
|
|
mylar.SIGNAL = 'shutdown'
|
2012-09-13 15:27:34 +00:00
|
|
|
else:
|
|
|
|
logger.info('Received signal: ' + mylar.SIGNAL)
|
|
|
|
if mylar.SIGNAL == 'shutdown':
|
|
|
|
mylar.shutdown()
|
|
|
|
elif mylar.SIGNAL == 'restart':
|
|
|
|
mylar.shutdown(restart=True)
|
|
|
|
else:
|
|
|
|
mylar.shutdown(restart=True, update=True)
|
|
|
|
|
|
|
|
mylar.SIGNAL = None
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|