Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
caosdb-advanced-user-tools
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
caosdb
Software
caosdb-advanced-user-tools
Commits
8c9ce466
Commit
8c9ce466
authored
3 years ago
by
Henrik tom Wörden
Browse files
Options
Downloads
Patches
Plain Diff
WIP: no path collision and email
parent
dce18d21
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!39
Release 0.4.0
,
!20
created draft for generic analysis method
Pipeline
#16473
passed
3 years ago
Stage: setup
Stage: cert
Stage: style
Stage: unittest
Stage: integrationtest
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/caosadvancedtools/serverside/examples/example_script.py
+40
-2
40 additions, 2 deletions
src/caosadvancedtools/serverside/examples/example_script.py
with
40 additions
and
2 deletions
src/caosadvancedtools/serverside/examples/example_script.py
+
40
−
2
View file @
8c9ce466
...
...
@@ -40,12 +40,44 @@ import numpy as np
from
caosadvancedtools.cfood
import
assure_property_is
from
caosadvancedtools.guard
import
INSERT
,
UPDATE
from
caosadvancedtools.guard
import
global_guard
as
guard
from
caosadvancedtools.serverside.helper
import
send_mail
as
main_send_mail
logger
=
logging
.
getLogger
(
__name__
)
guard
.
set_level
(
level
=
UPDATE
)
def
send_mail
(
self
,
changes
):
"""
calls sendmail in order to send a mail to the curator about pending
changes
Parameters:
-----------
changes: The CaosDB entities in the version after the update.
"""
caosdb_config
=
db
.
configuration
.
get_config
()
text
=
"""
Dear Curator,
The following changes where done automatically.
{changes}
"""
.
format
(
changes
=
"
\n
"
.
join
(
changes
))
try
:
fro
=
caosdb_config
[
"
advancedtools
"
][
"
automated_updates.from_mail
"
]
to
=
caosdb_config
[
"
advancedtools
"
][
"
automated_updates.to_mail
"
]
except
KeyError
:
logger
.
error
(
"
Server Configuration is missing a setting for
"
"
sending mails. The administrator should check
"
"'
from_mail
'
and
'
to_mail
'
.
"
)
return
main_send_mail
(
from_addr
=
fro
,
to
=
to
,
subject
=
"
Automated Update
"
,
body
=
text
)
def
main
(
args
):
# TODO (maybe) can these checks be replaced by a more declaritive appoach?
try
:
...
...
@@ -84,19 +116,20 @@ def main(args):
# ####################################################################### #
# Insert the result plot
# TODO (must): how do we find a good file path??
fig
=
db
.
File
(
file
=
filename
,
path
=
"
/
uploaded/something3
/
"
+
str
(
datetime
.
now
())
+
filename
)
path
=
"
/
Analysis/results
/
"
+
str
(
datetime
.
now
())
+
"
/
"
+
filename
)
fig
.
insert
()
# Add the result to the analysis Record
# An update should only be done if necessary: assure_property_is should be
# used instead of direct calls to 'update'.
to_be_updated
=
[]
assure_property_is
(
dataAnalysisRecord
,
"
mean_value
"
,
mean
,
to_be_updated
=
to_be_updated
)
# TODO (maybe) this is not really meaningful since an uploaded file will always
# be different.... Compare checksums of files?
...
...
@@ -104,7 +137,12 @@ def main(args):
dataAnalysisRecord
,
"
results
"
,
fig
.
id
,
to_be_updated
=
to_be_updated
)
if
len
(
to_be_updated
)
>
0
:
send_mail
(
to_be_updated
)
# TODO (must) what should be done with the old file? Removed if not referenced?
# TODO (maybe) inform about updates (reuse stuff from crawler.py?)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment