Example #1
0
def _get_configurations_stage(prototype):
    prototype_lib = get_prototype_lib()
    cobjs = [prototype_lib[x]
             for x in prototype.configs.configuration_names]
    cobjs.sort(key=lambda y: y.indicative_cost)
    configurations_costing_data = json.dumps(
        [{
            'key': "Sourcing Errors",
            'values': [
                {'label': x.ident,
                 'value': (2 ** x.sourcing_errors.terrors) * (-1)}
                for x in cobjs
                ],
            'color': '#d67777',
        }, {
            'key': "Indicative Costing",
            'values': [
                {'label': x.ident,
                 'value': x.indicative_cost.native_value}
                for x in cobjs
                ],
            'color': '#4f99b4',
        }]
    )
    return {'configurations': cobjs,
            'configurations_costing': configurations_costing_data,
            'native_currency_symbol': BASE_CURRENCY_SYMBOL,
            }
Example #2
0
def _get_configurations_stage(prototype):
    prototype_lib = get_prototype_lib()
    cobjs = [prototype_lib[x]
             for x in prototype.configs.configuration_names]
    cobjs.sort(key=lambda y: y.indicative_cost)
    configurations_costing_data = json.dumps(
        [{
            'key': "Sourcing Errors",
            'values': [
                {'label': x.ident,
                 'value': (2 ** x.sourcing_errors.terrors) * (-1)}
                for x in cobjs
                ],
            'color': '#d67777',
        }, {
            'key': "Indicative Costing",
            'values': [
                {'label': x.ident,
                 'value': x.indicative_cost.native_value}
                for x in cobjs
                ],
            'color': '#4f99b4',
        }]
    )
    return {'configurations': cobjs,
            'configurations_costing': configurations_costing_data,
            'native_currency_symbol': BASE_CURRENCY_SYMBOL,
            }
Example #3
0
def cards(cardname=None):
    prototypes = get_prototype_lib()
    if cardname is None:
        stage_cards = [
            v for k, v in viewitems(prototypes)
            if isinstance(v, CardPrototype)
        ]
        stage_cards.sort(key=lambda x: (x.status, x.ident))

        series = {}
        tstatuses = {str(x): 0 for x in status.get_known_statuses()}
        for card in stage_cards:
            if card.configs.snoseries not in series.keys():
                series[card.configs.snoseries] = 1
            else:
                series[card.configs.snoseries] += 1
            tstatuses[str(card.status)] += 1
        statuses = [(x, tstatuses[str(x)])
                    for x in status.get_known_statuses()]

        stage = {
            'statuses':
            statuses,
            'series':
            series,
            'cards':
            stage_cards,
            'crumbroot':
            '/entityhub',
            'breadcrumbs': [
                Crumb(name="Entity Hub", path=""),
                Crumb(name="Modules", path="modules/"),
                Crumb(name="Cards", path="cards/")
            ]
        }
        return render_template('entityhub_cards.html',
                               stage=stage,
                               pagetitle="Cards")
    else:
        prototype = prototypes[cardname]
        stage = {
            'prototype':
            prototype,
            'inclusion':
            ehproducts.get_module_inclusion(cardname),
            'crumbroot':
            '/entityhub',
            'breadcrumbs': [
                Crumb(name="Entity Hub", path=""),
                Crumb(name="Modules", path="modules/"),
                Crumb(name="Cards", path="cards/"),
                Crumb(name=cardname, path="cards/" + cardname)
            ]
        }
        return render_template('entityhub_card_detail.html',
                               stage=stage,
                               pagetitle=cardname + " Card Details")
Example #4
0
def cables(cblname=None):
    prototypes = get_prototype_lib()
    if cblname is None:
        stage_cables = [
            v for k, v in viewitems(prototypes)
            if isinstance(v, CablePrototype)
        ]
        stage_cables.sort(key=lambda x: (x.status, x.ident))

        series = {}

        for cable in stage_cables:
            if cable.configs.snoseries not in series.keys():
                series[cable.configs.snoseries] = 1
            else:
                series[cable.configs.snoseries] += 1

        stage = {
            'series':
            series,
            'cables':
            stage_cables,
            'crumbroot':
            '/entityhub',
            'breadcrumbs': [
                Crumb(name="Entity Hub", path=""),
                Crumb(name="Modules", path="modules/"),
                Crumb(name="Cables", path="cables/")
            ]
        }
        return render_template('entityhub_cables.html',
                               stage=stage,
                               pagetitle="Cables")
    else:
        prototype = prototypes[cblname]
        stage = {
            'prototype':
            prototype,
            'inclusion':
            ehproducts.get_module_inclusion(cblname),
            'crumbroot':
            '/entityhub',
            'breadcrumbs': [
                Crumb(name="Entity Hub", path=""),
                Crumb(name="Modules", path="modules/"),
                Crumb(name="Cables", path="cables/"),
                Crumb(name=cblname, path="cables/" + cblname)
            ]
        }
        return render_template('entityhub_cable_detail.html',
                               stage=stage,
                               pagetitle=cblname + " Cable Details")
Example #5
0
def get_bom_superset(regen=False):
    global superset_cobom
    if not regen and superset_cobom is not None:
        return superset_cobom
    prototypes = get_prototype_lib()
    boms = []
    logger.info("Building superset composite BOM")
    for ident, prototype in prototypes.iteritems():
        boms.append(prototype.obom)
    logger.info("Collating into superset composite BOM")
    superset_cobom = CompositeOutputBom(boms, name='ALL')
    superset_cobom.collapse_wires()
    return superset_cobom
Example #6
0
def get_bom_superset(regen=False):
    global superset_cobom
    if not regen and superset_cobom is not None:
        return superset_cobom
    prototypes = get_prototype_lib()
    boms = []
    logger.info("Building superset composite BOM")
    for ident, prototype in viewitems(prototypes):
        logger.info("Adding {0} to superset cobom...".format(ident))
        boms.append(prototype.obom)
    logger.info("Collating into superset composite BOM")
    superset_cobom = CompositeOutputBom(boms, name='ALL')
    superset_cobom.collapse_wires()
    return superset_cobom
Example #7
0
def generate_prototypelib():
    """
    Profiles the prototype library generation.

    When the ``entityhub.modules`` module is loaded, it automatically generates the
    prototype library from the projects on the filesystem. This function profiles
    the generation of the (thin) library.

    :download:`Raw execution profile <../../../profiling/entityhub/modules/modules.profile>`
    :download:`SVG of execution profile <../../../profiling/entityhub/modules/modules.profile.svg>`

    .. rubric:: Execution Profile

    .. image:: ../../../profiling/entityhub/modules/modules.profile.svg

    .. rubric:: pstats Output

    .. literalinclude:: ../../../profiling/entityhub/modules/modules.profile.stats

    """
    return modules.get_prototype_lib(regen=True)
Example #8
0
def generate_prototypelib():
    """
    Profiles the prototype library generation.

    When the ``entityhub.modules`` module is loaded, it automatically generates the
    prototype library from the projects on the filesystem. This function profiles
    the generation of the (thin) library.

    :download:`Raw execution profile <../../../profiling/entityhub/modules/modules.profile>`
    :download:`SVG of execution profile <../../../profiling/entityhub/modules/modules.profile.svg>`

    .. rubric:: Execution Profile

    .. image:: ../../../profiling/entityhub/modules/modules.profile.svg

    .. rubric:: pstats Output

    .. literalinclude:: ../../../profiling/entityhub/modules/modules.profile.stats

    """
    return modules.get_prototype_lib(regen=True)
Example #9
0
def cards(cardname=None):
    prototypes = get_prototype_lib()
    if cardname is None:
        stage_cards = [v for k, v in viewitems(prototypes)
                       if isinstance(v, CardPrototype)]
        stage_cards.sort(key=lambda x: (x.status, x.ident))

        series = {}
        tstatuses = {str(x): 0 for x in status.get_known_statuses()}
        for card in stage_cards:
            if card.configs.snoseries not in series.keys():
                series[card.configs.snoseries] = 1
            else:
                series[card.configs.snoseries] += 1
            tstatuses[str(card.status)] += 1
        statuses = [(x, tstatuses[str(x)]) for x in status.get_known_statuses()]

        stage = {'statuses': statuses,
                 'series': series,
                 'cards': stage_cards,
                 'crumbroot': '/entityhub',
                 'breadcrumbs': [Crumb(name="Entity Hub", path=""),
                                 Crumb(name="Modules", path="modules/"),
                                 Crumb(name="Cards", path="cards/")]
                 }
        return render_template('entityhub_cards.html', stage=stage,
                               pagetitle="Cards")
    else:
        prototype = prototypes[cardname]
        stage = {'prototype': prototype,
                 'inclusion': ehproducts.get_module_inclusion(cardname),
                 'crumbroot': '/entityhub',
                 'breadcrumbs': [Crumb(name="Entity Hub", path=""),
                                 Crumb(name="Modules", path="modules/"),
                                 Crumb(name="Cards", path="cards/"),
                                 Crumb(name=cardname, path="cards/"+cardname)]
                 }
        return render_template('entityhub_card_detail.html', stage=stage,
                               pagetitle=cardname + " Card Details")
Example #10
0
def generate_thick_prototypelib():
    """
    Profiles the prototype library generation with full object instantiation.

    The prototypes created at module load are thin prototypes, with various
    sections left for on-demand loading by default. This is useful when
    tendril is used as a script. However, when run as a server, this filling
    out of each prototype makes the first page load (per daemon) an
    incredibly slow process.

    This function prototypes the validation of each prototype. The validation
    process necessarily requires thick prototypes, since much of the data to be
    validated resides in the information not loaded on object instantiation.
    Tendril also uses the same validation hook to warm up it's caches when
    run as a server (as controlled by the WARM_UP_CACHES config option).

    :download:`Raw execution profile <../../../profiling/entityhub/modules/modules_thick.profile>`
    :download:`SVG of execution profile <../../../profiling/entityhub/modules/modules_thick.profile.svg>`

    .. rubric:: Execution Profile

    .. image:: ../../../profiling/entityhub/modules/modules_thick.profile.svg

    .. rubric:: pstats Output

    .. literalinclude:: ../../../profiling/entityhub/modules/modules_thick.profile.stats

    """
    pl = modules.get_prototype_lib(regen=False)
    tcount = len(pl.keys())
    count = 0
    for k, p in pl.iteritems():
        count += 1
        start_time = timeit.default_timer()
        temp = p.validation_errors
        elapsed = timeit.default_timer() - start_time
        print "{2:>3}/{3:3} Filled out {0:40} took {1:>6.2f}s" \
              "".format(k, elapsed, count, tcount)
Example #11
0
def generate_thick_prototypelib():
    """
    Profiles the prototype library generation with full object instantiation.

    The prototypes created at module load are thin prototypes, with various
    sections left for on-demand loading by default. This is useful when
    tendril is used as a script. However, when run as a server, this filling
    out of each prototype makes the first page load (per daemon) an
    incredibly slow process.

    This function prototypes the validation of each prototype. The validation
    process necessarily requires thick prototypes, since much of the data to be
    validated resides in the information not loaded on object instantiation.
    Tendril also uses the same validation hook to warm up it's caches when
    run as a server (as controlled by the WARM_UP_CACHES config option).

    :download:`Raw execution profile <../../../profiling/entityhub/modules/modules_thick.profile>`
    :download:`SVG of execution profile <../../../profiling/entityhub/modules/modules_thick.profile.svg>`

    .. rubric:: Execution Profile

    .. image:: ../../../profiling/entityhub/modules/modules_thick.profile.svg

    .. rubric:: pstats Output

    .. literalinclude:: ../../../profiling/entityhub/modules/modules_thick.profile.stats

    """
    pl = modules.get_prototype_lib(regen=False)
    tcount = len(pl.keys())
    count = 0
    for k, p in pl.iteritems():
        count += 1
        start_time = timeit.default_timer()
        temp = p.validation_errors
        elapsed = timeit.default_timer() - start_time
        print "{2:>3}/{3:3} Filled out {0:40} took {1:>6.2f}s" "".format(k, elapsed, count, tcount)
Example #12
0
def cables(cblname=None):
    prototypes = get_prototype_lib()
    if cblname is None:
        stage_cables = [v for k, v in viewitems(prototypes)
                        if isinstance(v, CablePrototype)]
        stage_cables.sort(key=lambda x: (x.status, x.ident))

        series = {}

        for cable in stage_cables:
            if cable.configs.snoseries not in series.keys():
                series[cable.configs.snoseries] = 1
            else:
                series[cable.configs.snoseries] += 1

        stage = {'series': series,
                 'cables': stage_cables,
                 'crumbroot': '/entityhub',
                 'breadcrumbs': [Crumb(name="Entity Hub", path=""),
                                 Crumb(name="Modules", path="modules/"),
                                 Crumb(name="Cables", path="cables/")]
                 }
        return render_template('entityhub_cables.html', stage=stage,
                               pagetitle="Cables")
    else:
        prototype = prototypes[cblname]
        stage = {'prototype': prototype,
                 'inclusion': ehproducts.get_module_inclusion(cblname),
                 'crumbroot': '/entityhub',
                 'breadcrumbs': [Crumb(name="Entity Hub", path=""),
                                 Crumb(name="Modules", path="modules/"),
                                 Crumb(name="Cables", path="cables/"),
                                 Crumb(name=cblname, path="cables/"+cblname)]
                 }
        return render_template('entityhub_cable_detail.html', stage=stage,
                               pagetitle=cblname + " Cable Details")
Example #13
0
def modules_list():
    prototypes = get_prototype_lib()
    moduls = sorted(prototypes.keys())
    return jsonify({'modules': moduls})
Example #14
0
def reload_card(cardname):
    prototypes = get_prototype_lib()
    prototype = prototypes[cardname]
    prototype.reload()
    return redirect(url_for(".cards", cardname=cardname))
Example #15
0
def modules_list():
    prototypes = get_prototype_lib()
    moduls = sorted(prototypes.keys())
    return jsonify({'modules': moduls})