change separator for script audiogen

refs #31
This commit is contained in:
boyska 2016-11-28 09:51:40 +01:00
parent 0902331ee4
commit b91869c27d
No known key found for this signature in database
GPG key ID: 7395DCAE58289CA9
2 changed files with 13 additions and 6 deletions

View file

@ -8,7 +8,7 @@ class ScriptAudioForm(Form):
name = StringField('Name', validators=[validators.required()],
description='filename (NOT path) of the script')
args = StringField('Arguments',
description='arguments, separated by spaces')
description='arguments, separated by ";"')
submit = SubmitField('Submit')
def populate_from_audiospec(self, audiospec):
@ -17,7 +17,10 @@ class ScriptAudioForm(Form):
if 'name' in audiospec:
self.name.data = audiospec['name']
if 'args' in audiospec:
self.args.data = audiospec['args']
if type(audiospec['args']) is str: # legacy compatibility
self.args.data = audiospec['args'].replace(' ', ';')
else:
self.args.data = ';'.join(audiospec['args'])
def validate_name(form, field):
if '/' in field.data:
@ -30,5 +33,5 @@ def scriptaudio_receive(form):
'kind': 'script',
'nick': form.nick.data,
'name': form.name.data,
'args': form.args.data
'args': form.args.data.split(';')
}

View file

@ -27,11 +27,13 @@ def generate(spec):
'''
Recognized arguments (fields in spec):
- name [mandatory] script name
- args [default=empty] arguments, space-separated
- args [default=empty] arguments, colon-separated
'''
conf = get_conf()
spec.setdefault('args', '')
args = spec['args'].split()
if type(spec['args']) is str:
args = spec['args'].split(';')
args = list(spec['args'])
for attr in ('name', ):
if attr not in spec:
raise ValueError("Malformed audiospec: missing '%s'" % attr)
@ -44,6 +46,7 @@ def generate(spec):
raise ValueError("Script %s not found", spec['name'])
if not os.access(scriptpath, os.R_OK | os.X_OK):
raise ValueError("Insufficient privileges for script %s" % scriptpath)
if os.stat(scriptpath).st_uid != os.getuid():
raise ValueError("Script %s owned by %d, should be owned by %d"
% (spec['name'], os.stat(scriptpath).st_uid,
@ -70,4 +73,5 @@ def generate(spec):
out = [p for p in out.split('\n') if p]
logging.debug('Script %s produced %d files' % (spec['name'], len(out)))
return out
generate.description = 'Generate audio through an external script. Experts only.'
generate.description = 'Generate audio through an external script. ' \
'Experts only.'