Skip to content

Commit

Permalink
Merge pull request #1014 from philborman/master
Browse files Browse the repository at this point in the history
Column tidying, removed some buttons
  • Loading branch information
philborman authored Aug 29, 2017
2 parents 51d3a16 + df7a41a commit d51d4df
Show file tree
Hide file tree
Showing 9 changed files with 74 additions and 46 deletions.
7 changes: 6 additions & 1 deletion data/interfaces/bookstrap/logs.html
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,13 @@ <h1>${title}</h1>
var oTable = $('#log_table').DataTable({
"bAutoWidth": false,
"aoColumnDefs": [
%if lazylibrarian.LOGLEVEL >= 2:
{ "sWidth": "3%", "aTargets": [ 0,1,2,3,4,5 ] },
{ "sWidth": "60%", "aTargets": [ 6 ] }
%else:
{ "sWidth": "3%", "aTargets": [ 0,1 ] },
{ "sWidth": "60%", "aTargets": [ 6 ] }
%endif
],
"stateSave": true,
"order": [[ 0, 'desc' ]],
Expand All @@ -94,7 +99,7 @@ <h1>${title}</h1>
} else {
$('td', nRow).closest('tr').addClass("text-info");
}
%if lazylibrarian.LOGLEVEL < 3:
%if lazylibrarian.LOGLEVEL < 2:
$('td', nRow).eq(2).addClass("hidden");
$('td', nRow).eq(3).addClass("hidden");
$('td', nRow).eq(4).addClass("hidden");
Expand Down
8 changes: 6 additions & 2 deletions data/interfaces/bookstrap/members.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ <h1>${series['AuthorName']} : ${title}</h1>
%endif
<th class="date col-xs-1 text-center">Num</th>
<th class="status text-center">Status</th>
<th class="stars text-center no-sort">Edit Details</th>
</tr>
</thead>
<tbody>
Expand All @@ -73,8 +72,13 @@ <h1>${series['AuthorName']} : ${title}</h1>
<td class="authorname hidden">${result['AuthorName']}</td>
%endif
<td class="date text-center">${result['SeriesNum']}</td>
%if result['Status'] == 'Open':
<td class="status text-center">
<a class="button green btn btn-xs btn-warning" href="openBook?bookid=${result['BookID']}&library=eBook"
target="_self"><i class="fa fa-book"></i>Open</a></td>
%else:
<td class="status text-center">${result['Status']}</td>
<td class="stars text-center"><a class="b btn btn-xs btn-success" href="editBook?bookid=${result['BookID']}" title="Select"><i class="fa fa-book"></i> Edit</a></p>
%endif
</td>
</tr>
%endfor
Expand Down
9 changes: 4 additions & 5 deletions data/interfaces/bookstrap/series.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ <h1>${title}</h1>
</div>
<input class="btn btn-sm btn-default" type="submit" value="Manage" />
%if lazylibrarian.CONFIG['TOGGLES'] == True:
&nbsp;&nbsp;Toggle: <a class="toggle-vis" data-column="1">Author</a> - <a class="toggle-vis" data-column="2">Series</a> - <a class="toggle-vis" data-column="3">Status</a> - <a class="toggle-vis" data-column="4">Select</a>
&nbsp;&nbsp;Toggle: <a class="toggle-vis" data-column="1">Author</a> - <a class="toggle-vis" data-column="2">Series</a> - <a class="toggle-vis" data-column="3">Status</a>
%endif
</form>
<br>
Expand All @@ -58,7 +58,6 @@ <h1>${title}</h1>
<th class="authorname">Author</th>
<th class="series">Series Name</th>
<th class="status text-center">Status</th>
<th class="stars text-center">Select</th>
</tr>
</thead>
</table>
Expand Down Expand Up @@ -91,8 +90,8 @@ <h1>${title}</h1>
{ targets: [0], 'render': function(data, type, row) {
return '<input type="checkbox" name="' + data + '" class="checkbox" />';}
},
{ targets: [4], 'render': function(data, type, row) {
return '<a class="b btn btn-xs btn-success" href="seriesMembers?seriesid=' + row[5] + '" title="Select"><i class="fa"></i>Show</a>';}
{ targets: [2], 'render': function(data, type, row) {
return '<a href="seriesMembers?seriesid=' + row[5] + '" target="_new">' + row[2] + '</a>';}
}
],
"oLanguage": {
Expand All @@ -112,7 +111,7 @@ <h1>${title}</h1>
"fnRowCallback": function (nRow, aData, iDisplayIndex, iDisplayIndexFull) {
$('td', nRow).eq(0).addClass("text-center");
$('td', nRow).eq(3).addClass("text-center");
$('td', nRow).eq(4).addClass("text-center");
//$('td', nRow).eq(4).addClass("text-center");
// hide author,status on small devices
//$('td', nRow).eq(1).addClass('hidden-xs');
//$('td', nRow).eq(3).addClass('hidden-xs');
Expand Down
7 changes: 6 additions & 1 deletion data/interfaces/default/logs.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,13 @@ <h1>&nbsp;&nbsp;${title}</h1>
{
"bAutoWidth": false,
"aoColumnDefs": [
%if lazylibrarian.LOGLEVEL >= 2:
{ "sWidth": "3%", "aTargets": [ 0,1,2,3,4,5 ] },
{ "sWidth": "60%", "aTargets": [ 6 ] }
%else:
{ "sWidth": "3%", "aTargets": [ 0,1 ] },
{ "sWidth": "60%", "aTargets": [ 6 ] }
%endif
],
"oLanguage": {
"sSearch":"",
Expand Down Expand Up @@ -89,7 +94,7 @@ <h1>&nbsp;&nbsp;${title}</h1>
{
$('td', nRow).eq(0).addClass('hidden');
}
%if lazylibrarian.LOGLEVEL < 3:
%if lazylibrarian.LOGLEVEL < 2:
$('td', nRow).eq(2).addClass("hidden");
$('td', nRow).eq(3).addClass("hidden");
$('td', nRow).eq(4).addClass("hidden");
Expand Down
3 changes: 3 additions & 0 deletions lazylibrarian/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,15 @@ def fetchURL(URL, headers=None, retry=True):
request.add_header(item, headers[item])
try:
resp = urllib2.urlopen(request, timeout=30)

if str(resp.getcode()).startswith("2"): # (200 OK etc)
try:
result = resp.read()
except socket.error as e:
return str(e), False
return result, True
if int(lazylibrarian.LOGLEVEL) > 2:
logger.debug(resp.info())
return str(resp.getcode()), False
except socket.timeout as e:
if not retry:
Expand Down
65 changes: 32 additions & 33 deletions lazylibrarian/dbupgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ def dbupgrade(db_current_version):
db_v21, db_v22
]
for index, upgrade_function in enumerate(upgradefunctions):
if index+2 <= db_current_version:
if index + 2 <= db_current_version:
upgrade_function(myDB, upgradelog)

# Now do any non-version-specific tidying
Expand Down Expand Up @@ -849,26 +849,26 @@ def db_v20(myDB, upgradelog):
lazylibrarian.UPDATE_MSG = 'Adding BookLibrary to book table'
upgradelog.write("%s v20: %s\n" % (time.ctime(), lazylibrarian.UPDATE_MSG))
myDB.action('ALTER TABLE books ADD COLUMN BookLibrary TEXT')
else:

lazylibrarian.UPDATE_MSG = 'Updating BookLibrary dates'
upgradelog.write("%s v20: %s\n" % (time.ctime(), lazylibrarian.UPDATE_MSG))
books = myDB.select('SELECT BookID,BookFile from books')
cnt = 0
mod = 0
if books:
tot = len(books)
for book in books:
cnt += 1
lazylibrarian.UPDATE_MSG = "Updating BookLibrary date: %s of %s" % (cnt, tot)
if book['BookFile'] and os.path.isfile(book['BookFile']):
mod += 1
t = os.path.getctime(book['BookFile'])
filedate = datetime.datetime.utcfromtimestamp(int(t)).strftime("%Y-%m-%d %H:%M:%S")
myDB.action('UPDATE books SET BookLibrary=? WHERE BookID=?',
(filedate, book['BookID']))

lazylibrarian.UPDATE_MSG = 'Adding BookLibrary date complete, %s/%s books' % (mod, cnt)
upgradelog.write("%s v20: %s\n" % (time.ctime(), lazylibrarian.UPDATE_MSG))
books = myDB.select('SELECT BookID,BookFile from books')
cnt = 0
mod = 0
if books:
tot = len(books)
for book in books:
cnt += 1
lazylibrarian.UPDATE_MSG = "Updating BookLibrary date: %s of %s" % (cnt, tot)
if book['BookFile'] and os.path.isfile(book['BookFile']):
mod += 1
t = os.path.getctime(book['BookFile'])
filedate = datetime.datetime.utcfromtimestamp(int(t)).strftime("%Y-%m-%d %H:%M:%S")
myDB.action('UPDATE books SET BookLibrary=? WHERE BookID=?',
(filedate, book['BookID']))

lazylibrarian.UPDATE_MSG = 'Adding BookLibrary date complete, %s/%s books' % (mod, cnt)
upgradelog.write("%s v20: %s\n" % (time.ctime(), lazylibrarian.UPDATE_MSG))
upgradelog.write("%s v20: complete\n" % time.ctime())


Expand All @@ -880,20 +880,19 @@ def db_v21(myDB, upgradelog):
myDB.action('ALTER TABLE books ADD COLUMN AudioLibrary TEXT')
myDB.action('ALTER TABLE books ADD COLUMN AudioStatus TEXT')
myDB.action('UPDATE books SET AudioStatus="Skipped"')
lazylibrarian.UPDATE_MSG = 'Creating downloads table'
upgradelog.write("%s v21: %s\n" % (time.ctime(), lazylibrarian.UPDATE_MSG))
myDB.action('CREATE TABLE IF NOT EXISTS downloads (Count INTEGER, Provider TEXT)')
downloads = myDB.select('SELECT NZBprov from wanted WHERE Status="Processed"')
for download in downloads:
entry = myDB.match('SELECT Count FROM downloads where Provider=?', (download['NZBprov'],))
if entry:
counter = int(entry['Count'])
myDB.action('UPDATE downloads SET Count=? WHERE Provider=?',
(counter + 1, download['NZBprov']))
else:
myDB.action('INSERT into downloads (Count, Provider) VALUES (?, ?)',
(1, download['NZBprov']))

lazylibrarian.UPDATE_MSG = 'Creating downloads table'
upgradelog.write("%s v21: %s\n" % (time.ctime(), lazylibrarian.UPDATE_MSG))
myDB.action('CREATE TABLE IF NOT EXISTS downloads (Count INTEGER, Provider TEXT)')
downloads = myDB.select('SELECT NZBprov from wanted WHERE Status="Processed"')
for download in downloads:
entry = myDB.match('SELECT Count FROM downloads where Provider=?', (download['NZBprov'],))
if entry:
counter = int(entry['Count'])
myDB.action('UPDATE downloads SET Count=? WHERE Provider=?',
(counter + 1, download['NZBprov']))
else:
myDB.action('INSERT into downloads (Count, Provider) VALUES (?, ?)',
(1, download['NZBprov']))
upgradelog.write("%s v21: complete\n" % time.ctime())


Expand Down
10 changes: 8 additions & 2 deletions lazylibrarian/librarysync.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,9 +379,15 @@ def LibraryScan(startdir=None, library='eBook', authid=None, remove=True):
"\\$\\T\\i\\t\\l\\e", "(?P<book>.*?)") + '\.[' + booktypes + ']'
pattern = re.compile(matchString, re.VERBOSE)

# ensure startdir is str as os.walk can fail if it tries to convert a subdir or file
# try to ensure startdir is str as os.walk can fail if it tries to convert a subdir or file
# to utf-8 and fails (eg scandinavian characters in ascii 8bit)
for r, d, f in os.walk(str(startdir)):
if isinstance(startdir, unicode):
try:
startdir = startdir.encode('ASCII')
except UnicodeEncodeError:
logger.debug('Unicode error converting %s' % repr(startdir))

for r, d, f in os.walk(startdir):
for directory in d:
# prevent magazine being scanned
if directory.startswith("_") or directory.startswith("."):
Expand Down
10 changes: 9 additions & 1 deletion lazylibrarian/magazinescan.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,15 @@ def magazineScan():
match = matchString.replace("\\$\\I\\s\\s\\u\\e\\D\\a\\t\\e", "(?P<issuedate>.*?)") + '\.[' + booktypes + ']'
date_pattern = re.compile(match, re.VERBOSE)

for dirname, dirnames, filenames in os.walk(str(mag_path)):
# try to ensure startdir is str as os.walk can fail if it tries to convert a subdir or file
# to utf-8 and fails (eg scandinavian characters in ascii 8bit)
if isinstance(mag_path, unicode):
try:
mag_path = mag_path.encode('ASCII')
except UnicodeEncodeError:
logger.debug('Unicode error converting %s' % repr(mag_path))

for dirname, dirnames, filenames in os.walk(mag_path):
for fname in filenames[:]:
# maybe not all magazines will be pdf?
if is_valid_booktype(fname, booktype='mag'):
Expand Down
1 change: 0 additions & 1 deletion lazylibrarian/webStart.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@


def initialize(options=None):

if options is None:
options = {}
https_enabled = options['https_enabled']
Expand Down

0 comments on commit d51d4df

Please sign in to comment.