Commit 252d91f8 authored by Jonathan Schaeffer's avatar Jonathan Schaeffer
Browse files

Network check correction

parent f1e882e6
Pipeline #85063 failed with stage
in 16 seconds
......@@ -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;
""",
(
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment