mplayerManager.daemon = True
        mplayerManager.start()
        mplayerReader = MplayerReader()
        mplayerReader.daemon = True
        mplayerReader.start()

def stopMplayer():
    if not mplayerManager:
        return
    mplayerManager.kill()

def onExit():
    if tmpdir:
        shutil.rmtree(tmpdir)

addHook("deckClosed", stopMplayer)
atexit.register(onExit)

# PyAudio recording
##########################################################################

try:
    import pyaudio
    import wave

    PYAU_FORMAT = pyaudio.paInt16
    PYAU_CHANNELS = 1
    PYAU_RATE = 44100
    PYAU_INPUT_INDEX = None
except:
    pass
Exemple #2
0
        shutil.copy2(os.path.join(tmpdir, "tmp.png"),
                     os.path.join(mdir, target))
        return (True, target)
    finally:
        os.chdir(oldcwd)

def imageForLatex(deck, latex, build=True):
    "Return an image that represents 'latex', building if necessary."
    imageFile = latexImgFile(deck, latex)
    ok = True
    if build and (not imageFile or not os.path.exists(imageFile)):
        (ok, imageFile) = buildImg(deck, latex)
    if not ok:
        return (False, imageFile)
    return (True, imageFile)

def imgLink(deck, latex, build=True):
    "Parse LATEX and return a HTML image representing the output."
    munged = mungeLatex(deck, latex)
    (ok, img) = imageForLatex(deck, munged, build)
    if ok:
        return '<img src="%s" alt="%s">' % (img, latex)
    else:
        return img

def formatQA(html, type, cid, mid, fact, tags, cm, deck):
    return renderLatex(deck, html)

# setup q/a filter
addHook("formatQA", formatQA)
Exemple #3
0
        os.chdir(oldcwd)


def imageForLatex(deck, latex, build=True):
    "Return an image that represents 'latex', building if necessary."
    imageFile = latexImgFile(deck, latex)
    ok = True
    if build and (not imageFile or not os.path.exists(imageFile)):
        (ok, imageFile) = buildImg(deck, latex)
    if not ok:
        return (False, imageFile)
    return (True, imageFile)


def imgLink(deck, latex, build=True):
    "Parse LATEX and return a HTML image representing the output."
    munged = mungeLatex(deck, latex)
    (ok, img) = imageForLatex(deck, munged, build)
    if ok:
        return '<img src="%s" alt="%s">' % (img, latex)
    else:
        return img


def formatQA(html, type, cid, mid, fact, tags, cm, deck):
    return renderLatex(deck, html)


# setup q/a filter
addHook("formatQA", formatQA)
Exemple #4
0
        mplayerManager.daemon = True
        mplayerManager.start()
        mplayerReader = MplayerReader()
        mplayerReader.daemon = True
        mplayerReader.start()

def stopMplayer():
    if not mplayerManager:
        return
    mplayerManager.kill()

def onExit():
    if tmpdir:
        shutil.rmtree(tmpdir)

addHook("deckClosed", stopMplayer)
atexit.register(onExit)

# PyAudio recording
##########################################################################

try:
    import pyaudio
    import wave

    PYAU_FORMAT = pyaudio.paInt16
    PYAU_CHANNELS = 1
    PYAU_RATE = 44100
    PYAU_INPUT_INDEX = None
except:
    pass