2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2024-11-29 05:11:52 +00:00

More tidying

This commit is contained in:
Philip Sargent 2020-04-14 20:46:45 +01:00
parent 09bbf81915
commit 5e48687347

View File

@ -50,14 +50,6 @@ def import_people():
parsers.people.LoadPersonsExpos() parsers.people.LoadPersonsExpos()
def import_logbooks(): def import_logbooks():
# The below line was causing errors I didn't understand (it said LOGFILE was a string), and I couldn't be bothered to figure
# what was going on so I just catch the error with a try. - AC 21 May
try:
settings.LOGFILE.write('\nBegun importing logbooks at ' + time.asctime() +'\n'+'-'*60)
except:
print "EXCEPTION when trying to write to", settings.LOGFILE
pass
import parsers.logbooks import parsers.logbooks
parsers.logbooks.LoadLogbooks() parsers.logbooks.LoadLogbooks()
@ -68,6 +60,7 @@ def import_survex():
def import_QMs(): def import_QMs():
import parsers.QMs import parsers.QMs
# import process runs on qm.csv in only 3 caves, not 264!
def import_surveys(): def import_surveys():
import parsers.surveys import parsers.surveys
@ -81,6 +74,11 @@ def import_tunnelfiles():
import parsers.surveys import parsers.surveys
parsers.surveys.LoadTunnelFiles() parsers.surveys.LoadTunnelFiles()
def pageredirects():
for oldURL, newURL in [("indxal.htm", reverse("caveindex"))]:
f = troggle.flatpages.models.Redirect(originalURL = oldURL, newURL = newURL)
f.save()
def reset(): def reset():
""" Wipe the troggle database and import everything from legacy data """ Wipe the troggle database and import everything from legacy data
""" """
@ -151,11 +149,6 @@ def dumplogbooks():
f.close() f.close()
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
def pageredirects():
for oldURL, newURL in [("indxal.htm", reverse("caveindex"))]:
f = troggle.flatpages.models.Redirect(originalURL = oldURL, newURL = newURL)
f.save()
def usage(): def usage():
print("""Usage is 'python databaseReset.py <command>' print("""Usage is 'python databaseReset.py <command>'
where command is: where command is:
@ -182,24 +175,22 @@ if __name__ == "__main__":
import sys import sys
import django import django
django.setup() django.setup()
if "scans" in sys.argv:
import_surveyscans() if "caves" in sys.argv:
elif "caves" in sys.argv:
import_caves() import_caves()
elif "logbooks" in sys.argv:
# management.call_command('syncdb', interactive=False) # this sets the path so that import settings works in import_survex
import_logbooks()
elif "people" in sys.argv: elif "people" in sys.argv:
import_people() import_people()
elif "QMs" in sys.argv: elif "QMs" in sys.argv:
import_QMs() import_QMs()
elif "tunnel" in sys.argv: elif "reload_db" in sys.argv:
import_tunnelfiles() reload_db()
elif "reset" in sys.argv: elif "reset" in sys.argv:
reset() reset()
elif "resetend" in sys.argv: elif "scans" in sys.argv:
import_QMs() import_surveyscans()
import_tunnelfiles()
import_surveys()
#import_descriptions() # no longer present
#parse_descriptions() # no longer present
elif "survex" in sys.argv: elif "survex" in sys.argv:
# management.call_command('syncdb', interactive=False) # this sets the path so that import settings works in import_survex # management.call_command('syncdb', interactive=False) # this sets the path so that import settings works in import_survex
import_survex() import_survex()
@ -207,21 +198,24 @@ if __name__ == "__main__":
# management.call_command('syncdb', interactive=False) # this sets the path so that import settings works in import_survex # management.call_command('syncdb', interactive=False) # this sets the path so that import settings works in import_survex
import parsers.survex import parsers.survex
parsers.survex.LoadPos() parsers.survex.LoadPos()
elif "logbooks" in sys.argv: elif "surveys" in sys.argv:
# management.call_command('syncdb', interactive=False) # this sets the path so that import settings works in import_survex import_surveys()
import_logbooks() elif "tunnel" in sys.argv:
import_tunnelfiles()
elif "help" in sys.argv:
usage()
elif "resetend" in sys.argv:
import_QMs()
import_tunnelfiles()
import_surveys()
#import_descriptions() # no longer present
#parse_descriptions() # no longer present
# elif "writeCaves" in sys.argv:
# writeCaves() # no longer present
elif "autologbooks" in sys.argv: elif "autologbooks" in sys.argv:
import_auto_logbooks() import_auto_logbooks()
elif "dumplogbooks" in sys.argv: elif "dumplogbooks" in sys.argv:
dumplogbooks() dumplogbooks()
# elif "writeCaves" in sys.argv:
# writeCaves() # no longer present
elif "surveys" in sys.argv:
import_surveys()
elif "help" in sys.argv:
usage()
elif "reload_db" in sys.argv:
reload_db()
else: else:
print("%s not recognised" % sys.argv) print("%s not recognised" % sys.argv)
usage() usage()