Code cosmetics
This commit is contained in:
+10
-8
@@ -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)
|
||||
|
||||
@@ -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()
|
||||
|
||||
+3
-8
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user