diff options
author | Martin Braun <martin.braun@ettus.com> | 2017-12-12 09:59:50 -0800 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2017-12-22 15:05:58 -0800 |
commit | d3e6dd11406893bfbc5537dfbe74d8151bbc1280 (patch) | |
tree | 8663263b3c5a4ff7202e01a5f9c5c6bb23969829 /mpm/python/usrp_mpm/periph_manager | |
parent | ea7cc7f8250cd9bdb41c1f22703d38be91fb6a84 (diff) | |
download | uhd-d3e6dd11406893bfbc5537dfbe74d8151bbc1280.tar.gz uhd-d3e6dd11406893bfbc5537dfbe74d8151bbc1280.tar.bz2 uhd-d3e6dd11406893bfbc5537dfbe74d8151bbc1280.zip |
mpm: Harmonize imports, tidy + sort modules
- Moved nijesdcore to cores/
- Moved udev, net, dtoverlay, uio to sys_utils/
- Made all imports non-relative (except in __init__.py files)
- Removed some unnecessary imports
- Reordered some imports for Python conventions
Diffstat (limited to 'mpm/python/usrp_mpm/periph_manager')
-rw-r--r-- | mpm/python/usrp_mpm/periph_manager/CMakeLists.txt | 1 | ||||
-rw-r--r-- | mpm/python/usrp_mpm/periph_manager/__init__.py.in | 6 | ||||
-rw-r--r-- | mpm/python/usrp_mpm/periph_manager/base.py | 12 | ||||
-rw-r--r-- | mpm/python/usrp_mpm/periph_manager/n310.py | 14 | ||||
-rw-r--r-- | mpm/python/usrp_mpm/periph_manager/test.py | 4 | ||||
-rw-r--r-- | mpm/python/usrp_mpm/periph_manager/udev.py | 52 |
6 files changed, 15 insertions, 74 deletions
diff --git a/mpm/python/usrp_mpm/periph_manager/CMakeLists.txt b/mpm/python/usrp_mpm/periph_manager/CMakeLists.txt index 49ca8e411..51bbf457c 100644 --- a/mpm/python/usrp_mpm/periph_manager/CMakeLists.txt +++ b/mpm/python/usrp_mpm/periph_manager/CMakeLists.txt @@ -24,7 +24,6 @@ SET(USRP_MPM_PERIPHMGR_FILES ${CMAKE_CURRENT_SOURCE_DIR}/base.py ${CMAKE_CURRENT_SOURCE_DIR}/n310.py ${CMAKE_CURRENT_SOURCE_DIR}/test.py - ${CMAKE_CURRENT_SOURCE_DIR}/udev.py ) LIST(APPEND USRP_MPM_FILES ${USRP_MPM_PERIPHMGR_FILES}) SET(USRP_MPM_FILES ${USRP_MPM_FILES} PARENT_SCOPE) diff --git a/mpm/python/usrp_mpm/periph_manager/__init__.py.in b/mpm/python/usrp_mpm/periph_manager/__init__.py.in index 34d29137a..5d99b0b5e 100644 --- a/mpm/python/usrp_mpm/periph_manager/__init__.py.in +++ b/mpm/python/usrp_mpm/periph_manager/__init__.py.in @@ -18,9 +18,7 @@ periph_manager __init__.py """ -# This is where the import magic happens -from .. import libpyusrp_periphs as lib -from .. import dboard_manager -from .. import mpmtypes +from .base import PeriphManagerBase +# This is where the import magic happens from .${MPM_DEVICE} import ${MPM_DEVICE} as periph_manager diff --git a/mpm/python/usrp_mpm/periph_manager/base.py b/mpm/python/usrp_mpm/periph_manager/base.py index ff86137df..c73ba6ef4 100644 --- a/mpm/python/usrp_mpm/periph_manager/base.py +++ b/mpm/python/usrp_mpm/periph_manager/base.py @@ -20,16 +20,16 @@ Mboard implementation base class from __future__ import print_function import os -from concurrent import futures from hashlib import md5 +from concurrent import futures from builtins import str from builtins import range from builtins import object from six import iteritems, itervalues -from ..mpmlog import get_logger -from .udev import get_eeprom_paths -from .udev import get_spidev_nodes -from usrp_mpm import dtoverlay +from usrp_mpm.mpmlog import get_logger +from usrp_mpm.sys_utils.udev import get_eeprom_paths +from usrp_mpm.sys_utils.udev import get_spidev_nodes +from usrp_mpm.sys_utils import dtoverlay from usrp_mpm import eeprom from usrp_mpm.rpc_server import no_claim, no_rpc @@ -37,7 +37,7 @@ def get_dboard_class_from_pid(pid): """ Given a PID, return a dboard class initializer callable. """ - from .. import dboard_manager + from usrp_mpm import dboard_manager for member in itervalues(dboard_manager.__dict__): try: if issubclass(member, dboard_manager.DboardManagerBase) and \ diff --git a/mpm/python/usrp_mpm/periph_manager/n310.py b/mpm/python/usrp_mpm/periph_manager/n310.py index 384c69e97..ed1b5d164 100644 --- a/mpm/python/usrp_mpm/periph_manager/n310.py +++ b/mpm/python/usrp_mpm/periph_manager/n310.py @@ -25,17 +25,13 @@ import shutil import subprocess from six import iteritems, itervalues from builtins import object -from .base import PeriphManagerBase -from ..net import get_iface_addrs -from ..net import byte_to_mac -from ..mpmtypes import SID +from usrp_mpm.periph_manager import PeriphManagerBase +from usrp_mpm.mpmtypes import SID from usrp_mpm.rpc_server import no_rpc -from usrp_mpm import net -from usrp_mpm import dtoverlay +from usrp_mpm.sys_utils import dtoverlay +from usrp_mpm.sys_utils.sysfs_gpio import SysFSGPIO +from usrp_mpm.sys_utils.uio import UIO from usrp_mpm.xports import XportMgrUDP, XportMgrLiberio -from ..sysfs_gpio import SysFSGPIO -from .. import libpyusrp_periphs as lib -from ..uio import UIO N3XX_DEFAULT_EXT_CLOCK_FREQ = 10e6 N3XX_DEFAULT_CLOCK_SOURCE = 'external' diff --git a/mpm/python/usrp_mpm/periph_manager/test.py b/mpm/python/usrp_mpm/periph_manager/test.py index 03bd28956..dd99b56b2 100644 --- a/mpm/python/usrp_mpm/periph_manager/test.py +++ b/mpm/python/usrp_mpm/periph_manager/test.py @@ -19,10 +19,10 @@ test periph_manager implementation module """ from __future__ import print_function -from .base import PeriphManagerBase -from . import dboard_manager import random import string +from usrp_mpm.periph_manager import PeriphManagerBase +from usrp_mpm import dboard_manager class test(PeriphManagerBase): diff --git a/mpm/python/usrp_mpm/periph_manager/udev.py b/mpm/python/usrp_mpm/periph_manager/udev.py deleted file mode 100644 index 33cb3367a..000000000 --- a/mpm/python/usrp_mpm/periph_manager/udev.py +++ /dev/null @@ -1,52 +0,0 @@ -# -# Copyright 2017 Ettus Research (National Instruments) -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. -# - -import os -import pyudev -from ..mpmlog import get_logger - -def get_eeprom_paths(address): - """ - Return list of EEPROM device paths for a given I2C address. - If no device paths are found, an empty list is returned. - """ - context = pyudev.Context() - parent = pyudev.Device.from_name(context, "platform", address) - paths = [d.device_node if d.device_node is not None else d.sys_path - for d in context.list_devices(parent=parent, subsystem="nvmem")] - if len(paths) == 0: - return [] - # We need to sort this so 9-0050 comes before 10-0050 (etc.) - maxlen = max((len(os.path.split(p)[1]) for p in paths)) - paths = sorted( - paths, - key=lambda x: "{:>0{maxlen}}".format(os.path.split(x)[1], maxlen=maxlen) - ) - return [os.path.join(x, 'nvmem') for x in paths] - -def get_spidev_nodes(spi_master): - """ - Return list of spidev device paths for a given SPI master. If no valid paths - can be found, an empty list is returned. - """ - context = pyudev.Context() - parent = pyudev.Device.from_name(context, "platform", spi_master) - return [ - device.device_node - for device in context.list_devices(parent=parent, subsystem="spidev") - ] - |