From 46351329b808000f478c53e600e5b9afda633a86 Mon Sep 17 00:00:00 2001 From: brent s Date: Mon, 4 Nov 2019 23:38:32 -0500 Subject: [PATCH] namespace issue fixed! --- aif/__init__.py | 4 +--- aif/constants.py | 14 ++++++++++--- aif/disk/__init__.py | 49 ++++++++++++++++++++++---------------------- aif/disk/block.py | 7 ++++--- 4 files changed, 41 insertions(+), 33 deletions(-) diff --git a/aif/__init__.py b/aif/__init__.py index 7e99210..ab12177 100644 --- a/aif/__init__.py +++ b/aif/__init__.py @@ -3,6 +3,7 @@ try: except ImportError: from . import constants_fallback as constants +from . import utils from . import disk from . import system from . import config @@ -10,9 +11,6 @@ from . import envsetup from . import log from . import network from . import pacman -from . import utils - - class AIF(object): diff --git a/aif/constants.py b/aif/constants.py index 2eea551..5036924 100644 --- a/aif/constants.py +++ b/aif/constants.py @@ -1,8 +1,16 @@ from .constants_fallback import * ## -import aif.disk._common -_BlockDev = aif.disk._common.BlockDev -aif.disk._common.addBDPlugin('part') +# This creates a conflict of imports, unfortunately. +# So we end up doing the same thing in aif/disk/(__init__.py => _common.py)... C'est la vie. +# Patches welcome. +# import aif.disk._common +# _BlockDev = aif.disk._common.BlockDev +# aif.disk._common.addBDPlugin('part') +import gi +gi.require_version('BlockDev', '2.0') +from gi.repository import BlockDev as _BlockDev +from gi.repository import GLib +_BlockDev.ensure_init(_BlockDev.plugin_specs_from_names(('part', ))) # LIBBLOCKDEV FLAG INDEXING / PARTED <=> LIBBLOCKDEV FLAG CONVERSION diff --git a/aif/disk/__init__.py b/aif/disk/__init__.py index 1f0f126..400f1bc 100644 --- a/aif/disk/__init__.py +++ b/aif/disk/__init__.py @@ -1,28 +1,29 @@ -try: - from . import block -except ImportError: - from . import block_fallback as block -try: - from . import filesystem_fallback -except ImportError: - from . import filesystem_fallback as filesystem - -try: - from . import luks_fallback -except ImportError: - from . import luks_fallback as luks - -try: - from . import lvm_fallback -except ImportError: - from . import lvm_fallback as lvm - -try: - from . import mdadm_fallback -except ImportError: - from . import mdadm_fallback as mdadm - try: from . import _common except ImportError: pass # GI isn't supported, so we don't even use a fallback. + +try: + from . import block +except ImportError: + from . import block_fallback as block + +try: + from . import filesystem +except ImportError: + from . import filesystem_fallback as filesystem + +try: + from . import luks +except ImportError: + from . import luks_fallback as luks + +try: + from . import lvm +except ImportError: + from . import lvm_fallback as lvm + +try: + from . import mdadm +except ImportError: + from . import mdadm_fallback as mdadm diff --git a/aif/disk/block.py b/aif/disk/block.py index fdaa9af..362945d 100644 --- a/aif/disk/block.py +++ b/aif/disk/block.py @@ -1,13 +1,14 @@ import re ## -import parted +import parted # Do I need this if I can have libblockdev's mounts API? Is there a way to get current mounts? import psutil ## import aif.constants -import aif.disk._common import aif.utils +from . import _common -_BlockDev = aif.disk._common.BlockDev + +_BlockDev = _common.BlockDev class Partition(object):