Ejemplo n.º 1
0
def get_sno_from_mac(mac=None, mactype=None, devicetype=None, session=None):

    if mactype is None:
        try:
            projectfolder = projects.cards[devicetype]
        except KeyError:
            raise AttributeError("Project for " + devicetype + " not found.")

        try:
            gcf = ConfigsFile(projectfolder)
            logger.debug("Using gEDA configs file from : " +
                         projects.cards[devicetype])
        except NoGedaProjectError:
            raise AttributeError(
                "gEDA project for " + devicetype + " not found."
            )

        modname = gcf.mactype
    else:
        modname = mactype
    funcname = 'get_sno_from_mac'

    mod = import_(os.path.join(macs_folder, modname))
    func = getattr(mod, funcname)
    return func(mac=mac, session=session)
Ejemplo n.º 2
0
def write_to_device(serialno, devicetype, suites=None):
    try:
        modname = get_product_calibformat(devicetype)
        mod = import_(os.path.join(INSTANCE_ROOT, "products", "calibformats", modname))
        func = getattr(mod, "write_to_device")
        func(serialno, devicetype, suites)
    except ImportError:
        logger.error("Write to device not implemented for devicetype : " + devicetype)
Ejemplo n.º 3
0
def write_to_device(serialno, devicetype, suites=None):
    try:
        modname = get_product_calibformat(devicetype)
        mod = import_(os.path.join(INSTANCE_ROOT, 'products',
                                   'calibformats', modname))
        func = getattr(mod, 'write_to_device')
        func(serialno, devicetype, suites)
    except ImportError:
        logger.error("Write to device not implemented for devicetype : " +
                     devicetype)
Ejemplo n.º 4
0
def get_device_mac(mactype='QASCv1', **kwargs):
    if mactype == 'QASCv1':
        funcname = 'get_device_mac'
        modname = mactype
        params = {}
    elif mactype == 'FT232DEVICEv1':
        funcname = 'get_device_mac'
        modname = mactype
        params = {'description': kwargs['description']}
    else:
        raise ValueError("Unrecognized MACTYPE")

    mod = import_(os.path.join(macs_folder, modname))
    func = getattr(mod, funcname)
    return func(**params)
Ejemplo n.º 5
0
def get_device_mac(mactype='QASCv1', **kwargs):
    if mactype == 'QASCv1':
        funcname = 'get_device_mac'
        modname = mactype
        params = {}
    elif mactype == 'FT232DEVICEv1':
        funcname = 'get_device_mac'
        modname = mactype
        params = {'description': kwargs['description']}
    else:
        raise ValueError("Unrecognized MACTYPE")

    mod = import_(os.path.join(macs_folder, modname))
    func = getattr(mod, funcname)
    return func(**params)
Ejemplo n.º 6
0
def get_mac_from_sno(serialno=None, session=None):
    devicetype = serialnos.get_serialno_efield(sno=serialno)

    try:
        projectfolder = projects.cards[devicetype]
    except KeyError:
        raise AttributeError("Project for " + devicetype + " not found.")

    try:
        gcf = ConfigsFile(projectfolder)
        logger.debug("Using gEDA configs file from : " +
                     projects.cards[devicetype])
    except NoGedaProjectError:
        raise AttributeError("gEDA project for " + devicetype + " not found.")

    modname = gcf.mactype
    funcname = 'get_mac_from_sno'

    mod = import_(os.path.join(macs_folder, modname))
    func = getattr(mod, funcname)
    return func(serialno=serialno, session=session)
Ejemplo n.º 7
0
def get_mac_from_sno(serialno=None, session=None):
    devicetype = serialnos.get_serialno_efield(sno=serialno)

    try:
        projectfolder = projects.cards[devicetype]
    except KeyError:
        raise AttributeError("Project for " + devicetype + " not found.")

    try:
        gcf = ConfigsFile(projectfolder)
        logger.debug("Using gEDA configs file from : " +
                     projects.cards[devicetype])
    except NoGedaProjectError:
        raise AttributeError("gEDA project for " + devicetype + " not found.")

    modname = gcf.mactype
    funcname = 'get_mac_from_sno'

    mod = import_(os.path.join(macs_folder, modname))
    func = getattr(mod, funcname)
    return func(serialno=serialno, session=session)
Ejemplo n.º 8
0
#
# You should have received a copy of the GNU Affero General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
"""
This file is part of tendril
See the COPYING, README, and INSTALL files for more information
"""

import os

from tendril.utils.config import TENDRIL_ROOT
from tendril.utils.config import INSTANCE_ROOT
from tendril.utils.fsutils import import_

INSTANCE_MOTIFS_ROOT = os.path.join(INSTANCE_ROOT, 'motifs')
INSTANCE_MOTIFS = import_(INSTANCE_MOTIFS_ROOT)


def create_motif_object(motifst):
    try:
        return INSTANCE_MOTIFS.create_motif_object(motifst)
    except ValueError:
        pass

    modname = motifst.split('.')[0]
    modstr = 'tendril.conventions.motifs.' + modname
    clsname = 'Motif' + modname

    try:
        mod = __import__(modstr, fromlist=[clsname])
        cls = getattr(mod, clsname)
Ejemplo n.º 9
0
from tendril.boms.outputbase import CompositeOutputBom
from tendril.boms.costingbase import HierachicalCostingBreakup
from tendril.boms.validate import ValidatableBase

from .modules import get_prototype_lib
from .prototypebase import PrototypeBase

from tendril.utils.files import yml as yaml
from tendril.utils import log

logger = log.get_logger(__name__, log.INFO)

PRODUCTS_ROOT = os.path.join(INSTANCE_ROOT, 'products')

INSTANCE_PRODUCT_CLASSES_PATH = os.path.join(PRODUCTS_ROOT, 'infoclasses')
INSTANCE_PRODUCT_CLASSES = import_(INSTANCE_PRODUCT_CLASSES_PATH)


class ProductInfo(ValidatableBase):
    def __init__(self, infodict, parent):
        super(ProductInfo, self).__init__()
        self._parent = parent
        self._infodict = infodict

    @property
    def ident(self):
        return self._parent.ident

    def labelinfo(self, sno):
        return sno, {}
Ejemplo n.º 10
0
#
# You should have received a copy of the GNU Affero General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
"""
This file is part of tendril
See the COPYING, README, and INSTALL files for more information
"""

import os

from tendril.utils.config import INSTANCE_ROOT
from tendril.utils.fsutils import import_


INSTANCE_TESTS_ROOT = os.path.join(INSTANCE_ROOT, 'tests')
INSTANCE_TESTS = import_(INSTANCE_TESTS_ROOT)


def get_test_object(testst, offline=False):

    try:
        return INSTANCE_TESTS.get_test_object(testst, offline=offline)
    except ValueError:
        pass

    if '.' in testst:
        modstr, clsname = testst.rsplit('.', 1)
    elif ':' in testst:
        modname, clsname = testst.split(':')
        clsname = 'Test' + clsname
        modstr = 'tendril.testing.tests.' + modname
Ejemplo n.º 11
0
    with open(os.path.join(INSTANCE_ROOT, 'redirect'), 'r') as f:
        INSTANCE_ROOT = f.read().strip()

config_constants_redirected = [
    ConfigConstant('INSTANCE_CONFIG_FILE',
                   "os.path.join(INSTANCE_ROOT, 'instance_config.py')",
                   'Path to the tendril instance configuration.'),
    ConfigConstant('LOCAL_CONFIG_FILE',
                   "os.path.join(INSTANCE_ROOT, 'local_config_overrides.py')",
                   'Path to local overrides to the instance configuration.'),
]

load_constants(config_constants_redirected)

if os.path.exists(INSTANCE_CONFIG_FILE):
    INSTANCE_CONFIG = import_(INSTANCE_CONFIG_FILE)
else:
    INSTANCE_CONFIG = {}

if os.path.exists(LOCAL_CONFIG_FILE):
    LOCAL_CONFIG = import_(LOCAL_CONFIG_FILE)
else:
    LOCAL_CONFIG = {}


class ConfigOption(object):
    """
    A configuration `option`. These options can be overridden
    by specifying them in the ``instance_config`` and
    ``local_config_overrides`` files.
Ejemplo n.º 12
0
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
"""
This file is part of tendril
See the COPYING, README, and INSTALL files for more information
"""

import os

from crochet import setup
setup()

from tendril.config.legacy import INSTANCE_ROOT
from tendril.utils.fsutils import import_

INSTANCE_INSTRUMENTS_ROOT = os.path.join(INSTANCE_ROOT, 'instruments')
INSTANCE_INSTRUMENTS = import_(INSTANCE_INSTRUMENTS_ROOT)

instument_pool = {}


def destroy_instrument(instst, instobj=None):
    if instobj is None:
        instument_pool.pop(instst)


def get_instrument_object(instst, dedicated=False):
    modname = instst
    modstr = 'tendril.testing.instruments.' + modname
    clsname = 'Instrument' + instst

    if dedicated is False:
Ejemplo n.º 13
0
"""


import os

from crochet import setup
setup()

from twisted.internet.protocol import connectionDone  # noqa

from tendril.utils.config import INSTANCE_ROOT
from tendril.utils.fsutils import import_


INSTANCE_INSTRUMENTS_ROOT = os.path.join(INSTANCE_ROOT, 'instruments')
INSTANCE_INSTRUMENTS = import_(INSTANCE_INSTRUMENTS_ROOT)

instument_pool = {}


def destroy_instrument(instst, instobj=None):
    if instobj is None:
        instument_pool.pop(instst)


def get_instrument_object(instst, dedicated=False):
    modname = instst
    modstr = 'tendril.testing.instruments.' + modname
    clsname = 'Instrument' + instst

    if dedicated is False:
Ejemplo n.º 14
0
from tendril.boms.outputbase import CompositeOutputBom
from tendril.boms.costingbase import HierachicalCostingBreakup
from tendril.boms.validate import ValidatableBase

from .modules import get_prototype_lib
from .prototypebase import PrototypeBase

from tendril.utils.files import yml as yaml
from tendril.utils import log
logger = log.get_logger(__name__, log.INFO)


PRODUCTS_ROOT = os.path.join(INSTANCE_ROOT, 'products')

INSTANCE_PRODUCT_CLASSES_PATH = os.path.join(PRODUCTS_ROOT, 'infoclasses')
INSTANCE_PRODUCT_CLASSES = import_(INSTANCE_PRODUCT_CLASSES_PATH)


class ProductInfo(ValidatableBase):
    def __init__(self, infodict, parent):
        super(ProductInfo, self).__init__()
        self._parent = parent
        self._infodict = infodict

    @property
    def ident(self):
        return self._parent.ident

    def labelinfo(self, sno):
        return sno, {}