Ejemplo n.º 1
0
def updateAbcTune(context, event):
    """TODO : see newAbcTune
    """
    portal = api.portal.get()
    try:
        context.abc = removeNonAscii(context.abc)
        addQ(context)
        addTuneType(context)
        addOrigins(context)
        addKeys(context)
        pt = getToolByName(portal, "portal_transforms")
        midi = pt.convertTo("audio/x-midi", context.abc)
        context.midi = midi.getData()
        score = pt.convertTo("image/png", context.abc)
        context.score = score.getData()
        sound = pt.convertTo("audio/mpeg", context.abc)
        context.sound = sound.getData()
        """
        This event notifier should be in module
        collective.abctuneset

        if parent.portal_type == 'abctuneset':
            log = '(IObjectModifiedEvent)abctune.updateAbcTune '
            log += parent.portal_type
            logger.info(log)
            notify(TuneInTuneSetModified(context))
        # _make_mp3(context)
        """

    except Exception:
        logger.info("updateAbcTune : abctune not modified...")
Ejemplo n.º 2
0
def makeFullTune(context, updateSound=True):
    validMIMEType(context)
    normalizer = getUtility(INormalizer)
    normalizedTitle = normalizer.normalize(context.title, locale='fr')
    try:
        context.abc = removeNonAscii(context.abc)
        addQ(context)
        addTuneType(context)
        addOrigins(context)
        addKeys(context)
    except Exception:
        msg = u'cannot add misc fields...!!!'
        logger.info(msg)
        annotateObject(context, msg=msg, key='ABC_ERRORS')
    try:
        pt = api.portal.get_tool('portal_transforms')
    except Exception:
        msg = u'cannot get portal_transforms tool'
        logger.info(msg)
        annotateObject(context, msg=msg, key='ABC_ERRORS')
    # For now, we only make SVG, PDF and OGG !
    updateSVG(context, normalizedTitle, pt)
    updatePDF(context, normalizedTitle, pt)
    # updatePNG(context, normalizedTitle, pt)
    if updateSound:
        updateOGG(context, normalizedTitle, pt)
Ejemplo n.º 3
0
def newAbcTune(context, event):
    portal = api.portal.get()
    """TODO : add %abc at the begining of the file if
    not present (for mimetype recognition)
    Create mp3 (sound field) only when asked
    """
    try:
        context.abc = removeNonAscii(context.abc)
        addQ(context)
        addTuneType(context)
        addOrigins(context)
        addKeys(context)
        pt = getToolByName(portal, "portal_transforms")
        midi = pt.convertTo("audio/x-midi", context.abc)
        context.midi = midi.getData()
        score = pt.convertTo("image/png", context.abc)
        context.score = score.getData()
        sound = pt.convertTo("audio/mpeg", context.abc)
        context.sound = sound.getData()
        logger.info("abc created !")
    except Exception:
        logger.info("abctune not created...")