%if lazylibrarian.CONFIG['TOGGLES'] == True:
diff --git a/example_preprocessor.py b/example_preprocessor.py
index 5c0b200cb..dec339932 100755
--- a/example_preprocessor.py
+++ b/example_preprocessor.py
@@ -25,7 +25,7 @@
def makeBytestr(txt):
# convert unicode to bytestring, needed for os.walk and os.listdir
# listdir falls over if given unicode startdir and a filename in a subdir can't be decoded to ascii
- if txt is None or not txt:
+ if not txt:
return b''
elif not isinstance(txt, text_type): # nothing to do if already bytestring
return txt
@@ -41,7 +41,7 @@ def makeBytestr(txt):
def makeUnicode(txt):
# convert a bytestring to unicode, don't know what encoding it might be so try a few
# it could be a file on a windows filesystem, unix...
- if txt is None or not txt:
+ if not txt:
return u''
elif isinstance(txt, text_type):
return txt
@@ -108,7 +108,8 @@ def makeUnicode(txt):
for ftype in wanted_formats:
if not os.path.exists(os.path.join(bookfolder, basename + ftype)):
pplog.write("No %s\n" % ftype)
- params = [converter, os.path.join(bookfolder, sourcefile), os.path.join(bookfolder, basename + ftype)]
+ params = [converter, os.path.join(bookfolder, sourcefile),
+ os.path.join(bookfolder, basename + ftype)]
try:
res = subprocess.check_output(params, stderr=subprocess.STDOUT)
if created:
diff --git a/lazylibrarian/api.py b/lazylibrarian/api.py
index 744076252..ff6096f11 100644
--- a/lazylibrarian/api.py
+++ b/lazylibrarian/api.py
@@ -155,7 +155,7 @@
'writeOPF': '&id= [&refresh] write out an opf file for a bookid, optionally overwrite existing opf',
'writeAllOPF': '[&refresh] write out opf files for all books, optionally overwrite existing opf',
'renameAudio': '&id Rename an audiobook using configured pattern',
- 'playlistAudio': '&id Create playlist for an audiobook',
+ 'createPlaylist': '&id Create playlist for an audiobook',
'nameVars': '&id Show the name variables that would be used for a bookid',
'showCaps': '&provider= get a list of capabilities from a provider',
'calibreList': '[&toread=] [&read=] get a list of books in calibre library',
@@ -347,7 +347,7 @@ def _renameAudio(self, **kwargs):
return
self.data = audioProcess(kwargs['id'], rename=True)
- def _playlistAudio(self, **kwargs):
+ def _createPlaylist(self, **kwargs):
if 'id' not in kwargs:
self.data = 'Missing parameter: id'
return
diff --git a/lazylibrarian/directparser.py b/lazylibrarian/directparser.py
index dbdc9666d..e19af089b 100644
--- a/lazylibrarian/directparser.py
+++ b/lazylibrarian/directparser.py
@@ -55,7 +55,7 @@ def redirect_url(genhost, url):
def GEN(book=None, prov=None, test=False):
errmsg = ''
provider = "libgen.io"
- if prov is None:
+ if not prov:
prov = 'GEN'
host = lazylibrarian.CONFIG[prov + '_HOST']
if not host.startswith('http'):
diff --git a/lazylibrarian/formatter.py b/lazylibrarian/formatter.py
index a792f63ae..d29ec802f 100644
--- a/lazylibrarian/formatter.py
+++ b/lazylibrarian/formatter.py
@@ -358,7 +358,7 @@ def md5_utf8(txt):
def makeUnicode(txt):
# convert a bytestring to unicode, don't know what encoding it might be so try a few
# it could be a file on a windows filesystem, unix...
- if txt is None or not txt:
+ if not txt:
return u''
elif isinstance(txt, text_type):
return txt
@@ -375,7 +375,7 @@ def makeUnicode(txt):
def makeBytestr(txt):
# convert unicode to bytestring, needed for os.walk and os.listdir
# listdir falls over if given unicode startdir and a filename in a subdir can't be decoded to ascii
- if txt is None or not txt:
+ if not txt:
return b''
elif not isinstance(txt, text_type): # nothing to do if already bytestring
return txt
diff --git a/lazylibrarian/gb.py b/lazylibrarian/gb.py
index ce4905d32..53e124a5c 100644
--- a/lazylibrarian/gb.py
+++ b/lazylibrarian/gb.py
@@ -118,7 +118,7 @@ def find_results(self, searchterm=None, queue=None):
try:
jsonresults, in_cache = gb_json_request(URL)
- if jsonresults is None:
+ if not jsonresults:
number_results = 0
else:
if not in_cache:
@@ -285,7 +285,7 @@ def get_author_books(self, authorid=None, authorname=None, bookstatus="Skipped",
try:
jsonresults, in_cache = gb_json_request(URL, useCache=not refresh)
- if jsonresults is None:
+ if not jsonresults:
number_results = 0
else:
if not in_cache:
@@ -620,7 +620,7 @@ def find_book(self, bookid=None, bookstatus=None, audiostatus=None):
str(bookid) + "?key=" + lazylibrarian.CONFIG['GB_API']
jsonresults, in_cache = gb_json_request(URL)
- if jsonresults is None:
+ if not jsonresults:
logger.debug('No results found for %s' % bookid)
return
diff --git a/lazylibrarian/images.py b/lazylibrarian/images.py
index 6d45f48c4..a7c64ae56 100644
--- a/lazylibrarian/images.py
+++ b/lazylibrarian/images.py
@@ -510,7 +510,7 @@ def createMagCovers(refresh=False):
def createMagCover(issuefile=None, refresh=False, pagenum=1):
if not lazylibrarian.CONFIG['IMP_MAGCOVER'] or not pagenum:
return 'unwanted'
- if issuefile is None or not os.path.isfile(issuefile):
+ if not issuefile or not os.path.isfile(issuefile):
logger.debug('No issuefile %s' % issuefile)
return 'failed'
diff --git a/lazylibrarian/postprocess.py b/lazylibrarian/postprocess.py
index fc9902aed..796879bde 100644
--- a/lazylibrarian/postprocess.py
+++ b/lazylibrarian/postprocess.py
@@ -733,6 +733,19 @@ def processDir(reset=False, startdir=None, ignoreclient=False):
except Exception as why:
logger.error("Unable to rename %s, %s %s" %
(pp_path, type(why).__name__, str(why)))
+ if not os.access(pp_path, os.R_OK):
+ logger.error("%s is not readable" % pp_path)
+ if not os.access(pp_path, os.W_OK):
+ logger.error("%s is not writeable" % pp_path)
+ if not os.access(pp_path, os.X_OK):
+ logger.error("%s is not executable" % pp_path)
+ parent = os.path.dirname(pp_path)
+ try:
+ with open(os.path.join(parent, 'll_temp'), 'w') as f:
+ f.write('test')
+ os.remove(os.path.join(parent, 'll_temp'))
+ except Exception as why:
+ logger.error("Directory %s is not writeable: %s" % (parent, why))
logger.warn('Residual files remain in %s' % pp_path)
ppcount += check_residual(download_dir)
@@ -1384,7 +1397,19 @@ def process_book(pp_path=None, bookID=None):
_ = safe_move(pp_path, pp_path + '.fail')
logger.warn('Residual files remain in %s.fail' % pp_path)
except Exception as e:
- logger.error("[importBook] Unable to rename %s, %s %s" % (pp_path, type(e).__name__, str(e)))
+ logger.error("Unable to rename %s, %s %s" %
+ (pp_path, type(e).__name__, str(e)))
+ if not os.access(pp_path, os.R_OK):
+ logger.error("%s is not readable" % pp_path)
+ if not os.access(pp_path, os.W_OK):
+ logger.error("%s is not writeable" % pp_path)
+ parent = os.path.dirname(pp_path)
+ try:
+ with open(os.path.join(parent, 'll_temp'), 'w') as f:
+ f.write('test')
+ os.remove(os.path.join(parent, 'll_temp'))
+ except Exception as why:
+ logger.error("Directory %s is not writeable: %s" % (parent, why))
logger.warn('Residual files remain in %s' % pp_path)
was_snatched = myDB.match('SELECT NZBurl FROM wanted WHERE BookID=? and Status="Snatched"', (bookID,))
@@ -1660,6 +1685,17 @@ def processDestination(pp_path=None, dest_path=None, authorname=None, bookname=N
if is_valid_booktype(destfile, booktype=booktype):
newbookfile = destfile
except Exception as why:
+ if not os.access(srcfile, os.R_OK):
+ logger.error("File [%s] is not readable" % srcfile)
+ if not os.access(srcfile, os.W_OK):
+ logger.error("File [%s] is not writeable" % srcfile)
+ parent = os.path.dirname(destfile)
+ try:
+ with open(os.path.join(parent, 'll_temp'), 'w') as f:
+ f.write('test')
+ os.remove(os.path.join(parent, 'll_temp'))
+ except Exception as why:
+ logger.error("Directory [%s] is not writeable: %s" % (parent, why))
return False, "Unable to %s file %s to %s: %s %s" % \
(typ, srcfile, destfile, type(why).__name__, str(why))
else:
diff --git a/lazylibrarian/resultlist.py b/lazylibrarian/resultlist.py
index be7341524..0e16986c9 100644
--- a/lazylibrarian/resultlist.py
+++ b/lazylibrarian/resultlist.py
@@ -104,7 +104,7 @@ def findBestResult(resultlist, book, searchtype, source):
rejected = False
url = res[prefix + 'url']
- if url is None:
+ if not url:
rejected = True
logger.debug("Rejecting %s, no URL found" % resultTitle)
diff --git a/lazylibrarian/searchbook.py b/lazylibrarian/searchbook.py
index 9552cf9c7..53a5296b1 100644
--- a/lazylibrarian/searchbook.py
+++ b/lazylibrarian/searchbook.py
@@ -44,7 +44,7 @@ def search_book(books=None, library=None):
try:
threadname = threading.currentThread().name
if "Thread-" in threadname:
- if books is None:
+ if not books:
threading.currentThread().name = "SEARCHALLBOOKS"
else:
threading.currentThread().name = "SEARCHBOOKS"
@@ -53,7 +53,7 @@ def search_book(books=None, library=None):
searchlist = []
searchbooks = []
- if books is None:
+ if not books:
# We are performing a backlog search
cmd = 'SELECT BookID, AuthorName, Bookname, BookSub, BookAdded, books.Status, AudioStatus '
cmd += 'from books,authors WHERE (books.Status="Wanted" OR AudioStatus="Wanted") '
diff --git a/lazylibrarian/searchmag.py b/lazylibrarian/searchmag.py
index f7f52e750..0bd855958 100644
--- a/lazylibrarian/searchmag.py
+++ b/lazylibrarian/searchmag.py
@@ -40,7 +40,7 @@ def search_magazines(mags=None, reset=False):
try:
threadname = threading.currentThread().name
if "Thread-" in threadname:
- if mags is None:
+ if not mags:
threading.currentThread().name = "SEARCHALLMAG"
else:
threading.currentThread().name = "SEARCHMAG"
@@ -48,7 +48,7 @@ def search_magazines(mags=None, reset=False):
myDB = database.DBConnection()
searchlist = []
- if mags is None: # backlog search
+ if not mags: # backlog search
searchmags = myDB.select('SELECT Title, Regex, DateType, LastAcquired, \
IssueDate from magazines WHERE Status="Active"')
else:
diff --git a/lazylibrarian/searchrss.py b/lazylibrarian/searchrss.py
index fe9a72e36..7e296cb3b 100644
--- a/lazylibrarian/searchrss.py
+++ b/lazylibrarian/searchrss.py
@@ -161,7 +161,7 @@ def search_rss_book(books=None, library=None):
try:
threadname = threading.currentThread().name
if "Thread-" in threadname:
- if books is None:
+ if not books:
threading.currentThread().name = "SEARCHALLRSS"
else:
threading.currentThread().name = "SEARCHRSS"
@@ -169,7 +169,7 @@ def search_rss_book(books=None, library=None):
myDB = database.DBConnection()
searchbooks = []
- if books is None:
+ if not books:
# We are performing a backlog search
cmd = 'SELECT BookID, AuthorName, Bookname, BookSub, BookAdded, books.Status, AudioStatus '
cmd += 'from books,authors WHERE (books.Status="Wanted" OR AudioStatus="Wanted") '
diff --git a/lazylibrarian/webServe.py b/lazylibrarian/webServe.py
index 2e012f35f..bbcb38e4e 100644
--- a/lazylibrarian/webServe.py
+++ b/lazylibrarian/webServe.py
@@ -956,13 +956,13 @@ def config(self):
for mag in magazines:
title = mag['Title']
regex = mag['Regex']
- if regex is None:
+ if not regex:
regex = ""
reject = mag['Reject']
- if reject is None:
+ if not reject:
reject = ""
datetype = mag['DateType']
- if datetype is None:
+ if not datetype:
datetype = ""
coverpage = check_int(mag['CoverPage'], 1)
mags_list.append({
@@ -1212,7 +1212,7 @@ def configUpdate(self, **kwargs):
@cherrypy.expose
def search(self, name):
self.label_thread('SEARCH')
- if name is None or not name:
+ if not name:
raise cherrypy.HTTPRedirect("home")
myDB = database.DBConnection()
@@ -3289,59 +3289,57 @@ def markIssues(self, action=None, **args):
title = ''
args.pop('book_table_length', None)
- for item in args:
- issue = myDB.match('SELECT IssueFile,Title,IssueDate from issues WHERE IssueID=?', (item,))
- if issue:
- title = issue['Title']
- if action == 'NewCover':
- cmd = 'select coverpage from magazines where Title=?'
- res = myDB.match(cmd, (title,))
- if res:
- createMagCover(issue['IssueFile'], refresh=True, pagenum=check_int(res['coverpage'], 1))
- if action == "Delete":
- result = self.deleteIssue(issue['IssueFile'])
- if result:
- logger.info('Issue %s of %s deleted from disc' % (issue['IssueDate'], issue['Title']))
- if action == "Remove" or action == "Delete":
- myDB.action('DELETE from issues WHERE IssueID=?', (item,))
- logger.info('Issue %s of %s removed from database' % (issue['IssueDate'], issue['Title']))
- # Set magazine_issuedate to issuedate of most recent issue we have
- # Set latestcover to most recent issue cover
- # Set magazine_lastacquired to acquired date of most recent issue we have
- # Set magazine_added to acquired date of earliest issue we have
- cmd = 'select IssueDate,IssueAcquired,IssueFile from issues where title=?'
- cmd += ' order by IssueDate '
- newest = myDB.match(cmd + 'DESC', (title,))
- oldest = myDB.match(cmd + 'ASC', (title,))
- controlValueDict = {'Title': title}
- if newest and oldest:
- old_acquired = ''
- new_acquired = ''
- cover = ''
- issuefile = newest['IssueFile']
- if os.path.exists(issuefile):
- cover = os.path.splitext(issuefile)[0] + '.jpg'
- mtime = os.path.getmtime(issuefile)
- new_acquired = datetime.date.isoformat(datetime.date.fromtimestamp(mtime))
- issuefile = oldest['IssueFile']
- if os.path.exists(issuefile):
- mtime = os.path.getmtime(issuefile)
- old_acquired = datetime.date.isoformat(datetime.date.fromtimestamp(mtime))
-
- newValueDict = {
- 'IssueDate': newest['IssueDate'],
- 'LatestCover': cover,
- 'LastAcquired': new_acquired,
- 'MagazineAdded': old_acquired
- }
- else:
- newValueDict = {
- 'IssueDate': '',
- 'LastAcquired': '',
- 'LatestCover': '',
- 'MagazineAdded': ''
- }
- myDB.upsert("magazines", newValueDict, controlValueDict)
+ if action:
+ for item in args:
+ issue = myDB.match('SELECT IssueFile,Title,IssueDate from issues WHERE IssueID=?', (item,))
+ if issue:
+ title = issue['Title']
+ if 'reCover' in action:
+ createMagCover(issue['IssueFile'], refresh=True, pagenum=check_int(action[-1], 1))
+ if action == "Delete":
+ result = self.deleteIssue(issue['IssueFile'])
+ if result:
+ logger.info('Issue %s of %s deleted from disc' % (issue['IssueDate'], issue['Title']))
+ if action == "Remove" or action == "Delete":
+ myDB.action('DELETE from issues WHERE IssueID=?', (item,))
+ logger.info('Issue %s of %s removed from database' % (issue['IssueDate'], issue['Title']))
+ # Set magazine_issuedate to issuedate of most recent issue we have
+ # Set latestcover to most recent issue cover
+ # Set magazine_lastacquired to acquired date of most recent issue we have
+ # Set magazine_added to acquired date of earliest issue we have
+ cmd = 'select IssueDate,IssueAcquired,IssueFile from issues where title=?'
+ cmd += ' order by IssueDate '
+ newest = myDB.match(cmd + 'DESC', (title,))
+ oldest = myDB.match(cmd + 'ASC', (title,))
+ controlValueDict = {'Title': title}
+ if newest and oldest:
+ old_acquired = ''
+ new_acquired = ''
+ cover = ''
+ issuefile = newest['IssueFile']
+ if os.path.exists(issuefile):
+ cover = os.path.splitext(issuefile)[0] + '.jpg'
+ mtime = os.path.getmtime(issuefile)
+ new_acquired = datetime.date.isoformat(datetime.date.fromtimestamp(mtime))
+ issuefile = oldest['IssueFile']
+ if os.path.exists(issuefile):
+ mtime = os.path.getmtime(issuefile)
+ old_acquired = datetime.date.isoformat(datetime.date.fromtimestamp(mtime))
+
+ newValueDict = {
+ 'IssueDate': newest['IssueDate'],
+ 'LatestCover': cover,
+ 'LastAcquired': new_acquired,
+ 'MagazineAdded': old_acquired
+ }
+ else:
+ newValueDict = {
+ 'IssueDate': '',
+ 'LastAcquired': '',
+ 'LatestCover': '',
+ 'MagazineAdded': ''
+ }
+ myDB.upsert("magazines", newValueDict, controlValueDict)
if title:
raise cherrypy.HTTPRedirect("issuePage?title=%s" % quote_plus(title))
else: