Files
main/multimedia/sound/timidity/comar/service.py
T
2016-02-21 20:20:56 +02:00

54 lines
1.6 KiB
Python
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# -*- coding: utf-8 -*-
serviceType = "local"
serviceDesc = _({"en": "Timidity Virtual MIDI Sequencer for Alsa",
"tr": "Timidity Sanal MIDI Ardışımlayıcı"})
MSG_ERR_TIMDPTCH = _({"en": "Failed to set patchset %s for Timidity.",
"tr": "Yama kümesi %s Timidity'ye atanamadı.",
})
from comar.service import *
import os
@synchronized
def start():
if config.get("USE_ESOUND", "") == "yes":
startDependencies("esound")
# set up sound fonts
patchset = config.get("PATCHSET", "shompatches")
currentlink = "/usr/share/timidity/current"
try:
currentpatch = os.readlink(currentlink)
except:
currentpatch = None
if patchset != currentpatch:
if not os.path.exists("/usr/share/timidity/%s" % patchset) and not os.path.exists(patchset):
fail(MSG_ERR_TIMDPTCH % patchset)
else:
if currentpatch:
os.unlink(currentlink)
os.symlink(patchset, currentlink)
if config.get("TIMIDITY_PCM_NAME", "") != "":
loadEnvironment()
os.environ["TIMIDITY_PCM_NAME"]=config.get("TIMIDITY_PCM_NAME")
startService(command="/usr/bin/timidity",
args="-iA %s" % config.get("TIMIDITY_OPTS", ""),
pidfile="/run/timidity.pid",
makepid=True,
detach=True,
donotify=True)
@synchronized
def stop():
stopService(pidfile="/run/timidity.pid",
donotify=True)
def status():
return isServiceRunning("/run/timidity.pid")