Jump to content

Embedding Python In Otls


doc

Recommended Posts

I'm trying to embed my python scripts inside my otl and I'm having a bit of

trouble.

I made a section in the "edit contents" editor called fat.py

here's the code for that section:

#!/usr/local/bin/python

print("yes this works!\n")

my otl has a button with the following callback:

    unix opdef:/Object/foo?fat.py

The problem is whenever I hit my button I get the following error in my shell:

opdef:/Object/foo?fat.py: No match.

anybody know how to get around this?

thanks

Luca

Link to comment
Share on other sites

I don't think the 'unix' command can execute scripts embedded within oplib, can it...? IF my memory is correct, I remember running into this issue more than a year ago and George told me you'd have to have the script sits outside the oplib...

I could wrong tho... I'd be interested in knowing about it. George? Jason?

-Alex

Link to comment
Share on other sites

thanks for the input guys. I've just confirmed with sesi, I'd have to write the python

out to a temp file. yuck.

Luca

28547[/snapback]

Does Python allow to use a single line programs like Perl? If so you can write a Python code inside expression function in this manner

string SomeFunc(string SomeParam) {
  ...
  code += "foreach my $text (@text) { ";
  code += "chomp($text); ";
  code += "$text =~ s/\\t/$spacestr/g; ";
  ...

  return system("perl -e \"" + code  + "\"");
}

That function then can be embed into OTL. Terrible but there is no need to use external temporary files :)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...