Run Sample Python Script

The steps in this topic demonstrate the procedure of running a sample Python script from Jython console, that is running the script that you might have written for exporting trace data or collecting trace data.

  1. Copy the Python scripts, which you want to execute, at <CW installation directory>\eclipse\plugins\com.freescale.sa.mcu.scripting_*\remote\scripting_sa_mcu.
  2. Select Window > Show View > Other > Debug > Remote Launch to open the Remote Launch view.
  3. Click the Enable Remote Launch button displayed on the top right of the view to enable remote launching.

    The color of the button changes to red.

  4. Select Window > Show View > Other > Debug > Jython Consoles to open the Jython Consoles view.
  5. Open the View menu in the Jython Consoles view, and select the New Interpreter option.
    Figure 1. Select New Interpreter Option in Jython Consoles View
    Select New Interpreter Option in Jython Consoles View

    The Input Name dialog box appears.

  6. Specify a name for the new interpreter and click OK.
  7. In the Jython console command prompt (">>>"), input code in Python syntax. You may access any classes in your test scripts, foe example, test_file.py, by inputting the following commands in the Jython command prompt:
    >>> from scripting_sa_mcu import test_file
    
    
    >>> test = test_file.test_class()
    
    
    >>> test.a_function(args)
    
    Note: The advantage of using Jython is that besides Python modules, it can also access Java modules in the similar manner.

This is how you run a sample Python script from Jython console.