Sequencer RUN PYTHON CODE - to quote or not to quote, etc, etc
Posted: Wed Jul 24, 2024 6:32 am
SharpCap Version 4.1.12395
If I type the following text into a file with a text editor and feed it to SharpCap, MDLTargetingAssistant.SavePostAdjusted_PlateSolveCoodinates() will be called as one would expect:
SEQUENCE
RUN PYTHON CODE "MDLTargetingAssistant.SavePostAdjusted_PlateSolveCoodinates( )"
END SEQUENCE
This will work the equally well:
SEQUENCE
RUN PYTHON CODE "result = MDLTargetingAssistant.SavePostAdjusted_PlateSolveCoodinates()"
END SEQUENCE'
And so will this:
SEQUENCE
RUN PYTHON CODE MDLTargetingAssistant.SavePostAdjusted_PlateSolveCoodinates()
END SEQUENCE'
BUT, this won't work:
SEQUENCE
RUN PYTHON CODE "MDLTargetingAssistant.SavePostAdjusted_PlateSolveCoodinates()"
END SEQUENCE
The sequencer does not execute the python code, with no error reported, as if the line was a no-op.
The difference, is that if a line of python code has no spaces in it, but is enclosed by double quotes, it is ignored. Just adding a space within the Python text will work, or removing the enclosing quotes will make it work. But you can only omit the quotes if the Python code contains no spaces.
I frequently edit my sequences in a text editor, so forgetting to put a space between the parentheses in a Python function call is easy. I try to remember to do it after I discovered the problem a few weeks ago, but sometimes forget. Just got bit by this one again tonight, so thought I should report it. Seems the Sequencer parser should be happy to have quotes whether there is a space or not, and certainly not just silently skip running your python code!
I believe there is a similar parsing issue involving calling subroutines that have spaces in their names. The sequencer only wants to see a subroutine name enclosed in quotes if the name contains at least one space. I think I saw this with GOSUB and/or DEF SUB but not with ON ERROR.
If I type the following text into a file with a text editor and feed it to SharpCap, MDLTargetingAssistant.SavePostAdjusted_PlateSolveCoodinates() will be called as one would expect:
SEQUENCE
RUN PYTHON CODE "MDLTargetingAssistant.SavePostAdjusted_PlateSolveCoodinates( )"
END SEQUENCE
This will work the equally well:
SEQUENCE
RUN PYTHON CODE "result = MDLTargetingAssistant.SavePostAdjusted_PlateSolveCoodinates()"
END SEQUENCE'
And so will this:
SEQUENCE
RUN PYTHON CODE MDLTargetingAssistant.SavePostAdjusted_PlateSolveCoodinates()
END SEQUENCE'
BUT, this won't work:
SEQUENCE
RUN PYTHON CODE "MDLTargetingAssistant.SavePostAdjusted_PlateSolveCoodinates()"
END SEQUENCE
The sequencer does not execute the python code, with no error reported, as if the line was a no-op.
The difference, is that if a line of python code has no spaces in it, but is enclosed by double quotes, it is ignored. Just adding a space within the Python text will work, or removing the enclosing quotes will make it work. But you can only omit the quotes if the Python code contains no spaces.
I frequently edit my sequences in a text editor, so forgetting to put a space between the parentheses in a Python function call is easy. I try to remember to do it after I discovered the problem a few weeks ago, but sometimes forget. Just got bit by this one again tonight, so thought I should report it. Seems the Sequencer parser should be happy to have quotes whether there is a space or not, and certainly not just silently skip running your python code!
I believe there is a similar parsing issue involving calling subroutines that have spaces in their names. The sequencer only wants to see a subroutine name enclosed in quotes if the name contains at least one space. I think I saw this with GOSUB and/or DEF SUB but not with ON ERROR.