2019-12-20 12:50:41 -05:00
|
|
|
import logging
|
|
|
|
##
|
2019-11-01 02:54:51 -04:00
|
|
|
import gi
|
|
|
|
gi.require_version('BlockDev', '2.0')
|
|
|
|
from gi.repository import BlockDev, GLib
|
|
|
|
|
2019-11-04 23:18:28 -05:00
|
|
|
BlockDev.ensure_init([None])
|
2019-11-01 02:54:51 -04:00
|
|
|
|
2019-12-20 12:50:41 -05:00
|
|
|
_logger = logging.getLogger('disk:_common')
|
|
|
|
|
2019-11-04 23:18:28 -05:00
|
|
|
|
|
|
|
def addBDPlugin(plugin_name):
|
2019-12-20 12:50:41 -05:00
|
|
|
_logger.info('Enabling plugin: {0}'.format(plugin_name))
|
2019-11-04 23:18:28 -05:00
|
|
|
plugins = BlockDev.get_available_plugin_names()
|
|
|
|
plugins.append(plugin_name)
|
|
|
|
plugins = list(set(plugins)) # Deduplicate
|
2019-12-20 12:50:41 -05:00
|
|
|
_logger.debug('Currently loaded plugins: {0}'.format(','.join(plugins)))
|
2019-11-04 23:18:28 -05:00
|
|
|
spec = BlockDev.plugin_specs_from_names(plugins)
|
2019-12-20 12:50:41 -05:00
|
|
|
_logger.debug('Plugin {0} loaded.'.format(plugin_name))
|
2019-11-04 23:18:28 -05:00
|
|
|
return(BlockDev.ensure_init(spec))
|