Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
ArchiveExtractor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
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
Insights
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
DG
ArchiveExtractor
Commits
07c3dc1d
Commit
07c3dc1d
authored
3 years ago
by
System User
Browse files
Options
Downloads
Patches
Plain Diff
Corrections after tests
parent
7da2f361
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
cli_archiveextractor.py
+11
-7
11 additions, 7 deletions
cli_archiveextractor.py
core/ArchiveExtractor.py
+6
-6
6 additions, 6 deletions
core/ArchiveExtractor.py
with
17 additions
and
13 deletions
cli_archiveextractor.py
100644 → 100755
+
11
−
7
View file @
07c3dc1d
...
...
@@ -3,7 +3,11 @@
Command Line Interface to use ArchiveExtractor module
"""
import
argparse
import
ArchiveExtractor
import
core.ArchiveExtractor
as
AE
import
logging
import
datetime
import
numpy
as
np
import
PyTango
as
tango
# Name the logger after the filename
logger
=
logging
.
getLogger
(
"
ArchiveExtractor
"
)
...
...
@@ -17,15 +21,15 @@ dateStart = datetime.datetime.now()-datetime.timedelta(days=1)
#######################################################
# Install argument parser
parser
=
argparse
.
ArgumentParser
(
description
=
"
Extract attributes from the extractor devices.
\n
Version %s
"
%
__version__
)
parser
=
argparse
.
ArgumentParser
(
description
=
"
Extract attributes from the extractor devices.
\n
Version %s
"
%
AE
.
__version__
)
parser
.
add_argument
(
"
--from
"
,
type
=
dateparse
,
dest
=
"
dateStart
"
,
parser
.
add_argument
(
"
--from
"
,
type
=
AE
.
ArchiveExtractor
.
dateparse
,
dest
=
"
dateStart
"
,
help
=
"
Start date for extraction, format
'
1990-12-13-22:33:45
'
.
"
+
"
It is possible to be less precise and drop, seconds, minutes, hours or even day.
"
+
"
Default is one day ago
"
,
default
=
dateStart
)
parser
.
add_argument
(
"
--to
"
,
type
=
dateparse
,
dest
=
"
dateStop
"
,
parser
.
add_argument
(
"
--to
"
,
type
=
AE
.
ArchiveExtractor
.
dateparse
,
dest
=
"
dateStop
"
,
help
=
"
Stop date for extraction, format
'
1990-12-13-22:33:45
'
. It is possible to be less precise and drop, seconds, minutes, hours or even day.
"
+
"
Default is now.
"
,
default
=
dateStop
)
...
...
@@ -68,7 +72,7 @@ logger.addHandler(s_handler)
logger
.
debug
(
"
Parsed arguments: %s
"
%
args
)
logger
.
info
(
"
Archive Extractor %s
"
%
__version__
)
logger
.
info
(
"
Archive Extractor %s
"
%
AE
.
__version__
)
#######################################################
# Filemode or not
...
...
@@ -90,9 +94,9 @@ else:
#######################################################
# Instanciate Extractor
if
args
.
DB
==
"
L
"
:
AE
=
A
rchiveExtractor
.
ArchiveExtractor
(
extractorPath
=
"
archiving/extractor/%d
"
%
(
args
.
DBN
))
AE
=
A
E
.
ArchiveExtractor
(
extractorPath
=
"
archiving/extractor/%d
"
%
(
args
.
DBN
)
,
logger
=
logger
)
else
:
AE
=
A
rchiveExtractor
.
ArchiveExtractor
(
args
.
DB
,
args
.
DBN
)
AE
=
A
E
.
ArchiveExtractor
(
args
.
DB
,
args
.
DBN
,
logger
=
logger
)
#######################################################
# Prepare dictionnary for result
...
...
This diff is collapsed.
Click to expand it.
core/ArchiveExtractor.py
+
6
−
6
View file @
07c3dc1d
...
...
@@ -227,8 +227,8 @@ class ArchiveExtractor:
self
,
attribute
,
dateStart
,
timeInterval
=
datetime
.
timedelta
(
seconds
=
60
),
dateStop
=
datetime
.
datetime
.
now
(),
timeInterval
=
datetime
.
timedelta
(
seconds
=
60
),
):
"""
Query attribute data from an archiver database, get all points between dates.
...
...
@@ -297,12 +297,12 @@ class ArchiveExtractor:
cdates
.
append
(
cdates
[
-
1
]
+
timeInterval
)
cdates
[
-
1
]
=
dateStop
mdates
=
np
.
asarray
(
cdates
[:
-
1
])
+
timeInterval
/
2
logger
.
debug
(
"
Cutting time range to %d chunks of time, %s each.
"
%
(
len
(
cdates
)
-
1
,
d
t
))
self
.
logger
.
debug
(
"
Cutting time range to %d chunks of time, %s each.
"
%
(
len
(
cdates
)
-
1
,
t
imeInterval
))
# Prepare arrays
value_min
=
np
.
empty
(
len
(
cdates
-
1
)
)
value_max
=
np
.
empty
(
len
(
cdates
-
1
)
)
value_mean
=
np
.
empty
(
len
(
cdates
-
1
)
)
value_min
=
np
.
empty
(
len
(
cdates
)
-
1
)
value_max
=
np
.
empty
(
len
(
cdates
)
-
1
)
value_mean
=
np
.
empty
(
len
(
cdates
)
-
1
)
# For each time chunk
for
i_d
in
range
(
len
(
cdates
)
-
1
):
...
...
@@ -311,7 +311,7 @@ class ArchiveExtractor:
[
value_max
,
value_min
,
value_mean
],
):
# Make requests
logger
.
debug
(
"
Perform GetAttData%sBetweenDates (%s, %s, %s)
"
%
(
self
.
logger
.
debug
(
"
Perform GetAttData%sBetweenDates (%s, %s, %s)
"
%
(
func
,
attribute
,
cdates
[
i_d
].
strftime
(
DBDFMT2
),
...
...
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