Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Alan Marchiori
labtool
Commits
92c54daf
Commit
92c54daf
authored
Mar 14, 2022
by
alan
Browse files
added stats
parent
637da91c
Changes
1
Hide whitespace changes
Inline
Side-by-side
stats.py
0 → 100644
View file @
92c54daf
"""
Generate and email status reports
Alan Marchiori (c) 2022
"""
import
config
# pull version from labtool
from
lt
import
labtool_version
config
.
labtool_version
=
labtool_version
import
courses
from
utils.mailer
import
send_email
from
labmon
import
show_course_summary
import
io
from
contextlib
import
redirect_stdout
from
datetime
import
datetime
dt
=
datetime
.
now
().
isoformat
()
#print(str(dt)[:19])
email_to
=
set
()
# course summary prints to stdout, so capture the output
with
io
.
StringIO
()
as
buf
,
redirect_stdout
(
buf
),
config
.
UserConfig
()
as
uc
:
for
c
in
[
f
"CSCI206-S22-
{
x
:
2
d
}
"
for
x
in
range
(
60
,
63
)]:
email_to
.
update
(
courses
.
all
[
c
][
'tas'
])
email_to
.
update
(
courses
.
all
[
c
][
'instructors'
])
print
(
"="
*
20
+
c
+
"="
*
20
)
#code, out = run(f"python3 labmon.py --course {c}")
show_course_summary
(
c
,
user
=
None
,
email
=
None
,
tblfmt
=
"simple"
)
msg
=
buf
.
getvalue
()
email_to
=
[
f
"
{
x
}
@
{
config
.
email_domain
}
"
for
x
in
email_to
]
print
(
"Sending email to "
,
email_to
)
subject
=
f
"labtool summary report from
{
str
(
dt
)[:
19
]
}
"
send_email
(
config
.
feedback_email_from
,
email_to
,
subject
,
body
=
None
,
html
=
f
"<pre>
{
msg
}
</pre>"
)
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