mirror of https://github.com/evilhero/mylar
IMP:(#268) Added CHMOD Config options, fixed missing directory errors (Pull Request from claym)
This commit is contained in:
parent
199fd25d8f
commit
152a60dafe
14
Mylar.py
14
Mylar.py
|
@ -21,7 +21,7 @@ from lib.configobj import ConfigObj
|
|||
|
||||
import mylar
|
||||
|
||||
from mylar import webstart, logger
|
||||
from mylar import webstart, logger, filechecker
|
||||
|
||||
try:
|
||||
import argparse
|
||||
|
@ -89,11 +89,13 @@ def main():
|
|||
mylar.CONFIG_FILE = os.path.join(mylar.DATA_DIR, 'config.ini')
|
||||
|
||||
# Try to create the DATA_DIR if it doesn't exist
|
||||
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....')
|
||||
#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)
|
||||
|
||||
# Make sure the DATA_DIR is writeable
|
||||
if not os.access(mylar.DATA_DIR, os.W_OK):
|
||||
|
|
|
@ -164,7 +164,17 @@
|
|||
<input type="text" name="destination_dir" value="${config['destination_dir']}" size="50">
|
||||
<small>Where do you store your comics?<br/> (or where do you want me to store them)</small>
|
||||
<small>e.g. /Users/name/Comics or /Volumes/share/comics</small>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<label>Directory CHMOD</label>
|
||||
<input type="text" name="chmod_dir" value="${config['chmod_dir']}" size="50">
|
||||
<small>Permissions on created/moved directories</small>
|
||||
</div>
|
||||
<div class="row">
|
||||
<label>File CHMOD</label>
|
||||
<input type="text" name="chmod_file" value="${config['chmod_file']}" size="50">
|
||||
<small>Permissions on created/moved directories</small>
|
||||
</div>
|
||||
|
||||
</fieldset>
|
||||
|
|
|
@ -27,7 +27,7 @@ import urllib2
|
|||
import sqlite3
|
||||
from xml.dom.minidom import parseString
|
||||
|
||||
from mylar import logger, db, helpers, updater, notifiers
|
||||
from mylar import logger, db, helpers, updater, notifiers, filechecker
|
||||
|
||||
class PostProcessor(object):
|
||||
"""
|
||||
|
@ -437,6 +437,9 @@ class PostProcessor(object):
|
|||
logger.fdebug("New Filename: " + str(nfilename))
|
||||
|
||||
src = os.path.join(self.nzb_folder, ofilename)
|
||||
|
||||
filechecker.validateAndCreateDirectory(comlocation, True)
|
||||
|
||||
if mylar.LOWERCASE_FILENAMES:
|
||||
dst = (comlocation + "/" + nfilename + ext).lower()
|
||||
else:
|
||||
|
|
|
@ -85,6 +85,8 @@ CHECK_GITHUB_ON_STARTUP = False
|
|||
CHECK_GITHUB_INTERVAL = None
|
||||
|
||||
DESTINATION_DIR = None
|
||||
CHMOD_DIR = None
|
||||
CHMOD_FILE = None
|
||||
USENET_RETENTION = None
|
||||
|
||||
ADD_COMICS = False
|
||||
|
@ -260,7 +262,7 @@ def initialize():
|
|||
RAW, RAW_PROVIDER, RAW_USERNAME, RAW_PASSWORD, RAW_GROUPS, EXPERIMENTAL, \
|
||||
PROWL_ENABLED, PROWL_PRIORITY, PROWL_KEYS, PROWL_ONSNATCH, NMA_ENABLED, NMA_APIKEY, NMA_PRIORITY, NMA_ONSNATCH, \
|
||||
PREFERRED_QUALITY, MOVE_FILES, RENAME_FILES, LOWERCASE_FILENAMES, USE_MINSIZE, MINSIZE, USE_MAXSIZE, MAXSIZE, CORRECT_METADATA, FOLDER_FORMAT, FILE_FORMAT, REPLACE_CHAR, REPLACE_SPACES, ADD_TO_CSV, CVINFO, LOG_LEVEL, POST_PROCESSING, SEARCH_DELAY, GRABBAG_DIR, READ2FILENAME, \
|
||||
COMIC_LOCATION, QUAL_ALTVERS, QUAL_SCANNER, QUAL_TYPE, QUAL_QUALITY, ENABLE_EXTRA_SCRIPTS, EXTRA_SCRIPTS, ENABLE_PRE_SCRIPTS, PRE_SCRIPTS, PULLNEW, COUNT_ISSUES, COUNT_HAVES, COUNT_COMICS, SYNO_FIX, ANNUALS_ON, CV_ONLY, CV_ONETIMER
|
||||
COMIC_LOCATION, QUAL_ALTVERS, QUAL_SCANNER, QUAL_TYPE, QUAL_QUALITY, ENABLE_EXTRA_SCRIPTS, EXTRA_SCRIPTS, ENABLE_PRE_SCRIPTS, PRE_SCRIPTS, PULLNEW, COUNT_ISSUES, COUNT_HAVES, COUNT_COMICS, SYNO_FIX, CHMOD_FILE, CHMOD_DIR, ANNUALS_ON, CV_ONLY, CV_ONETIMER
|
||||
|
||||
if __INITIALIZED__:
|
||||
return False
|
||||
|
@ -300,6 +302,8 @@ def initialize():
|
|||
CHECK_GITHUB_INTERVAL = check_setting_int(CFG, 'General', 'check_github_interval', 360)
|
||||
|
||||
DESTINATION_DIR = check_setting_str(CFG, 'General', 'destination_dir', '')
|
||||
CHMOD_DIR = check_setting_str(CFG, 'General', 'chmod_dir', '0777')
|
||||
CHMOD_FILE = check_setting_str(CFG, 'General', 'chmod_file', '0660')
|
||||
USENET_RETENTION = check_setting_int(CFG, 'General', 'usenet_retention', '1500')
|
||||
|
||||
SEARCH_INTERVAL = check_setting_int(CFG, 'General', 'search_interval', 360)
|
||||
|
@ -320,7 +324,7 @@ def initialize():
|
|||
CORRECT_METADATA = bool(check_setting_int(CFG, 'General', 'correct_metadata', 0))
|
||||
MOVE_FILES = bool(check_setting_int(CFG, 'General', 'move_files', 0))
|
||||
RENAME_FILES = bool(check_setting_int(CFG, 'General', 'rename_files', 0))
|
||||
FOLDER_FORMAT = check_setting_str(CFG, 'General', 'folder_format', '$Series-($Year)')
|
||||
FOLDER_FORMAT = check_setting_str(CFG, 'General', 'folder_format', '$Series ($Year)')
|
||||
FILE_FORMAT = check_setting_str(CFG, 'General', 'file_format', '$Series $Issue ($Year)')
|
||||
BLACKHOLE = bool(check_setting_int(CFG, 'General', 'blackhole', 0))
|
||||
BLACKHOLE_DIR = check_setting_str(CFG, 'General', 'blackhole_dir', '')
|
||||
|
@ -635,6 +639,8 @@ def config_write():
|
|||
new_config['General']['check_github_interval'] = CHECK_GITHUB_INTERVAL
|
||||
|
||||
new_config['General']['destination_dir'] = DESTINATION_DIR
|
||||
new_config['General']['chmod_dir'] = CHMOD_DIR
|
||||
new_config['General']['chmod_file'] = CHMOD_FILE
|
||||
new_config['General']['usenet_retention'] = USENET_RETENTION
|
||||
|
||||
new_config['General']['search_interval'] = SEARCH_INTERVAL
|
||||
|
|
|
@ -20,6 +20,7 @@ import pprint
|
|||
import subprocess
|
||||
import re
|
||||
import logger
|
||||
import mylar
|
||||
|
||||
def file2comicmatch(watchmatch):
|
||||
#print ("match: " + str(watchmatch))
|
||||
|
@ -115,3 +116,22 @@ def listFiles(dir,watchcomic,AlternateSearch=None):
|
|||
logger.fdebug("you have a total of " + str(comiccnt) + " " + watchcomic + " comics")
|
||||
watchmatch['comiccount'] = comiccnt
|
||||
return watchmatch
|
||||
|
||||
def validateAndCreateDirectory(dir, create=False):
|
||||
if os.path.exists(dir):
|
||||
logger.info("Found comic directory: " + dir)
|
||||
return True
|
||||
else:
|
||||
logger.warn("Could not find comic directory: " + dir)
|
||||
if create:
|
||||
if dir.strip():
|
||||
logger.info("Creating comic directory ("+str(mylar.CHMOD_DIR)+") : " + dir)
|
||||
try:
|
||||
os.makedirs(dir, mode=int(mylar.CHMOD_DIR))
|
||||
except OSError:
|
||||
raise SystemExit('Could not create data directory: ' + mylar.DATA_DIR + '. Exiting....')
|
||||
return True
|
||||
else:
|
||||
logger.warn("Provided directory is blank, aborting")
|
||||
return False
|
||||
return False
|
||||
|
|
|
@ -61,6 +61,7 @@ def addComictoDB(comicid,mismatch=None,pullupd=None,imported=None,ogcname=None):
|
|||
else:
|
||||
newValueDict = {"Status": "Loading"}
|
||||
comlocation = dbcomic['ComicLocation']
|
||||
filechecker.validateAndCreateDirectory(comlocation, True)
|
||||
|
||||
myDB.upsert("comics", newValueDict, controlValueDict)
|
||||
|
||||
|
@ -214,11 +215,12 @@ def addComictoDB(comicid,mismatch=None,pullupd=None,imported=None,ogcname=None):
|
|||
logger.info(u"Directory (" + str(comlocation) + ") already exists! Continuing...")
|
||||
else:
|
||||
#print ("Directory doesn't exist!")
|
||||
try:
|
||||
os.makedirs(str(comlocation))
|
||||
logger.info(u"Directory successfully created at: " + str(comlocation))
|
||||
except OSError:
|
||||
logger.error(u"Could not create comicdir : " + str(comlocation))
|
||||
#try:
|
||||
# os.makedirs(str(comlocation))
|
||||
# logger.info(u"Directory successfully created at: " + str(comlocation))
|
||||
#except OSError:
|
||||
# logger.error(u"Could not create comicdir : " + str(comlocation))
|
||||
filechecker.validateAndCreateDirectory(comlocation, True)
|
||||
|
||||
#try to account for CV not updating new issues as fast as GCD
|
||||
#seems CV doesn't update total counts
|
||||
|
@ -746,12 +748,12 @@ def GCDimport(gcomicid, pullupd=None,imported=None,ogcname=None):
|
|||
logger.info(u"Directory (" + str(comlocation) + ") already exists! Continuing...")
|
||||
else:
|
||||
#print ("Directory doesn't exist!")
|
||||
try:
|
||||
os.makedirs(str(comlocation))
|
||||
logger.info(u"Directory successfully created at: " + str(comlocation))
|
||||
except OSError:
|
||||
logger.error(u"Could not create comicdir : " + str(comlocation))
|
||||
|
||||
#try:
|
||||
# os.makedirs(str(comlocation))
|
||||
# logger.info(u"Directory successfully created at: " + str(comlocation))
|
||||
#except OSError:
|
||||
# logger.error(u"Could not create comicdir : " + str(comlocation))
|
||||
filechecker.validateAndCreateDirectory(comlocation, True)
|
||||
|
||||
comicIssues = gcdinfo['totalissues']
|
||||
|
||||
|
|
|
@ -1383,6 +1383,8 @@ class WebInterface(object):
|
|||
"newznab_enabled" : helpers.checked(mylar.NEWZNAB_ENABLED),
|
||||
"extra_newznabs" : mylar.EXTRA_NEWZNABS,
|
||||
"destination_dir" : mylar.DESTINATION_DIR,
|
||||
"chmod_dir" : mylar.CHMOD_DIR,
|
||||
"chmod_file" : mylar.CHMOD_FILE,
|
||||
"replace_spaces" : helpers.checked(mylar.REPLACE_SPACES),
|
||||
"replace_char" : mylar.REPLACE_CHAR,
|
||||
"use_minsize" : helpers.checked(mylar.USE_MINSIZE),
|
||||
|
@ -1523,11 +1525,12 @@ class WebInterface(object):
|
|||
logger.info(u"Validating Directory (" + str(com_location) + "). Already exists! Continuing...")
|
||||
else:
|
||||
logger.fdebug("Updated Directory doesn't exist! - attempting to create now.")
|
||||
try:
|
||||
os.makedirs(str(com_location))
|
||||
logger.info(u"Directory successfully created at: " + str(com_location))
|
||||
except OSError:
|
||||
logger.error(u"Could not create comicdir : " + str(com_location))
|
||||
#try:
|
||||
# os.makedirs(str(com_location))
|
||||
# logger.info(u"Directory successfully created at: " + str(com_location))
|
||||
#except OSError:
|
||||
# logger.error(u"Could not create comicdir : " + str(com_location))
|
||||
filechecker.validateAndCreateDirectory(com_location, True)
|
||||
|
||||
myDB.upsert("comics", newValues, controlValueDict)
|
||||
raise cherrypy.HTTPRedirect("artistPage?ComicID=%s" % ComicID)
|
||||
|
@ -1539,7 +1542,7 @@ class WebInterface(object):
|
|||
usenet_retention=None, nzbsu=0, nzbsu_apikey=None, dognzb=0, dognzb_apikey=None, nzbx=0, newznab=0, newznab_host=None, newznab_apikey=None, newznab_enabled=0,
|
||||
raw=0, raw_provider=None, raw_username=None, raw_password=None, raw_groups=None, experimental=0,
|
||||
prowl_enabled=0, prowl_onsnatch=0, prowl_keys=None, prowl_priority=None, nma_enabled=0, nma_apikey=None, nma_priority=0, nma_onsnatch=0,
|
||||
preferred_quality=0, move_files=0, rename_files=0, add_to_csv=1, cvinfo=0, lowercase_filenames=0, folder_format=None, file_format=None, enable_extra_scripts=0, extra_scripts=None, enable_pre_scripts=0, pre_scripts=None, post_processing=0, syno_fix=0, search_delay=None,
|
||||
preferred_quality=0, move_files=0, rename_files=0, add_to_csv=1, cvinfo=0, lowercase_filenames=0, folder_format=None, file_format=None, enable_extra_scripts=0, extra_scripts=None, enable_pre_scripts=0, pre_scripts=None, post_processing=0, syno_fix=0, search_delay=None, chmod_dir=0777, chmod_file=0660,
|
||||
destination_dir=None, replace_spaces=0, replace_char=None, use_minsize=0, minsize=None, use_maxsize=0, maxsize=None, autowant_all=0, autowant_upcoming=0, comic_cover_local=0, zero_level=0, zero_level_n=None, interface=None, **kwargs):
|
||||
mylar.HTTP_HOST = http_host
|
||||
mylar.HTTP_PORT = http_port
|
||||
|
@ -1622,6 +1625,8 @@ class WebInterface(object):
|
|||
mylar.PRE_SCRIPTS = pre_scripts
|
||||
mylar.LOG_DIR = log_dir
|
||||
mylar.LOG_LEVEL = log_level
|
||||
mylar.CHMOD_DIR = chmod_dir
|
||||
mylar.CHMOD_FILE = chmod_file
|
||||
# Handle the variable config options. Note - keys with False values aren't getting passed
|
||||
|
||||
mylar.EXTRA_NEWZNABS = []
|
||||
|
@ -1647,6 +1652,14 @@ class WebInterface(object):
|
|||
logger.info("Minimum search delay set for 1 minute to avoid hammering.")
|
||||
mylar.SEARCH_DELAY = 1
|
||||
|
||||
if not helpers.is_number(mylar.CHMOD_DIR):
|
||||
logger.info("CHMOD Directory value is not a valid numeric - please correct. Defaulting to 0777")
|
||||
mylar.CHMOD_DIR = '0777'
|
||||
|
||||
if not helpers.is_number(mylar.CHMOD_FILE):
|
||||
logger.info("CHMOD File value is not a valid numeric - please correct. Defaulting to 0660")
|
||||
mylar.CHMOD_FILE = '0660'
|
||||
|
||||
# Write the config
|
||||
mylar.config_write()
|
||||
|
||||
|
|
Loading…
Reference in New Issue