Commit d1815737 authored by Jonathan Schaeffer's avatar Jonathan Schaeffer
Browse files

Smarter date insertion

parent bf9eca90
......@@ -47,12 +47,12 @@ def scan_volume(path):
is_permanent = not re.match('^[1-9XYZ]', path[0])
data.append({'year': path[0], 'network': path[1], 'station': path[2],
'channel': channel, 'quality': quality, 'size': size,
'is_permanent': is_permanent, 'date': date.today().strftime("%Y-%m-%d")})
'is_permanent': is_permanent })
else:
is_permanent = not re.match('^[1-9XYZ]', path[1])
data.append({'year': path[1], 'network': path[0], 'station': path[2],
'channel': channel, 'quality': quality, 'size': size,
'is_permanent': is_permanent, 'date': date.today().strftime("%Y-%m-%d")})
'is_permanent': is_permanent })
logger.debug(data[-1])
logger.debug("Volume scanned in %s", datetime.now() - starttime)
return data
......@@ -183,7 +183,7 @@ def cli(configfile, force_scan, dryrun, verbose, version):
VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)
ON CONFLICT (network,year,station,channel,type,date) DO UPDATE SET size = EXCLUDED.size;
""",
(stat['network'], stat['year'], stat['station'], stat['channel'], stat['quality'], stat['type'], stat['size'], stat['is_permanent'], stat['volume'], stat['date']))
(stat['network'], stat['year'], stat['station'], stat['channel'], stat['quality'], stat['type'], stat['size'], stat['is_permanent'], stat['volume'], today))
except psycopg2.Error as err:
logging.error(err)
logging.info(cur.mogrify(
......@@ -192,7 +192,7 @@ def cli(configfile, force_scan, dryrun, verbose, version):
VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)
ON CONFLICT (network,year,station,channel,type,date) DO UPDATE SET size = EXCLUDED.size;
""",
(stat['network'], stat['year'], stat['station'], stat['channel'], stat['quality'], stat['type'], stat['size'], stat['is_permanent'], stat['volume'], stat['date'])
(stat['network'], stat['year'], stat['station'], stat['channel'], stat['quality'], stat['type'], stat['size'], stat['is_permanent'], stat['volume'], today)
))
conn.commit()
......
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