troggle-unchained/parsers/imports.py

76 lines
2.4 KiB
Python
Raw Normal View History

2020-06-16 16:07:36 +01:00
import sys
import os
import django
from django.core import management
from django.db import connection, close_old_connections, connections
from django.contrib.auth.models import User
from django.http import HttpResponse
2020-06-18 21:50:16 +01:00
#from django.urls import reverse, resolve
from django.db import transaction
2020-06-16 16:07:36 +01:00
import troggle.settings
import troggle.parsers.caves
import troggle.parsers.people
import troggle.parsers.surveys
import troggle.parsers.logbooks
import troggle.parsers.QMs
2020-07-07 01:35:58 +01:00
import troggle.parsers.subcaves
2020-06-16 16:07:36 +01:00
def import_caves():
2020-07-01 22:49:38 +01:00
print("-- Importing Caves to ",end="")
2020-06-16 16:07:36 +01:00
print(django.db.connections.databases['default']['NAME'])
# wrap the entire import in a transaction
with transaction.atomic():
troggle.parsers.caves.readcaves()
2020-06-16 16:07:36 +01:00
def import_people():
2020-07-01 22:49:38 +01:00
print("-- Importing People (folk.csv) to ",end="")
2020-06-16 16:07:36 +01:00
print(django.db.connections.databases['default']['NAME'])
with transaction.atomic():
troggle.parsers.people.LoadPersonsExpos()
2020-06-16 16:07:36 +01:00
def import_surveyscans():
2020-07-01 22:49:38 +01:00
print("-- Importing Survey Scans")
with transaction.atomic():
troggle.parsers.surveys.LoadListScans()
2020-06-16 16:07:36 +01:00
def import_logbooks():
2020-07-01 22:49:38 +01:00
print("-- Importing Logbooks")
with transaction.atomic():
troggle.parsers.logbooks.LoadLogbooks()
2020-06-16 16:07:36 +01:00
def import_QMs():
print("-- Importing old QMs for 161, 204, 234 from CSV files")
with transaction.atomic():
troggle.parsers.QMs.Load_QMs()
2020-06-16 16:07:36 +01:00
def import_survex():
# when this import is moved to the top with the rest it all crashes horribly
with transaction.atomic():
import troggle.parsers.survex
print("-- Importing Survex and Entrance Positions")
2020-06-16 19:27:32 +01:00
print(" - Survex Blocks")
with transaction.atomic():
troggle.parsers.survex.LoadSurvexBlocks()
2020-06-16 19:27:32 +01:00
print(" - Survex entrances x/y/z Positions")
with transaction.atomic():
troggle.parsers.survex.LoadPositions()
2020-06-16 16:07:36 +01:00
2020-06-30 15:24:42 +01:00
def import_loadpos():
# when this import is moved to the top with the rest it all crashes horribly
with transaction.atomic():
import troggle.parsers.survex
2020-06-30 15:24:42 +01:00
print(" - Survex entrances x/y/z Positions")
troggle.parsers.survex.LoadPositions()
2020-06-30 15:24:42 +01:00
def import_drawingsfiles():
2020-07-01 22:49:38 +01:00
print("-- Importing Drawings files")
troggle.parsers.surveys.LoadDrawingFiles()
2020-06-16 16:07:36 +01:00
# Fossil.
# def import_subcaves():
# print("-- Interpreting SubCaves from CaveDescriptions")
# troggle.parsers.subcaves.importAllSubcaves()
2020-07-07 01:35:58 +01:00