summaryrefslogtreecommitdiffstats
path: root/parsers/imports.py
blob: e2a62241b4ac45ef7039911d548cb9432fe8c038 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
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
from django.db import transaction

import troggle.settings
import troggle.parsers.caves
import troggle.parsers.people
import troggle.parsers.surveys
import troggle.parsers.logbooks
import troggle.parsers.QMs

def import_caves():
    print("-- Importing Caves to ",end="")
    print(django.db.connections.databases['default']['NAME'])
    # wrap the entire import in a transaction
    with transaction.atomic():
        troggle.parsers.caves.readcaves()

def import_people():
    print("-- Importing People (folk.csv) to ",end="")
    print(django.db.connections.databases['default']['NAME'])
    with transaction.atomic():
        troggle.parsers.people.LoadPersonsExpos()

def import_surveyscans():
    print("-- Importing Survey Scans")
    with transaction.atomic():
        troggle.parsers.surveys.LoadListScans()

def import_logbooks():
    print("-- Importing Logbooks")
    with transaction.atomic():
        troggle.parsers.logbooks.LoadLogbooks()

def import_QMs():
    print("-- Importing old QMs for 161, 204, 234 from CSV files")
    with transaction.atomic():
        troggle.parsers.QMs.Load_QMs()

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")
    print(" - Survex Blocks")
    with transaction.atomic():
        troggle.parsers.survex.LoadSurvexBlocks()
    print(" - Survex entrances x/y/z Positions")
    with transaction.atomic():
        troggle.parsers.survex.LoadPositions()

def import_loadpos():
    # when this import is moved to the top with the rest it all crashes horribly
    import troggle.parsers.survex 
    print(" - Survex entrances x/y/z Positions")
    with transaction.atomic():
        troggle.parsers.survex.LoadPositions()

def import_drawingsfiles():
    print("-- Importing Drawings files")
    with transaction.atomic():
        troggle.parsers.surveys.LoadDrawingFiles()