diff options
author | Rob Austein <sra@hactrn.net> | 2016-03-23 22:19:43 +0000 |
---|---|---|
committer | Rob Austein <sra@hactrn.net> | 2016-03-23 22:19:43 +0000 |
commit | 7ae30a179529efbe6d7895104caa7d457ebe4c83 (patch) | |
tree | f00d34a64a159f65671309001ce1053e2ec34237 | |
parent | 8e46ff7d680f05f7690ea7702f5cb596fbc76c3e (diff) |
Wrap a MySQL-specific error check so it doesn't cause problems when using other engines.
svn path=/branches/tk705/; revision=6326
-rw-r--r-- | rpki/gui/routeview/util.py | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/rpki/gui/routeview/util.py b/rpki/gui/routeview/util.py index 77ff04c7..169fbf00 100644 --- a/rpki/gui/routeview/util.py +++ b/rpki/gui/routeview/util.py @@ -16,7 +16,6 @@ __version__ = '$Id$' __all__ = ('import_routeviews_dump') import itertools -import _mysql_exceptions import os.path import subprocess import time @@ -32,6 +31,14 @@ from rpki.resource_set import resource_range_ipv4, resource_range_ipv6 from rpki.exceptions import BadIPResource import rpki.gui.app.timestamp +try: + import _mysql_exceptions +except ImportError: + class MySQLWarning(Exception): + "Dummy, nothing will ever raise this." +else: + MySQLWarning = _mysql_exceptions.Warning + # globals logger = logging.getLogger(__name__) @@ -57,7 +64,7 @@ class RouteDumpParser(object): try: logger.info('Dropping existing staging table...') self.cursor.execute('DROP TABLE IF EXISTS %s_new' % self.table) - except _mysql_exceptions.Warning: + except MySQLWarning: pass logger.info('Creating staging table...') @@ -94,7 +101,7 @@ class RouteDumpParser(object): try: logger.info('Dropping old table...') self.cursor.execute('DROP TABLE IF EXISTS %s_old' % self.table) - except _mysql_exceptions.Warning: + except MySQLWarning: pass logger.info('Swapping staging table with live table...') |