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
OSUG
RESIF
resif_data_reporter
Commits
252d91f8
Commit
252d91f8
authored
Jan 04, 2022
by
Jonathan Schaeffer
Browse files
Network check correction
parent
f1e882e6
Pipeline
#85063
failed with stage
in 16 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
resifdatareporter/resifdatareporter.py
View file @
252d91f8
...
...
@@ -31,7 +31,6 @@ def scan_volume(path):
)
for
l
in
io
.
TextIOWrapper
(
proc
.
stdout
,
encoding
=
"utf-8"
):
l
=
l
.
strip
()
logger
.
debug
(
"Scanned %s"
,
l
)
(
size
,
path
)
=
l
.
split
(
"
\t
"
)
# On ne garde que le chemin qui nous intéresse
path
=
path
.
replace
(
volume
,
""
).
split
(
"/"
)
...
...
@@ -50,9 +49,9 @@ def scan_volume(path):
else
:
year
=
path
[
1
]
network
=
path
[
0
]
is_permanent
=
not
re
.
match
(
"^[
1
-9XYZ]"
,
path
[
0
]
)
is_permanent
=
not
re
.
match
(
"^[
0
-9XYZ]"
,
network
)
# On vérifie le format du network pour éviter les mauvaises insertions
if
re
.
match
(
"^[A-Z0-9]{
1,2}
$"
,
network
):
if
re
.
match
(
"^
([A-W]
[A-Z0-9]{
0,1})|([0-9XYZ][A-Z0-9][0-9]{4})
$"
,
network
):
data
.
append
(
{
"year"
:
year
,
...
...
@@ -213,7 +212,7 @@ def cli(configfile, force_scan, dryrun, verbose, version):
sys
.
exit
(
0
)
# Write to postgres database
if
"postgres"
in
cfg
:
logger
.
info
(
"Writing to postgres database"
)
logger
.
info
(
"Writing
%s entries
to postgres database"
,
len
(
statistics
)
)
conn
=
psycopg2
.
connect
(
dbname
=
cfg
[
"postgres"
][
"database"
],
user
=
cfg
[
"postgres"
][
"user"
],
...
...
@@ -226,7 +225,7 @@ def cli(configfile, force_scan, dryrun, verbose, version):
cur
.
execute
(
"""
INSERT INTO dataholdings (network, year, station, channel, type, size, is_permanent, volume, date)
VALUES (%s, %s, %s, %s, %s, %s, %s, %s,
%s,
%s)
VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)
ON CONFLICT (network,year,station,channel,type,date) DO UPDATE SET size = EXCLUDED.size;
"""
,
(
...
...
@@ -247,7 +246,7 @@ def cli(configfile, force_scan, dryrun, verbose, version):
cur
.
mogrify
(
"""
INSERT INTO dataholdings (network, year, station, channel, type, size, is_permanent, volume, date)
VALUES (%s, %s, %s, %s, %s, %s, %s, %s,
%s,
%s)
VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)
ON CONFLICT (network,year,station,channel,type,date) DO UPDATE SET size = EXCLUDED.size;
"""
,
(
...
...
Write
Preview
Supports
Markdown
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