1
0
mirror of https://github.com/janeczku/calibre-web synced 2024-11-28 12:30:00 +00:00
This commit is contained in:
cbartondock 2021-04-22 18:12:19 -04:00
commit 541dd6b579
4 changed files with 17 additions and 7 deletions

View File

@ -62,11 +62,11 @@ class _Logger(logging.Logger):
def debug_no_auth(self, message, *args, **kwargs): def debug_no_auth(self, message, *args, **kwargs):
message = message.strip("\r\n")
if message.startswith("send: AUTH"): if message.startswith("send: AUTH"):
self.debug(message[:16], stacklevel=2, *args, **kwargs) self.debug(message[:16], *args, **kwargs)
else: else:
self.debug(message, stacklevel=2, *args, **kwargs) self.debug(message, *args, **kwargs)
def get(name=None): def get(name=None):

View File

@ -45,7 +45,7 @@ class ImprovedQueue(queue.Queue):
with self.mutex: with self.mutex:
return list(self.queue) return list(self.queue)
#Class for all worker tasks in the background # Class for all worker tasks in the background
class WorkerThread(threading.Thread): class WorkerThread(threading.Thread):
_instance = None _instance = None
@ -69,6 +69,7 @@ class WorkerThread(threading.Thread):
def add(cls, user, task): def add(cls, user, task):
ins = cls.getInstance() ins = cls.getInstance()
ins.num += 1 ins.num += 1
log.debug("Add Task for user: {}: {}".format(user, task))
ins.queue.put(QueuedTask( ins.queue.put(QueuedTask(
num=ins.num, num=ins.num,
user=user, user=user,

View File

@ -640,6 +640,7 @@ function checkboxFormatter(value, row, index){
return '<input type="checkbox" class="chk" data-pk="' + row.id + '" data-name="' + this.field + '" onchange="checkboxChange(this, ' + row.id + ', \'' + this.name + '\', ' + this.column + ')">'; return '<input type="checkbox" class="chk" data-pk="' + row.id + '" data-name="' + this.field + '" onchange="checkboxChange(this, ' + row.id + ', \'' + this.name + '\', ' + this.column + ')">';
} }
/* Do some hiding disabling after user list is loaded */
function loadSuccess() { function loadSuccess() {
var guest = $(".editable[data-name='name'][data-value='Guest']"); var guest = $(".editable[data-name='name'][data-value='Guest']");
guest.editable("disable"); guest.editable("disable");

View File

@ -115,6 +115,7 @@ class TaskEmail(CalibreTask):
self.results = dict() self.results = dict()
def prepare_message(self): def prepare_message(self):
log.debug("prepare email message for sending")
message = MIMEMultipart() message = MIMEMultipart()
message['to'] = self.recipent message['to'] = self.recipent
message['from'] = self.settings["mail_from"] message['from'] = self.settings["mail_from"]
@ -134,9 +135,9 @@ class TaskEmail(CalibreTask):
return message return message
def run(self, worker_thread): def run(self, worker_thread):
# create MIME message
msg = self.prepare_message()
try: try:
# create MIME message
msg = self.prepare_message()
if self.settings['mail_server_type'] == 0: if self.settings['mail_server_type'] == 0:
self.send_standard_email(msg) self.send_standard_email(msg)
else: else:
@ -170,9 +171,11 @@ class TaskEmail(CalibreTask):
# redirect output to logfile on python2 on python3 debugoutput is caught with overwritten # redirect output to logfile on python2 on python3 debugoutput is caught with overwritten
# _print_debug function # _print_debug function
if sys.version_info < (3, 0): if sys.version_info < (3, 0):
log.debug("Redirect output on python2 for email")
org_smtpstderr = smtplib.stderr org_smtpstderr = smtplib.stderr
smtplib.stderr = logger.StderrLogger('worker.smtp') smtplib.stderr = logger.StderrLogger('worker.smtp')
log.debug("Start send email")
if use_ssl == 2: if use_ssl == 2:
self.asyncSMTP = EmailSSL(self.settings["mail_server"], self.settings["mail_port"], self.asyncSMTP = EmailSSL(self.settings["mail_server"], self.settings["mail_port"],
timeout=timeout) timeout=timeout)
@ -185,6 +188,7 @@ class TaskEmail(CalibreTask):
if use_ssl == 1: if use_ssl == 1:
self.asyncSMTP.starttls() self.asyncSMTP.starttls()
if self.settings["mail_password"]: if self.settings["mail_password"]:
log.debug("Login to email server")
self.asyncSMTP.login(str(self.settings["mail_login"]), str(self.settings["mail_password"])) self.asyncSMTP.login(str(self.settings["mail_login"]), str(self.settings["mail_password"]))
# Convert message to something to send # Convert message to something to send
@ -192,14 +196,15 @@ class TaskEmail(CalibreTask):
gen = Generator(fp, mangle_from_=False) gen = Generator(fp, mangle_from_=False)
gen.flatten(msg) gen.flatten(msg)
log.debug("Sending email")
self.asyncSMTP.sendmail(self.settings["mail_from"], self.recipent, fp.getvalue()) self.asyncSMTP.sendmail(self.settings["mail_from"], self.recipent, fp.getvalue())
self.asyncSMTP.quit() self.asyncSMTP.quit()
self._handleSuccess() self._handleSuccess()
log.debug("Email send successfully")
if sys.version_info < (3, 0): if sys.version_info < (3, 0):
smtplib.stderr = org_smtpstderr smtplib.stderr = org_smtpstderr
def send_gmail_email(self, message): def send_gmail_email(self, message):
return gmail.send_messsage(self.settings.get('mail_gmail_token', None), message) return gmail.send_messsage(self.settings.get('mail_gmail_token', None), message)
@ -258,3 +263,6 @@ class TaskEmail(CalibreTask):
@property @property
def name(self): def name(self):
return "Email" return "Email"
def __str__(self):
return "{}, {}".format(self.name, self.subject)