X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sfa%2Fstorage%2Fdbschema.py;h=5166b93c60cada3f973d8ebf0cfacd0d8e44d900;hb=fad16c7d54b658b37a9b42fbee47b0d4f51cb8ec;hp=3776d527d7b733e53dd202eb502f24960977ce83;hpb=99cb825b1ec4c7bc1ebf9075ca1c8d36fa0efc5f;p=sfa.git diff --git a/sfa/storage/dbschema.py b/sfa/storage/dbschema.py index 3776d527..5166b93c 100644 --- a/sfa/storage/dbschema.py +++ b/sfa/storage/dbschema.py @@ -1,3 +1,5 @@ +from __future__ import print_function + import sys import traceback @@ -62,10 +64,10 @@ class DBSchema: def drop_table (self, tablename): if self.table_exists (tablename): - print >>sys.stderr, "%s: Dropping table %s"%(DBSchema.header,tablename) + print("%s: Dropping table %s"%(DBSchema.header,tablename), file=sys.stderr) self.engine.execute ("drop table %s cascade"%tablename) else: - print >>sys.stderr, "%s: no need to drop table %s"%(DBSchema.header,tablename) + print("%s: no need to drop table %s"%(DBSchema.header,tablename), file=sys.stderr) def handle_old_releases (self): try: @@ -75,7 +77,7 @@ class DBSchema: # (.) we've just created the db, so it's either a fresh install, or # (.) we come from a 'very old' depl. # in either case, an import is required but there's nothing to clean up - print >> sys.stderr,"%s: make sure to run import"%(DBSchema.header,) + print("%s: make sure to run import"%(DBSchema.header,), file=sys.stderr) elif self.table_exists ('sfa_db_version'): # we come from an 'old' version self.drop_table ('records') @@ -85,7 +87,7 @@ class DBSchema: # we should be good here pass except: - print >> sys.stderr, "%s: unknown exception"%(DBSchema.header,) + print("%s: unknown exception"%(DBSchema.header,), file=sys.stderr) traceback.print_exc () # after this call the db schema and the version as known by migrate should @@ -120,7 +122,10 @@ class DBSchema: def nuke (self): model.drop_tables(self.engine) # so in this case it's like we haven't initialized the db at all - migrate.drop_version_control (self.url, self.repository) + try: + migrate.drop_version_control (self.url, self.repository) + except migrate.exceptions.DatabaseNotControlledError: + logger.log_exc("Failed to drop version control") if __name__ == '__main__':