mirror of
https://gitlab.com/wgp/dougal/software.git
synced 2025-12-06 10:37:07 +00:00
Add system data export module.
It exports the data that is entered directly into Dougal as opposed to being read from an external source. As of this commit, not all direct data is exported. Specifically, sequence comments (raw and final), sequence and shot NTBA and shot NTBP statuses are not exported.
This commit is contained in:
50
bin/system_exports.py
Executable file
50
bin/system_exports.py
Executable file
@@ -0,0 +1,50 @@
|
||||
#!/usr/bin/python3
|
||||
|
||||
"""
|
||||
Export data that is entered directly into Dougal
|
||||
as opposed to being read from external sources.
|
||||
|
||||
This data will be read back in when the database
|
||||
is recreated for an existing survey.
|
||||
"""
|
||||
|
||||
import os
|
||||
from glob import glob
|
||||
import configuration
|
||||
import preplots
|
||||
from datastore import Datastore
|
||||
|
||||
exportables = [
|
||||
"events_seq",
|
||||
"events_seq_labels",
|
||||
"events_timed",
|
||||
"events_timed_labels"
|
||||
]
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
print("Reading configuration")
|
||||
surveys = configuration.surveys()
|
||||
|
||||
print("Connecting to database")
|
||||
db = Datastore()
|
||||
|
||||
print("Reading surveys")
|
||||
for survey in surveys:
|
||||
print(f'Survey: {survey["id"]} ({survey["schema"]})')
|
||||
db.set_survey(survey["schema"])
|
||||
with db.conn.cursor() as cursor:
|
||||
|
||||
try:
|
||||
pathPrefix = survey["exports"]["path"]
|
||||
except ValueError:
|
||||
print("Survey does not define an export path")
|
||||
continue
|
||||
|
||||
for table in exportables:
|
||||
path = os.path.join(pathPrefix, table)
|
||||
print(" → ", path, " ← ", table)
|
||||
with open(path, "wb") as fd:
|
||||
cursor.copy_to(fd, table);
|
||||
|
||||
print("Done")
|
||||
Reference in New Issue
Block a user