From b91869c27dd13cb88c34464b91073d4e68e1a2a8 Mon Sep 17 00:00:00 2001 From: boyska Date: Mon, 28 Nov 2016 09:51:40 +0100 Subject: [PATCH] change separator for script audiogen refs #31 --- larigira/audioform_script.py | 9 ++++++--- larigira/audiogen_script.py | 10 +++++++--- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/larigira/audioform_script.py b/larigira/audioform_script.py index 2ab3366..d6e5782 100644 --- a/larigira/audioform_script.py +++ b/larigira/audioform_script.py @@ -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(';') } diff --git a/larigira/audiogen_script.py b/larigira/audiogen_script.py index 7b5a72e..0e81030 100644 --- a/larigira/audiogen_script.py +++ b/larigira/audiogen_script.py @@ -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.'