Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
D
douban-api-proxy
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
captainwong
douban-api-proxy
Commits
541dd6b5
Commit
541dd6b5
authored
Apr 22, 2021
by
cbartondock
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
https://github.com/janeczku/calibre-web
parents
e57229e6
450ee436
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
7 deletions
+17
-7
logger.py
cps/logger.py
+3
-3
worker.py
cps/services/worker.py
+2
-1
table.js
cps/static/js/table.js
+1
-0
mail.py
cps/tasks/mail.py
+11
-3
No files found.
cps/logger.py
View file @
541dd6b5
...
...
@@ -62,11 +62,11 @@ class _Logger(logging.Logger):
def
debug_no_auth
(
self
,
message
,
*
args
,
**
kwargs
):
message
=
message
.
strip
(
"
\r\n
"
)
if
message
.
startswith
(
"send: AUTH"
):
self
.
debug
(
message
[:
16
],
stacklevel
=
2
,
*
args
,
**
kwargs
)
self
.
debug
(
message
[:
16
],
*
args
,
**
kwargs
)
else
:
self
.
debug
(
message
,
stacklevel
=
2
,
*
args
,
**
kwargs
)
self
.
debug
(
message
,
*
args
,
**
kwargs
)
def
get
(
name
=
None
):
...
...
cps/services/worker.py
View file @
541dd6b5
...
...
@@ -45,7 +45,7 @@ class ImprovedQueue(queue.Queue):
with
self
.
mutex
:
return
list
(
self
.
queue
)
#Class for all worker tasks in the background
#
Class for all worker tasks in the background
class
WorkerThread
(
threading
.
Thread
):
_instance
=
None
...
...
@@ -69,6 +69,7 @@ class WorkerThread(threading.Thread):
def
add
(
cls
,
user
,
task
):
ins
=
cls
.
getInstance
()
ins
.
num
+=
1
log
.
debug
(
"Add Task for user: {}: {}"
.
format
(
user
,
task
))
ins
.
queue
.
put
(
QueuedTask
(
num
=
ins
.
num
,
user
=
user
,
...
...
cps/static/js/table.js
View file @
541dd6b5
...
...
@@ -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
+
')">'
;
}
/* Do some hiding disabling after user list is loaded */
function
loadSuccess
()
{
var
guest
=
$
(
".editable[data-name='name'][data-value='Guest']"
);
guest
.
editable
(
"disable"
);
...
...
cps/tasks/mail.py
View file @
541dd6b5
...
...
@@ -115,6 +115,7 @@ class TaskEmail(CalibreTask):
self
.
results
=
dict
()
def
prepare_message
(
self
):
log
.
debug
(
"prepare email message for sending"
)
message
=
MIMEMultipart
()
message
[
'to'
]
=
self
.
recipent
message
[
'from'
]
=
self
.
settings
[
"mail_from"
]
...
...
@@ -134,9 +135,9 @@ class TaskEmail(CalibreTask):
return
message
def
run
(
self
,
worker_thread
):
try
:
# create MIME message
msg
=
self
.
prepare_message
()
try
:
if
self
.
settings
[
'mail_server_type'
]
==
0
:
self
.
send_standard_email
(
msg
)
else
:
...
...
@@ -170,9 +171,11 @@ class TaskEmail(CalibreTask):
# redirect output to logfile on python2 on python3 debugoutput is caught with overwritten
# _print_debug function
if
sys
.
version_info
<
(
3
,
0
):
log
.
debug
(
"Redirect output on python2 for email"
)
org_smtpstderr
=
smtplib
.
stderr
smtplib
.
stderr
=
logger
.
StderrLogger
(
'worker.smtp'
)
log
.
debug
(
"Start send email"
)
if
use_ssl
==
2
:
self
.
asyncSMTP
=
EmailSSL
(
self
.
settings
[
"mail_server"
],
self
.
settings
[
"mail_port"
],
timeout
=
timeout
)
...
...
@@ -185,6 +188,7 @@ class TaskEmail(CalibreTask):
if
use_ssl
==
1
:
self
.
asyncSMTP
.
starttls
()
if
self
.
settings
[
"mail_password"
]:
log
.
debug
(
"Login to email server"
)
self
.
asyncSMTP
.
login
(
str
(
self
.
settings
[
"mail_login"
]),
str
(
self
.
settings
[
"mail_password"
]))
# Convert message to something to send
...
...
@@ -192,14 +196,15 @@ class TaskEmail(CalibreTask):
gen
=
Generator
(
fp
,
mangle_from_
=
False
)
gen
.
flatten
(
msg
)
log
.
debug
(
"Sending email"
)
self
.
asyncSMTP
.
sendmail
(
self
.
settings
[
"mail_from"
],
self
.
recipent
,
fp
.
getvalue
())
self
.
asyncSMTP
.
quit
()
self
.
_handleSuccess
()
log
.
debug
(
"Email send successfully"
)
if
sys
.
version_info
<
(
3
,
0
):
smtplib
.
stderr
=
org_smtpstderr
def
send_gmail_email
(
self
,
message
):
return
gmail
.
send_messsage
(
self
.
settings
.
get
(
'mail_gmail_token'
,
None
),
message
)
...
...
@@ -258,3 +263,6 @@ class TaskEmail(CalibreTask):
@
property
def
name
(
self
):
return
"Email"
def
__str__
(
self
):
return
"{}, {}"
.
format
(
self
.
name
,
self
.
subject
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment