Code cosmetics

pull/228/head
OzzieIsaacs 7 years ago
parent 1fdb7dc497
commit 74e93e1cdf

@ -88,10 +88,10 @@ def make_mobi(book_id, calibrepath):
if os.path.exists(file_path + u".epub"): if os.path.exists(file_path + u".epub"):
try: try:
p = subprocess.Popen((kindlegen + " \"" + file_path + u".epub\"").encode(sys.getfilesystemencoding()), p = subprocess.Popen((kindlegen + " \"" + file_path + u".epub\"").encode(sys.getfilesystemencoding()),
stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) stdout=subprocess.PIPE, stderr=subprocess.PIPE)
except: except Exception:
error_message = _(u"kindlegen failed, no excecution permissions") 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 return error_message, RET_FAIL
# Poll process for new output until finished # 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'])) msg.attach(get_attachment(formats['mobi']))
elif 'epub' in formats: elif 'epub' in formats:
data, resultCode = make_mobi(book.id, calibrepath) data, resultCode = make_mobi(book.id, calibrepath)
app.logger.error = (data)
if resultCode == RET_SUCCESS: if resultCode == RET_SUCCESS:
msg.attach(get_attachment(data)) msg.attach(get_attachment(data))
else: else:
return data #_("Could not convert epub to mobi") return data #_("Could not convert epub to mobi")
elif 'pdf' in formats: elif 'pdf' in formats:
msg.attach(get_attachment(formats['pdf'])) msg.attach(get_attachment(formats['pdf']))
@ -305,7 +307,7 @@ def delete_book_gdrive(book):
def update_dir_stucture(book_id, calibrepath): def update_dir_stucture(book_id, calibrepath):
db.session.connection().connection.connection.create_function("title_sort", 1, db.title_sort) 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() 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] authordir = book.path.split('/')[0]
new_authordir = get_valid_filename(book.authors[0].name) 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) new_authordir = get_valid_filename(book.authors[0].name)
titledir = book.path.split('/')[1] titledir = book.path.split('/')[1]
new_titledir = get_valid_filename(book.title) + " (" + str(book_id) + ")" new_titledir = get_valid_filename(book.title) + " (" + str(book_id) + ")"
if titledir != new_titledir: if titledir != new_titledir:
print (titledir) print (titledir)
gFile=gd.getFileFromEbooksFolder(web.Gdrive.Instance().drive,os.path.dirname(book.path),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: for file in delete_files:
parts = file.split(os.sep) parts = file.split(os.sep)
sub = '' sub = ''
for i in range(len(parts)): for part in parts:
sub = os.path.join(sub, parts[i]) sub = os.path.join(sub, part)
if sub == '': if sub == '':
sub = os.sep sub = os.sep
count = 0 count = 0
@ -432,7 +434,7 @@ class Updater(threading.Thread):
logging.getLogger('cps.web').debug('Update on OS-System : ' + sys.platform) logging.getLogger('cps.web').debug('Update on OS-System : ' + sys.platform)
new_permissions = os.stat(root_dst_dir) new_permissions = os.stat(root_dst_dir)
# print new_permissions # 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) dst_dir = src_dir.replace(root_src_dir, root_dst_dir, 1)
if not os.path.exists(dst_dir): if not os.path.exists(dst_dir):
os.makedirs(dst_dir) os.makedirs(dst_dir)

@ -349,13 +349,6 @@ class Config:
else: else:
return False 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): def role_passwd(self):
if self.config_default_role is not None: if self.config_default_role is not None:
return True if self.config_default_role & ROLE_PASSWD == ROLE_PASSWD else False return True if self.config_default_role & ROLE_PASSWD == ROLE_PASSWD else False
@ -460,13 +453,16 @@ def migrate_Database():
create=True create=True
try: try:
if create: if create:
conn.execute("SELET language_books FROM user") conn = engine.connect()
conn.execute("SELECT language_books FROM user")
session.commit() session.commit()
except exc.OperationalError: except exc.OperationalError:
conn = engine.connect() conn = engine.connect()
conn.execute("UPDATE user SET 'sidebar_view' = (random_books*"+str(SIDEBAR_RANDOM)+"+ language_books *"+ conn.execute("UPDATE user SET 'sidebar_view' = (random_books* :side_random + language_books * :side_lang "
str(SIDEBAR_LANGUAGE)+"+ series_books *"+str(SIDEBAR_SERIES)+"+ category_books *"+str(SIDEBAR_CATEGORY)+ "+ series_books * :side_series + category_books * :side_category + hot_books * "
"+ hot_books *"+str(SIDEBAR_HOT)+"+"+str(SIDEBAR_AUTHOR)+"+"+str(DETAIL_RANDOM)+")") ":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() session.commit()
if session.query(User).filter(User.role.op('&')(ROLE_ANONYMOUS) == ROLE_ANONYMOUS).first() is None: if session.query(User).filter(User.role.op('&')(ROLE_ANONYMOUS) == ROLE_ANONYMOUS).first() is None:
create_anonymous_user() create_anonymous_user()

@ -77,11 +77,6 @@ import time
current_milli_time = lambda: int(round(time.time() * 1000)) 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 # Global variables
gdrive_watch_callback_token = 'target=calibreweb-watch_files' gdrive_watch_callback_token = 'target=calibreweb-watch_files'
@ -739,7 +734,7 @@ def feed_author(book_id):
off = request.args.get("offset") off = request.args.get("offset")
if not off: if not off:
off = 0 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()) 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) xml = render_title_template('feed.xml', entries=entries, pagination=pagination)
response = make_response(xml) response = make_response(xml)
@ -1285,8 +1280,8 @@ def stats():
lines = lines.decode('utf-8') lines = lines.decode('utf-8')
if re.search('Amazon kindlegen\(', lines): if re.search('Amazon kindlegen\(', lines):
versions['KindlegenVersion'] = lines versions['KindlegenVersion'] = lines
except: except Exception:
versions['KindlegenVersion'] = _('Excecution permissions missing') versions['KindlegenVersion'] = _(u'Excecution permissions missing')
versions['PythonVersion'] = sys.version versions['PythonVersion'] = sys.version
versions['babel'] = babelVersion versions['babel'] = babelVersion
versions['sqlalchemy'] = sqlalchemyVersion versions['sqlalchemy'] = sqlalchemyVersion

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PROJECT VERSION\n" "Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\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" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -31,33 +31,33 @@ msgstr ""
msgid "epub format not found for book id: %(book)d" msgid "epub format not found for book id: %(book)d"
msgstr "" msgstr ""
#: cps/helper.py:93 #: cps/helper.py:90 cps/helper.py:94
msgid "kindlegen failed, no excecution permissions" msgid "kindlegen failed, no excecution permissions"
msgstr "" msgstr ""
#: cps/helper.py:109 #: cps/helper.py:110
#, python-format #, python-format
msgid "Kindlegen failed with Error %(error)s. Message: %(message)s" msgid "Kindlegen failed with Error %(error)s. Message: %(message)s"
msgstr "" msgstr ""
#: cps/helper.py:186 #: cps/helper.py:187
#, python-format #, python-format
msgid "Failed to send mail: %s" msgid "Failed to send mail: %s"
msgstr "" msgstr ""
#: cps/helper.py:193 #: cps/helper.py:194
msgid "Calibre-web test email" msgid "Calibre-web test email"
msgstr "" 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." msgid "This email has been sent via calibre web."
msgstr "" msgstr ""
#: cps/helper.py:203 cps/templates/detail.html:47 #: cps/helper.py:204 cps/templates/detail.html:43
msgid "Send to Kindle" msgid "Send to Kindle"
msgstr "" 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" msgid "Could not find any formats suitable for sending by email"
msgstr "" msgstr ""
@ -445,8 +445,8 @@ msgstr ""
msgid "Admin" msgid "Admin"
msgstr "" msgstr ""
#: cps/templates/admin.html:13 cps/templates/detail.html:22 #: cps/templates/admin.html:13 cps/templates/detail.html:21
#: cps/templates/detail.html:34 #: cps/templates/detail.html:30
msgid "Download" msgid "Download"
msgstr "" msgstr ""
@ -699,7 +699,7 @@ msgstr ""
msgid "No Result! Please try anonther keyword." msgid "No Result! Please try anonther keyword."
msgstr "" 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 #: cps/templates/search_form.html:14
msgid "Publisher" msgid "Publisher"
msgstr "" msgstr ""
@ -809,39 +809,39 @@ msgstr ""
msgid "Login" msgid "Login"
msgstr "" msgstr ""
#: cps/templates/detail.html:52 #: cps/templates/detail.html:48
msgid "Read in browser" msgid "Read in browser"
msgstr "" msgstr ""
#: cps/templates/detail.html:91 #: cps/templates/detail.html:88
msgid "Book" msgid "Book"
msgstr "" msgstr ""
#: cps/templates/detail.html:91 #: cps/templates/detail.html:88
msgid "of" msgid "of"
msgstr "" msgstr ""
#: cps/templates/detail.html:97 #: cps/templates/detail.html:94
msgid "language" msgid "language"
msgstr "" msgstr ""
#: cps/templates/detail.html:132 #: cps/templates/detail.html:131
msgid "Publishing date" msgid "Publishing date"
msgstr "" msgstr ""
#: cps/templates/detail.html:167 #: cps/templates/detail.html:168
msgid "Read" msgid "Read"
msgstr "" msgstr ""
#: cps/templates/detail.html:176 #: cps/templates/detail.html:177
msgid "Description:" msgid "Description:"
msgstr "" msgstr ""
#: cps/templates/detail.html:187 #: cps/templates/detail.html:189
msgid "Add to shelf" msgid "Add to shelf"
msgstr "" msgstr ""
#: cps/templates/detail.html:227 #: cps/templates/detail.html:230
msgid "Edit metadata" msgid "Edit metadata"
msgstr "" msgstr ""
@ -1007,7 +1007,7 @@ msgstr ""
msgid "Calibre Web ebook catalog" msgid "Calibre Web ebook catalog"
msgstr "" msgstr ""
#: cps/templates/read.html:136 #: cps/templates/read.html:125
msgid "Reflow text when sidebars are open." msgid "Reflow text when sidebars are open."
msgstr "" msgstr ""

Loading…
Cancel
Save