本文整理汇总了Python中mod.session.SESSION.save_pedalboard方法的典型用法代码示例。如果您正苦于以下问题:Python SESSION.save_pedalboard方法的具体用法?Python SESSION.save_pedalboard怎么用?Python SESSION.save_pedalboard使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mod.session.SESSION
的用法示例。
在下文中一共展示了SESSION.save_pedalboard方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
# 需要导入模块: from mod.session import SESSION [as 别名]
# 或者: from mod.session.SESSION import save_pedalboard [as 别名]
def post(self):
title = self.get_argument('title')
as_new = bool(int(self.get_argument('asNew')))
try:
uid = SESSION.save_pedalboard(title, as_new)
except Pedalboard.ValidationError as e:
self.write(json.dumps({ 'ok': False, 'error': str(e) }))
self.finish()
raise StopIteration
THUMB_GENERATOR.schedule_thumbnail(uid)
self.set_header('Content-Type', 'application/json')
self.write(json.dumps({ 'ok': True, 'uid': uid }, default=json_handler))
self.finish()
示例2: post
# 需要导入模块: from mod.session import SESSION [as 别名]
# 或者: from mod.session.SESSION import save_pedalboard [as 别名]
def post(self):
title = self.get_argument('title')
asNew = bool(int(self.get_argument('asNew')))
titlesym = symbolify(title)
# Save over existing bundlepath
if SESSION.bundlepath and os.path.exists(SESSION.bundlepath) and os.path.isdir(SESSION.bundlepath) and not asNew:
bundlepath = SESSION.bundlepath
# Save new
else:
lv2path = os.path.expanduser("~/.lv2/") # FIXME: cross-platform
trypath = os.path.join(lv2path, "%s.pedalboard" % titlesym)
# if trypath already exists, generate a random bundlepath based on title
if os.path.exists(trypath):
from random import randint
while True:
trypath = os.path.join(lv2path, "%s-%i.pedalboard" % (titlesym, randint(1,99999)))
if os.path.exists(trypath):
continue
bundlepath = trypath
break
# trypath doesn't exist yet, use it
else:
bundlepath = trypath
# just in case..
if not os.path.exists(lv2path):
os.mkdir(lv2path)
os.mkdir(bundlepath)
# callback for when ingen is done doing its business
def callback(ok):
if not ok:
self.write(json.dumps({ 'ok': False, 'error': "Failed" })) # TODO more descriptive error?
self.finish()
return
# Create a custom manifest.ttl, not created by ingen because we want *.pedalboard extension
with open(os.path.join(bundlepath, "manifest.ttl"), 'w') as fd:
fd.write('''\
@prefix ingen: <http://drobilla.net/ns/ingen#> .
@prefix lv2: <http://lv2plug.in/ns/lv2core#> .
@prefix pedal: <http://portalmod.com/ns/modpedal#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
<%s.ttl>
lv2:prototype ingen:GraphPrototype ;
a lv2:Plugin ,
ingen:Graph ,
pedal:Pedalboard ;
rdfs:seeAlso <%s.ttl> .
''' % (titlesym, titlesym))
# All ok!
self.set_header('Content-Type', 'application/json')
self.write(json.dumps({ 'ok': True, 'bundlepath': bundlepath }, default=json_handler))
self.finish()
# Ask ingen to save
SESSION.save_pedalboard(bundlepath, title, callback)