Code cosmetics

pull/173/head
OzzieIsaacs 8 years ago
parent dc45b53b24
commit 699bd036e8

@ -81,7 +81,7 @@ def make_mobi(book_id, calibrepath):
file_path = os.path.join(calibrepath, book.path, data.name) file_path = os.path.join(calibrepath, book.path, data.name)
if os.path.exists(file_path + u".epub"): if os.path.exists(file_path + u".epub"):
p = subprocess.Popen((kindlegen + " \"" + file_path + u".epub\" ").encode(sys.getfilesystemencoding()), p = subprocess.Popen((kindlegen + " \"" + file_path + u".epub\" ").encode(sys.getfilesystemencoding()),
shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE) stdout=subprocess.PIPE, stderr=subprocess.PIPE)
# Poll process for new output until finished # Poll process for new output until finished
while True: while True:
nextline = p.stdout.readline() nextline = p.stdout.readline()
@ -252,7 +252,7 @@ def get_valid_filename(value, replace_whitespace=True):
value=value.replace(u'ß',u'ss') value=value.replace(u'ß',u'ss')
value = unicodedata.normalize('NFKD', value) value = unicodedata.normalize('NFKD', value)
re_slugify = re.compile('[\W\s-]', re.UNICODE) re_slugify = re.compile('[\W\s-]', re.UNICODE)
if type(value) is str: #Python3 str, Python2 unicode if isinstance(value, str): #Python3 str, Python2 unicode
value = re_slugify.sub('', value).strip() value = re_slugify.sub('', value).strip()
else: else:
value = unicode(re_slugify.sub('', value).strip()) value = unicode(re_slugify.sub('', value).strip())

@ -13,7 +13,7 @@ $(function() {
$.ajax({ $.ajax({
dataType: "json", dataType: "json",
url: window.location.pathname+"/../../get_updater_status", url: window.location.pathname+"/../../get_updater_status",
success: function(data) { success(data) {
// console.log(data.status); // console.log(data.status);
$("#UpdateprogressDialog #Updatecontent").html(updateText[data.status]); $("#UpdateprogressDialog #Updatecontent").html(updateText[data.status]);
if (data.status >6){ if (data.status >6){

@ -272,14 +272,9 @@ def load_user_from_header(header_val):
return user return user
return return
def check_auth(username, password): def check_auth(username, password):
user = ub.session.query(ub.User).filter(ub.User.nickname == username).first() user = ub.session.query(ub.User).filter(ub.User.nickname == username).first()
if user and check_password_hash(user.password, password): return bool(user and check_password_hash(user.password, password))
return True
else:
return False
def authenticate(): def authenticate():
return Response( return Response(
@ -1239,11 +1234,10 @@ def stats():
kindlegen = os.path.join(vendorpath, u"kindlegen") kindlegen = os.path.join(vendorpath, u"kindlegen")
versions['KindlegenVersion'] = _('not installed') versions['KindlegenVersion'] = _('not installed')
if os.path.exists(kindlegen): if os.path.exists(kindlegen):
p = subprocess.Popen(kindlegen, shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE, p = subprocess.Popen(kindlegen, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdin=subprocess.PIPE)
p.wait() p.wait()
for lines in p.stdout.readlines(): for lines in p.stdout.readlines():
if type(lines) is bytes: if isinstance(lines, bytes):
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

Loading…
Cancel
Save