Hi Marc,

On 11/4/11 2:09 PM, J. Marc Edwards wrote:
I need a little help in integrating my Jython/Python code into the Python actor.

When I double-click on the Python actor in the PythonDialogExample, a window with the Python code appears. I can of course edit the code from within this window. However, I want to perform my code development and editing from within my Eclipse environment from my Kepler development build.
I don't know that much about Python, but I believe that you could use the Python import facility to find imports.
I just added text to the Kepler Jython page about this, see:
https://kepler-project.org/developers/reference/python-and-kepler#how-jython-finds-imports

Note that I found a few other references on the web, included what appears to be people who are using the full version of Python (not Jython) with Kepler.
When I "open the actor", the beginning of the file has some Javadoc as well as what appear to be some unmatched XML elements (<p>), along with some matching XML element tags (</pre>) (does this correspond to some pre-fire method?).
When you open the actor, you are seeing the Java code that implements the PythonActor. The <p> tags are html tags used in the javadoc comments of the Java file. All of the instances of the PythonActor share the same Java code, but may have different Python code.
After this all of the Java code for the actor follows with the standard initialize(), stop(), stopFire(), preinitialize(), terminate(), etc, methods.

I do see in the Java code where there is a PythonScript method that accepts a CompositeEntity where a script template is provided where I am supposing a long Python string in the script.setExpression is defined.

However, what I would like to do is simply include my Jython module within my Kepler build and debug my Jython code in connection with my overall workflow.

Can someone tell me how to go about achieving this objective?
It looks like Jython uses sys.path to find imports. I included a Ptolemy II model that opens in the devel version of Kepler that lists the contents of sys.path. For further information about sys.path, see

http://jythonpodcast.hostjava.net/jythonbook/en/1.0/ModulesPackages.html

_Christopher

Thanks, Marc
--

J. Marc Edwards
Lead Architect - Semiconductor Design Portals
Nimbis Services, Inc.
Skype: (919) 747-3775
Cell:  (919) 345-1021
Fax:   (919) 882-8602
marc.edwa...@nimbisservices.com
www.nimbisservices.com



_______________________________________________
Kepler-users mailing list
Kepler-users@kepler-project.org
http://lists.nceas.ucsb.edu/kepler/mailman/listinfo/kepler-users

--
Christopher Brooks, PMP                       University of California
CHESS Executive Director                      US Mail: 337 Cory Hall
Programmer/Analyst CHESS/Ptolemy/Trust        Berkeley, CA 94720-1774
ph: 510.643.9841                                (Office: 545Q Cory)
home: (F-Tu) 707.665.0131 cell: 707.332.0670

<?xml version="1.0" standalone="no"?>
<!DOCTYPE entity PUBLIC "-//UC Berkeley//DTD MoML 1//EN"
    "http://ptolemy.eecs.berkeley.edu/xml/dtd/MoML_1.dtd";>
<entity name="PythonSysPath" class="ptolemy.actor.TypedCompositeActor">
    <property name="_createdBy" class="ptolemy.kernel.attributes.VersionAttribute" value="8.1.devel">
    </property>
    <property name="_windowProperties" class="ptolemy.actor.gui.WindowPropertiesAttribute" value="{bounds={171, 30, 813, 510}, maximized=false}">
    </property>
    <property name="_vergilSize" class="ptolemy.actor.gui.SizeAttribute" value="[600, 400]">
    </property>
    <property name="_vergilZoomFactor" class="ptolemy.data.expr.ExpertParameter" value="1.0">
    </property>
    <property name="_vergilCenter" class="ptolemy.data.expr.ExpertParameter" value="{300.0, 200.0}">
    </property>
    <property name="SDF Director" class="ptolemy.domains.sdf.kernel.SDFDirector">
        <property name="iterations" class="ptolemy.data.expr.Parameter" value="1">
        </property>
        <property name="allowRateChanges" class="ptolemy.data.expr.Parameter" value="false">
        </property>
        <property name="_location" class="ptolemy.kernel.util.Location" value="{115, 50}">
        </property>
    </property>
    <property name="Annotation" class="ptolemy.vergil.kernel.attributes.TextAttribute">
        <property name="text" class="ptolemy.kernel.util.StringAttribute" value="Display the contents of the Python sys.path variable">
        </property>
        <property name="_location" class="ptolemy.kernel.util.Location" value="[65.0, 85.0]">
        </property>
    </property>
    <entity name="PythonActor" class="ptolemy.actor.lib.python.PythonScript">
        <property name="script" class="ptolemy.kernel.util.StringAttribute" value="import sys.path&#10;&#10;import ptolemy.data.type.BaseType&#10;import ptolemy.data.StringToken&#10;&#10;class Main :&#10;  &quot;Report the components of Jython's syspath&quot;&#10;  def preinitialize(self):&#10;    self.output.setTypeEquals(ptolemy.data.type.BaseType.STRING)&#10;  def prefire(self):&#10;    return self.input.hasToken(0)&#10;  def fire(self) :&#10;    y=self.input.get(0) # retrieve and discard the trigger&#10;    result=&quot;&quot;&#10;    sp=sys.path&#10;    for i in range(len(sp)) :&#10;      if (len(result) &gt; 0):&#10;          result+=&quot;\n&quot;&#10;      result+=sp[i]&#10;    self.output.broadcast(ptolemy.data.StringToken(result))&#10;    return&#10;&#10;">
            <property name="style" class="ptolemy.actor.gui.style.TextStyle">
            </property>
        </property>
        <property name="_tableauFactory" class="ptolemy.vergil.toolbox.TextEditorTableauFactory">
            <property name="attributeName" class="ptolemy.kernel.util.StringAttribute" value="script">
            </property>
        </property>
        <property name="_location" class="ptolemy.kernel.util.Location" value="195.0, 220.0">
        </property>
        <port name="input" class="ptolemy.actor.TypedIOPort">
            <property name="input"/>
        </port>
        <port name="output" class="ptolemy.actor.TypedIOPort">
            <property name="output"/>
        </port>
    </entity>
    <entity name="Const" class="ptolemy.actor.lib.Const">
        <property name="value" class="ptolemy.data.expr.Parameter" value="true">
        </property>
        <doc>Create a constant sequence.</doc>
        <property name="_icon" class="ptolemy.vergil.icon.BoxedValueIcon">
            <property name="attributeName" class="ptolemy.kernel.util.StringAttribute" value="value">
            </property>
            <property name="displayWidth" class="ptolemy.data.expr.Parameter" value="60">
            </property>
        </property>
        <property name="_location" class="ptolemy.kernel.util.Location" value="[100.0, 220.0]">
        </property>
    </entity>
    <entity name="Display" class="ptolemy.actor.lib.gui.Display">
        <property name="_windowProperties" class="ptolemy.actor.gui.WindowPropertiesAttribute" value="{bounds={598, 421, 484, 208}, maximized=false}">
        </property>
        <property name="_paneSize" class="ptolemy.actor.gui.SizeAttribute">
        </property>
        <property name="_location" class="ptolemy.kernel.util.Location" value="[345.0, 220.0]">
        </property>
    </entity>
    <relation name="relation" class="ptolemy.actor.TypedIORelation">
    </relation>
    <relation name="relation2" class="ptolemy.actor.TypedIORelation">
    </relation>
    <link port="PythonActor.input" relation="relation"/>
    <link port="PythonActor.output" relation="relation2"/>
    <link port="Const.output" relation="relation"/>
    <link port="Display.input" relation="relation2"/>
</entity>
_______________________________________________
Kepler-users mailing list
Kepler-users@kepler-project.org
http://lists.nceas.ucsb.edu/kepler/mailman/listinfo/kepler-users

Reply via email to