mirror of
https://github.com/janeczku/calibre-web
synced 2024-12-25 09:30:31 +00:00
Code cosmetics
This commit is contained in:
parent
1fdb7dc497
commit
74e93e1cdf
@ -88,10 +88,10 @@ def make_mobi(book_id, calibrepath):
|
||||
if os.path.exists(file_path + u".epub"):
|
||||
try:
|
||||
p = subprocess.Popen((kindlegen + " \"" + file_path + u".epub\"").encode(sys.getfilesystemencoding()),
|
||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
|
||||
except:
|
||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
except Exception:
|
||||
error_message = _(u"kindlegen failed, no excecution permissions")
|
||||
app.logger.error("make_mobi: "+error_message)
|
||||
app.logger.error("make_mobi: " + error_message)
|
||||
return error_message, RET_FAIL
|
||||
|
||||
# Poll process for new output until finished
|
||||
@ -226,9 +226,11 @@ def send_mail(book_id, kindle_mail, calibrepath):
|
||||
msg.attach(get_attachment(formats['mobi']))
|
||||
elif 'epub' in formats:
|
||||
data, resultCode = make_mobi(book.id, calibrepath)
|
||||
app.logger.error = (data)
|
||||
if resultCode == RET_SUCCESS:
|
||||
msg.attach(get_attachment(data))
|
||||
else:
|
||||
|
||||
return data #_("Could not convert epub to mobi")
|
||||
elif 'pdf' in formats:
|
||||
msg.attach(get_attachment(formats['pdf']))
|
||||
@ -305,7 +307,7 @@ def delete_book_gdrive(book):
|
||||
def update_dir_stucture(book_id, calibrepath):
|
||||
db.session.connection().connection.connection.create_function("title_sort", 1, db.title_sort)
|
||||
book = db.session.query(db.Books).filter(db.Books.id == book_id).first()
|
||||
path = os.path.join(calibrepath, book.path)#.replace('/',os.path.sep)).replace('\\',os.path.sep)
|
||||
path = os.path.join(calibrepath, book.path)
|
||||
|
||||
authordir = book.path.split('/')[0]
|
||||
new_authordir = get_valid_filename(book.authors[0].name)
|
||||
@ -333,7 +335,7 @@ def update_dir_structure_gdrive(book_id):
|
||||
new_authordir = get_valid_filename(book.authors[0].name)
|
||||
titledir = book.path.split('/')[1]
|
||||
new_titledir = get_valid_filename(book.title) + " (" + str(book_id) + ")"
|
||||
|
||||
|
||||
if titledir != new_titledir:
|
||||
print (titledir)
|
||||
gFile=gd.getFileFromEbooksFolder(web.Gdrive.Instance().drive,os.path.dirname(book.path),titledir)
|
||||
@ -400,8 +402,8 @@ class Updater(threading.Thread):
|
||||
for file in delete_files:
|
||||
parts = file.split(os.sep)
|
||||
sub = ''
|
||||
for i in range(len(parts)):
|
||||
sub = os.path.join(sub, parts[i])
|
||||
for part in parts:
|
||||
sub = os.path.join(sub, part)
|
||||
if sub == '':
|
||||
sub = os.sep
|
||||
count = 0
|
||||
@ -432,7 +434,7 @@ class Updater(threading.Thread):
|
||||
logging.getLogger('cps.web').debug('Update on OS-System : ' + sys.platform)
|
||||
new_permissions = os.stat(root_dst_dir)
|
||||
# print new_permissions
|
||||
for src_dir, dirs, files in os.walk(root_src_dir):
|
||||
for src_dir, __, files in os.walk(root_src_dir):
|
||||
dst_dir = src_dir.replace(root_src_dir, root_dst_dir, 1)
|
||||
if not os.path.exists(dst_dir):
|
||||
os.makedirs(dst_dir)
|
||||
|
18
cps/ub.py
18
cps/ub.py
@ -349,13 +349,6 @@ class Config:
|
||||
else:
|
||||
return False
|
||||
|
||||
def role_delete_books(self):
|
||||
if self.config_default_role is not None:
|
||||
return True if self.config_default_role & ROLE_DELETE_BOOKS == ROLE_DELETE_BOOKS else False
|
||||
else:
|
||||
return False
|
||||
|
||||
|
||||
def role_passwd(self):
|
||||
if self.config_default_role is not None:
|
||||
return True if self.config_default_role & ROLE_PASSWD == ROLE_PASSWD else False
|
||||
@ -460,13 +453,16 @@ def migrate_Database():
|
||||
create=True
|
||||
try:
|
||||
if create:
|
||||
conn.execute("SELET language_books FROM user")
|
||||
conn = engine.connect()
|
||||
conn.execute("SELECT language_books FROM user")
|
||||
session.commit()
|
||||
except exc.OperationalError:
|
||||
conn = engine.connect()
|
||||
conn.execute("UPDATE user SET 'sidebar_view' = (random_books*"+str(SIDEBAR_RANDOM)+"+ language_books *"+
|
||||
str(SIDEBAR_LANGUAGE)+"+ series_books *"+str(SIDEBAR_SERIES)+"+ category_books *"+str(SIDEBAR_CATEGORY)+
|
||||
"+ hot_books *"+str(SIDEBAR_HOT)+"+"+str(SIDEBAR_AUTHOR)+"+"+str(DETAIL_RANDOM)+")")
|
||||
conn.execute("UPDATE user SET 'sidebar_view' = (random_books* :side_random + language_books * :side_lang "
|
||||
"+ series_books * :side_series + category_books * :side_category + hot_books * "
|
||||
":side_hot + :side_autor + :detail_random)",{'side_random': SIDEBAR_RANDOM,
|
||||
'side_lang': SIDEBAR_LANGUAGE, 'side_series': SIDEBAR_SERIES, 'side_category': SIDEBAR_CATEGORY,
|
||||
'side_hot': SIDEBAR_HOT, 'side_autor': SIDEBAR_AUTHOR, 'detail_random': DETAIL_RANDOM})
|
||||
session.commit()
|
||||
if session.query(User).filter(User.role.op('&')(ROLE_ANONYMOUS) == ROLE_ANONYMOUS).first() is None:
|
||||
create_anonymous_user()
|
||||
|
11
cps/web.py
11
cps/web.py
@ -77,11 +77,6 @@ import time
|
||||
|
||||
current_milli_time = lambda: int(round(time.time() * 1000))
|
||||
|
||||
try:
|
||||
from wand.image import Image
|
||||
use_generic_pdf_cover = False
|
||||
except ImportError:
|
||||
use_generic_pdf_cover = True
|
||||
|
||||
# Global variables
|
||||
gdrive_watch_callback_token = 'target=calibreweb-watch_files'
|
||||
@ -739,7 +734,7 @@ def feed_author(book_id):
|
||||
off = request.args.get("offset")
|
||||
if not off:
|
||||
off = 0
|
||||
entries, random, pagination = fill_indexpage((int(off) / (int(config.config_books_per_page)) + 1),
|
||||
entries, __, pagination = fill_indexpage((int(off) / (int(config.config_books_per_page)) + 1),
|
||||
db.Books, db.Books.authors.any(db.Authors.id == book_id), db.Books.timestamp.desc())
|
||||
xml = render_title_template('feed.xml', entries=entries, pagination=pagination)
|
||||
response = make_response(xml)
|
||||
@ -1285,8 +1280,8 @@ def stats():
|
||||
lines = lines.decode('utf-8')
|
||||
if re.search('Amazon kindlegen\(', lines):
|
||||
versions['KindlegenVersion'] = lines
|
||||
except:
|
||||
versions['KindlegenVersion'] = _('Excecution permissions missing')
|
||||
except Exception:
|
||||
versions['KindlegenVersion'] = _(u'Excecution permissions missing')
|
||||
versions['PythonVersion'] = sys.version
|
||||
versions['babel'] = babelVersion
|
||||
versions['sqlalchemy'] = sqlalchemyVersion
|
||||
|
42
messages.pot
42
messages.pot
@ -8,7 +8,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PROJECT VERSION\n"
|
||||
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
|
||||
"POT-Creation-Date: 2017-07-08 19:46+0200\n"
|
||||
"POT-Creation-Date: 2017-07-09 19:16+0200\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
@ -31,33 +31,33 @@ msgstr ""
|
||||
msgid "epub format not found for book id: %(book)d"
|
||||
msgstr ""
|
||||
|
||||
#: cps/helper.py:93
|
||||
#: cps/helper.py:90 cps/helper.py:94
|
||||
msgid "kindlegen failed, no excecution permissions"
|
||||
msgstr ""
|
||||
|
||||
#: cps/helper.py:109
|
||||
#: cps/helper.py:110
|
||||
#, python-format
|
||||
msgid "Kindlegen failed with Error %(error)s. Message: %(message)s"
|
||||
msgstr ""
|
||||
|
||||
#: cps/helper.py:186
|
||||
#: cps/helper.py:187
|
||||
#, python-format
|
||||
msgid "Failed to send mail: %s"
|
||||
msgstr ""
|
||||
|
||||
#: cps/helper.py:193
|
||||
#: cps/helper.py:194
|
||||
msgid "Calibre-web test email"
|
||||
msgstr ""
|
||||
|
||||
#: cps/helper.py:194 cps/helper.py:206
|
||||
#: cps/helper.py:195 cps/helper.py:207
|
||||
msgid "This email has been sent via calibre web."
|
||||
msgstr ""
|
||||
|
||||
#: cps/helper.py:203 cps/templates/detail.html:47
|
||||
#: cps/helper.py:204 cps/templates/detail.html:43
|
||||
msgid "Send to Kindle"
|
||||
msgstr ""
|
||||
|
||||
#: cps/helper.py:223 cps/helper.py:236
|
||||
#: cps/helper.py:224 cps/helper.py:239
|
||||
msgid "Could not find any formats suitable for sending by email"
|
||||
msgstr ""
|
||||
|
||||
@ -445,8 +445,8 @@ msgstr ""
|
||||
msgid "Admin"
|
||||
msgstr ""
|
||||
|
||||
#: cps/templates/admin.html:13 cps/templates/detail.html:22
|
||||
#: cps/templates/detail.html:34
|
||||
#: cps/templates/admin.html:13 cps/templates/detail.html:21
|
||||
#: cps/templates/detail.html:30
|
||||
msgid "Download"
|
||||
msgstr ""
|
||||
|
||||
@ -699,7 +699,7 @@ msgstr ""
|
||||
msgid "No Result! Please try anonther keyword."
|
||||
msgstr ""
|
||||
|
||||
#: cps/templates/book_edit.html:182 cps/templates/detail.html:127
|
||||
#: cps/templates/book_edit.html:182 cps/templates/detail.html:126
|
||||
#: cps/templates/search_form.html:14
|
||||
msgid "Publisher"
|
||||
msgstr ""
|
||||
@ -809,39 +809,39 @@ msgstr ""
|
||||
msgid "Login"
|
||||
msgstr ""
|
||||
|
||||
#: cps/templates/detail.html:52
|
||||
#: cps/templates/detail.html:48
|
||||
msgid "Read in browser"
|
||||
msgstr ""
|
||||
|
||||
#: cps/templates/detail.html:91
|
||||
#: cps/templates/detail.html:88
|
||||
msgid "Book"
|
||||
msgstr ""
|
||||
|
||||
#: cps/templates/detail.html:91
|
||||
#: cps/templates/detail.html:88
|
||||
msgid "of"
|
||||
msgstr ""
|
||||
|
||||
#: cps/templates/detail.html:97
|
||||
#: cps/templates/detail.html:94
|
||||
msgid "language"
|
||||
msgstr ""
|
||||
|
||||
#: cps/templates/detail.html:132
|
||||
#: cps/templates/detail.html:131
|
||||
msgid "Publishing date"
|
||||
msgstr ""
|
||||
|
||||
#: cps/templates/detail.html:167
|
||||
#: cps/templates/detail.html:168
|
||||
msgid "Read"
|
||||
msgstr ""
|
||||
|
||||
#: cps/templates/detail.html:176
|
||||
#: cps/templates/detail.html:177
|
||||
msgid "Description:"
|
||||
msgstr ""
|
||||
|
||||
#: cps/templates/detail.html:187
|
||||
#: cps/templates/detail.html:189
|
||||
msgid "Add to shelf"
|
||||
msgstr ""
|
||||
|
||||
#: cps/templates/detail.html:227
|
||||
#: cps/templates/detail.html:230
|
||||
msgid "Edit metadata"
|
||||
msgstr ""
|
||||
|
||||
@ -1007,7 +1007,7 @@ msgstr ""
|
||||
msgid "Calibre Web ebook catalog"
|
||||
msgstr ""
|
||||
|
||||
#: cps/templates/read.html:136
|
||||
#: cps/templates/read.html:125
|
||||
msgid "Reflow text when sidebars are open."
|
||||
msgstr ""
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user