mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 08:58:59 +00:00
Gracefully disable the mysql module if MySQLdb isn't available
This commit is contained in:
parent
feed585380
commit
a5631f9a65
@ -14,11 +14,17 @@ might look like::
|
||||
You can also use a defaults file::
|
||||
|
||||
mysql.default_file: '/etc/mysql/debian.cnf'
|
||||
|
||||
Required python modules: MySQLdb
|
||||
'''
|
||||
|
||||
import logging
|
||||
try:
|
||||
import MySQLdb
|
||||
import MySQLdb.cursors
|
||||
has_mysqldb = True
|
||||
except ImportError:
|
||||
has_mysqldb = True
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
__opts__ = {}
|
||||
@ -28,6 +34,7 @@ def __virtual__():
|
||||
Only load this module if the mysql config is set
|
||||
'''
|
||||
if any(k.startswith('mysql.') for k in __opts__.keys()):
|
||||
if has_mysqldb:
|
||||
return 'mysql'
|
||||
return False
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user