diff --git a/databaseReset.py b/databaseReset.py index efdb48b..9133107 100644 --- a/databaseReset.py +++ b/databaseReset.py @@ -50,14 +50,6 @@ def import_people(): parsers.people.LoadPersonsExpos() 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 parsers.logbooks.LoadLogbooks() @@ -68,7 +60,8 @@ def import_survex(): def import_QMs(): import parsers.QMs - + # import process runs on qm.csv in only 3 caves, not 264! + def import_surveys(): import parsers.surveys parsers.surveys.parseSurveys(logfile=settings.LOGFILE) @@ -81,6 +74,11 @@ def import_tunnelfiles(): import parsers.surveys 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(): """ Wipe the troggle database and import everything from legacy data """ @@ -151,11 +149,6 @@ def dumplogbooks(): 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(): print("""Usage is 'python databaseReset.py ' where command is: @@ -182,24 +175,22 @@ if __name__ == "__main__": import sys import django django.setup() - if "scans" in sys.argv: - import_surveyscans() - elif "caves" in sys.argv: + + if "caves" in sys.argv: 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: import_people() elif "QMs" in sys.argv: import_QMs() - elif "tunnel" in sys.argv: - import_tunnelfiles() + elif "reload_db" in sys.argv: + reload_db() elif "reset" in sys.argv: reset() - elif "resetend" in sys.argv: - import_QMs() - import_tunnelfiles() - import_surveys() - #import_descriptions() # no longer present - #parse_descriptions() # no longer present + elif "scans" in sys.argv: + import_surveyscans() elif "survex" in sys.argv: # management.call_command('syncdb', interactive=False) # this sets the path so that import settings works in 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 import parsers.survex parsers.survex.LoadPos() - 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 "surveys" in sys.argv: + import_surveys() + 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: import_auto_logbooks() elif "dumplogbooks" in sys.argv: 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: print("%s not recognised" % sys.argv) usage()