Skip to content

Commit

Permalink
Merge pull request #1103 from philborman/master
Browse files Browse the repository at this point in the history
config.ini in debug.zip
  • Loading branch information
philborman authored Oct 31, 2017
2 parents a4bef92 + 3f2228b commit b7ca967
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 4 deletions.
27 changes: 23 additions & 4 deletions lazylibrarian/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@ def logHeader():
header += 'OpenSSL missing module/attribute: %s\n' % e

try:
# get_extention_for_class method added in `cryptography==1.1`; not available in older versions
# get_extension_for_class method added in `cryptography==1.1`; not available in older versions
# but need cryptography >= 1.3.4 for access from pyopenssl >= 0.14
import cryptography
from cryptography.x509.extensions import Extensions
Expand All @@ -603,9 +603,9 @@ def saveLog():

basename = os.path.join(lazylibrarian.CONFIG['LOGDIR'], 'lazylibrarian.log')
outfile = os.path.join(lazylibrarian.CONFIG['LOGDIR'], 'debug')
passchars = string.ascii_letters + string.digits + '_/' # _/ used by slack and googlebooks
redactlist = ['api -> ', 'apikey -> ', 'pass -> ', 'password -> ', 'token -> ', 'using api [',
'apikey=', 'key=', 'apikey%3D', "apikey': u'", "apikey': ', 'keys ->'"]
passchars = string.ascii_letters + string.digits + ':_/' # _/ used by slack, telegram and googlebooks
redactlist = ['api -> ', 'key -> ', 'secret -> ', 'pass -> ', 'password -> ', 'token -> ', 'keys ->',
'&r=', 'using api [', 'apikey=', 'key=', 'apikey%3D', "apikey': u'", "apikey': ',"]
with open(outfile + '.tmp', 'w') as out:
nextfile = True
extn = 0
Expand Down Expand Up @@ -642,6 +642,25 @@ def saveLog():
linecount += 1
extn += 1

if os.path.exists(lazylibrarian.CONFIGFILE):
out.write('---END-CONFIG---------------------------------\n')
for line in reverse_readline(lazylibrarian.CONFIGFILE):
for item in redactlist:
item = item.replace('->', '=')
startpos = line.find(item)
if startpos >= 0:
startpos += len(item)
endpos = startpos
while endpos < len(line) and not line[endpos] in passchars:
endpos += 1
while endpos < len(line) and line[endpos] in passchars:
endpos += 1
if endpos != startpos:
line = line[:startpos] + '<redacted>' + line[endpos:]
redacts += 1
out.write("%s\n" % line)
out.write('---CONFIG-------------------------------------\n')

with open(outfile + '.log', 'w') as logfile:
logfile.write(logHeader())
lines = 0
Expand Down
1 change: 1 addition & 0 deletions lazylibrarian/postprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -1121,6 +1121,7 @@ def processDestination(pp_path=None, dest_path=None, authorname=None, bookname=N
return False, 'calibredb import failed, %s %s' % (type(e).__name__, str(e))
else:
# we are copying the files ourselves, either it's audiobook, magazine or we don't want to use calibre
logger.debug("BookType: %s, calibredb: [%s]" % (booktype, lazylibrarian.CONFIG['IMP_CALIBREDB']))
if not os.path.exists(dest_path):
logger.debug('%s does not exist, so it\'s safe to create it' % dest_path)
elif not os.path.isdir(dest_path):
Expand Down
6 changes: 6 additions & 0 deletions lazylibrarian/webServe.py
Original file line number Diff line number Diff line change
Expand Up @@ -642,6 +642,9 @@ def series(self, AuthorID=None, whichStatus=None):
match = myDB.match('SELECT AuthorName from authors WHERE AuthorID=?', (AuthorID,))
if match:
title = "%s Series" % match['AuthorName']
if '&' in title and '&amp;' not in title:
title = title.replace('&', '&amp;')

return serve_template(templatename="series.html", title=title, authorid=AuthorID, series=[],
whichStatus=whichStatus)

Expand Down Expand Up @@ -2120,6 +2123,9 @@ def issuePage(self, title):
if not lazylibrarian.CONFIG['MAG_IMG'] or lazylibrarian.CONFIG['IMP_CONVERT'] == 'None':
covercount = 0

if '&' in title and '&amp;' not in title: # could use htmlparser but seems overkill for just '&'
title = title.replace('&', '&amp;')

return serve_template(templatename="issues.html", title=title, issues=mod_issues, covercount=covercount)

@cherrypy.expose
Expand Down

0 comments on commit b7ca967

Please sign in to comment.