[fixed] Script working from command line but not in Synfig... what difference?

Hello.

My script to generate kinetic typography is running fine from the command line but not when I call it from the Synfig Scripts Menu. Any idea where that may come frome?

I guess it’s a difference in python version or import path… but don’t know how to check this, nor how to fix.

The error I get is

SyntaxError: invalid syntax File "import-audacity-labels-keyframes/pystache/parser.py", line 15 NON_BLANK_RE = re.compile(ur'^(.)', re.M)

more info: github.com/berteh/import-audaci … s/issues/3
source code: github.com/berteh/import-audaci … keyframes/

to reproduce:
unzip github.com/berteh/import-audaci … master.zip into your Synfig script directory (/opt/synfig/share/synfig/plugins/ in ubuntu)
open import-audacity-labels-keyframes/test/keyframe-import-test.sif with Scribus
run Scripts > Import Audacity Labels as Keyframes

And instead of having a set of animated text objects animated for you from the timing of the “labels.txt” file… you get an error :frowning:

To get a glimpse at the expected effect simply run the script from the command line instead:

cd /opt/synfig/share/synfig/plugins/import-audacity-labels-keyframes ./import-audacity-labels-keyframes.py test/keyframe-import-test.sif test/labels2.txt ~/generated.sif synfigstudio ~/generated.sif &

Any idea how I can check the import path from within Synfig? (by the way: any use of print() would generate a SyntaxError too…maybe it’s related)
Have a nice day!
Berteh.

Hi berteh,

if found out there is a problem with unicode :slight_smile:

Since we are using Python 3 with unicode by default, you shouldn’t use ur’^(.)’ but simply r’^(.)’ (2 occurences in pystache/parser.py). (source)

After this, there other problems in common.py about “unicode”, renderer.py with “basestring”…

But this should be a good start :smiley:

P.S.: Under 14.04, python = python2 (2.7) but Synfig takes python3 (3.4), that’s surely why you don’t have troubles from command line :wink:

Thanks Bob,
Porting the script code to Python 3 was indeed enough to make it all work as expected, and using 2to3 made that quite easy.
B.