2020-08-08 23:59:13 +02:00
|
|
|
#!/usr/bin/python3
|
|
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
Remove from the database data related to files that
|
|
|
|
|
no longer exist on disk.
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
import os
|
|
|
|
|
from glob import glob
|
|
|
|
|
import configuration
|
|
|
|
|
import preplots
|
|
|
|
|
from datastore import Datastore
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
|
|
|
|
|
|
print("Connecting to database")
|
|
|
|
|
db = Datastore()
|
|
|
|
|
|
2023-08-30 14:19:56 +02:00
|
|
|
print("Reading configuration")
|
|
|
|
|
surveys = db.surveys()
|
|
|
|
|
|
2020-08-08 23:59:13 +02:00
|
|
|
print("Reading surveys")
|
|
|
|
|
for survey in surveys:
|
|
|
|
|
print(f'Survey: {survey["id"]} ({survey["schema"]})')
|
|
|
|
|
db.set_survey(survey["schema"])
|
|
|
|
|
|
|
|
|
|
for file in db.list_files():
|
|
|
|
|
path = file[0]
|
|
|
|
|
if not os.path.exists(path):
|
|
|
|
|
print(path, "NOT FOUND")
|
|
|
|
|
db.del_file(path)
|
|
|
|
|
|
|
|
|
|
print("Done")
|