Documentation/Maemo Eclipse Tutorial/Using PluThon

m (1 revision)
(wikify slightly, reformat images, use <code>, links)
 
(2 intermediate revisions not shown)
Line 1: Line 1:
-
 
-
= Using PluThon =
 
-
 
PluThon supports only Python projects. This chapter briefly shows hot to create Python projects and applications and run, test and debug Python applications with Maemo device.
PluThon supports only Python projects. This chapter briefly shows hot to create Python projects and applications and run, test and debug Python applications with Maemo device.
Line 8: Line 5:
Ensure that you can connect to the Maemo device from the host PC (that PC Connectivity has been properly installed and configured) before creating your first project with PluThon.
Ensure that you can connect to the Maemo device from the host PC (that PC Connectivity has been properly installed and configured) before creating your first project with PluThon.
-
= Creating PluThon Python projects =
+
== Creating PluThon Python projects ==
-
 
+
-
Create new PluThon project from '''File menu &gt; New &gt; PluThon Project''', figure [[#fig:pluthon_usage_project_01_new|7.1]].
+
-
 
+
-
 
+
-
 
+
-
{| summary="New Project Menu"
+
-
|+ align="BOTTOM" |'''Figure 7.1:''' New Project Menu
+
-
|-
+
-
|
+
-
[[Image:project-01-new.png|Image project-01-new]]
+
-
|}
+
 +
Create new PluThon project from '''File menu &gt; New &gt; PluThon Project''', figure [[#figure-pluthon_usage_project_01_new|7.1]].
 +
<div id="figure-pluthon_usage_project_01_new">
 +
[[Image:project-01-new.png|frame|center|alt=Screenshot of new project menu|Figure 7.1: New Project Menu]]
 +
</div>
-
== PluThon Project Templates ==
+
=== PluThon Project Templates ===
Templates define the basic structure of the project. Most of the templates are examples, but you can use these examples also as a base structure for your project.
Templates define the basic structure of the project. Most of the templates are examples, but you can use these examples also as a base structure for your project.
-
Select any template under '''Examples'''. Some of the templates are only for <span><font face="monospace">Diablo</font></span> device (N800 or N810) and others for <span><font face="monospace">Fremantle</font></span> (N900), figure [[#fig:pluthon_usage_project_03_template|7.2]].
+
Select any template under '''Examples'''. Some of the templates are only for [[Open development/Maemo roadmap/Diablo|Diablo]] devices ([[Nokia N800|N800]] or [[Nokia N810|N810]]) and others for [[Open development/Maemo roadmap/Fremantle|Fremantle]] ([[Nokia N900|N900]]), figure [[#figure-pluthon_usage_project_03_template|7.2]].
 +
<div id="figure-pluthon_usage_project_03_template">
 +
[[Image:project-03-template.png|frame|center|alt=Screenshot of PluThon project template|Figure 7.2: PluThon Project Template]]
 +
</div>
-
 
+
=== PluThon Project Target ===
-
{| summary="PluThon Project Template"
+
-
|+ align="BOTTOM" |'''Figure 7.2:''' PluThon Project Template
+
-
|-
+
-
|
+
-
[[Image:project-03-template.png|Image project-03-template]]
+
-
|}
+
-
 
+
-
 
+
-
 
+
-
== PluThon Project Target ==
+
Select your connection to the device from the list. Default IP addresses are the same as PC Connectivity uses as default. The connection must be enabled from device PC Connectivity. See the PC Connectivity documentation for more information.
Select your connection to the device from the list. Default IP addresses are the same as PC Connectivity uses as default. The connection must be enabled from device PC Connectivity. See the PC Connectivity documentation for more information.
-
If you only use SSH connection to your device, or you have other IP values in your PC Connectivity properties, you can configure the connection here by right-clicking connection and selecting '''configure'''. Then you need to set '''Host name''' and '''Default User ID''', figures [[#fig:pluthon_usage_project_04_target|7.3]] and [[#fig:pluthon_usage_configure_connection|7.4]].
+
If you only use [[SSH]] connection to your device, or you have other IP values in your PC Connectivity properties, you can configure the connection here by right-clicking connection and selecting '''configure'''. Then you need to set '''Host name''' and '''Default User ID''', figures [[#figure-pluthon_usage_project_04_target|7.3]] and [[#figure-pluthon_usage_configure_connection|7.4]].
-
 
+
-
 
+
-
 
+
-
{| summary="PluThon Project Target"
+
-
|+ align="BOTTOM" |'''Figure 7.3:''' PluThon Project Target
+
-
|-
+
-
|
+
-
[[Image:project-04-target.png|Image project-04-target]]
+
-
|}
+
-
 
+
-
 
+
-
 
+
-
 
+
-
 
+
-
{| summary="PluThon Project Target"
+
-
|+ align="BOTTOM" |'''Figure 7.4:''' PluThon Project Target
+
-
|-
+
-
|
+
-
[[Image:configure-connection.png|Image configure-connection]]
+
-
|}
+
 +
<div id="figure-pluthon_usage_project_04_target">
 +
[[Image:project-04-target.png|frame|center|alt=Screenshot of PluThon project target|Figure 7.3: PluThon Project Target]]
 +
</div>
 +
<div id="figure-pluthon_usage_configure_connection">
 +
[[Image:configure-connection.png|frame|center|alt=Screenshot of PluThon project target|Figure 7.4: PluThon Project Target]]
 +
</div>
You can configure connections afterwards from '''Window &gt; Preferences &gt; Maemo &gt; Installed Targets''' or use Remote Systems view '''Window &gt; Show View &gt; Other &gt; Remote Systems &gt; Remote Systems'''.
You can configure connections afterwards from '''Window &gt; Preferences &gt; Maemo &gt; Installed Targets''' or use Remote Systems view '''Window &gt; Show View &gt; Other &gt; Remote Systems &gt; Remote Systems'''.
-
== PluThon Project Metadata ==
+
=== PluThon Project Metadata ===
-
'''Basic Settings''' page defines some basic variables used by the selected template. You can insert requested information into fields or leave default values, figure [[#fig:pluthon_usage_project_05_metadata|7.5]].
+
'''Basic Settings''' page defines some basic variables used by the selected template. You can insert requested information into fields or leave default values, figure [[#figure-pluthon_usage_project_05_metadata|7.5]].
 +
<div id="figure-pluthon_usage_project_05_metadata">
 +
[[Image:project-05-metadata.png|frame|center|alt=Screenshot of PluThon project configuration|Figure 7.5: PluThon Project Configuration]]
 +
</div>
-
 
+
=== PluThon Project Interpreter Configuration ===
-
{| summary="PluThon Project Configuration"
+
-
|+ align="BOTTOM" |'''Figure 7.5:''' PluThon Project Configuration
+
-
|-
+
-
|
+
-
[[Image:project-05-metadata.png|Image project-05-metadata]]
+
-
|}
+
-
 
+
-
 
+
-
 
+
-
== PluThon Project Interpreter Configuration ==
+
Python configuration is done on the last page. If existing Python configuration is not found, a wizard suggests creating a new configuration.
Python configuration is done on the last page. If existing Python configuration is not found, a wizard suggests creating a new configuration.
-
Leave all values as default and press the '''Finish''' button to create project, figure [[#fig:pluthon_usage_project_06_configuration|7.6]].
+
Leave all values as default and press the '''Finish''' button to create project, figure [[#figure-pluthon_usage_project_06_configuration|7.6]].
 +
<div id="figure-pluthon_usage_project_06_configuration">
 +
[[Image:project-06-configuration.png|frame|center|alt=Screenshot of PluThon project configuration|Figure 7.6: PluThon Project Configuration]]
 +
</div>
 +
If there were no previous configurations for your project, ESbox will ask you to create new configuration. Select '''Yes''' to create one, figure [[#figure-pluthon_usage_project_07_interpreter_dialog|7.7]].
-
{| summary="PluThon Project Configuration"
+
<div id="figure-pluthon_usage_project_07_interpreter_dialo">
-
|+ align="BOTTOM" |'''Figure 7.6:''' PluThon Project Configuration
+
[[Image:project-07-interpreter-dialog.png|frame|center|alt=Screenshot of Python interpreter dialog|Figure 7.7: Python Interpreter Dialog]]
-
|-
+
</div>
-
|
+
-
[[Image:project-06-configuration.png|Image project-06-configuration]]
+
-
|}
+
 +
For the Python interpreter configuration you can select all Python paths and confirm the addition with '''OK''' button, figure [[#figure-pluthon_usage_project_08_interpreter_paths|7.8]].
 +
<div id="figure-pluthon_usage_project_08_interpreter_paths">
 +
[[Image:project-08-interpreter-paths.png|frame|center|alt=Screenshot of Python interpreter path configuration|Figure 7.8: Python Interpreter Path Configuration]]
 +
</div>
-
If there were no previous configurations for your project, ESbox will ask you to create new configuration. Select '''Yes''' to create one, figure [[#fig:pluthon_usage_project_07_interpreter_dialog|7.7]].
+
=== Validating PluThon Project Packages on Maemo Device ===
 +
PluThon suggests package validation when a new project is created. Answer '''Yes''' to package validations, figure [[#figure-pluthon_usage_project_09_validate_dialog|7.9]].
 +
<div id="figure-pluthon_usage_project_09_validate_dialog">
 +
[[Image:project-09-validate-dialog.png|frame|center|alt=Screenshot of package validation dialog|Figure 7.9: Validate Packages Dialog]]
 +
</div>
-
{| summary="Python Interpreter Dialog"
+
PluThon installs the required dependencies into the Maemo device after you press '''Finish''' button on Package Validation Wizard, figure [[#figure-pluthon_usage_project_10_validate_wizard|7.10]].
-
|+ align="BOTTOM" |'''Figure 7.7:''' Python Interpreter Dialog
+
-
|-
+
-
|
+
-
[[Image:project-07-interpreter-dialog.png|Image project-07-interpreter-dialog]]
+
-
|}
+
-
 
+
-
 
+
-
 
+
-
For the Python interpreter configuration you can select all Python paths and confirm the addition with '''OK''' button, figure [[#fig:pluthon_usage_project_08_interpreter_paths|7.8]].
+
-
 
+
-
 
+
-
 
+
-
{| summary="Python Interpreter Path Configuration"
+
-
|+ align="BOTTOM" |'''Figure 7.8:''' Python Interpreter Path Configuration
+
-
|-
+
-
|
+
-
[[Image:project-08-interpreter-paths.png|Image project-08-interpreter-paths]]
+
-
|}
+
-
 
+
-
 
+
-
 
+
-
== Validating PluThon Project Packages on Maemo Device ==
+
-
 
+
-
PluThon suggests package validation when a new project is created. Answer '''Yes''' to package validations, figure [[#fig:pluthon_usage_project_09_validate_dialog|7.9]].
+
-
 
+
-
 
+
-
 
+
-
{| summary="Validate Packages Dialog"
+
-
|+ align="BOTTOM" |'''Figure 7.9:''' Validate Packages Dialog
+
-
|-
+
-
|
+
-
[[Image:project-09-validate-dialog.png|Image project-09-validate-dialog]]
+
-
|}
+
-
 
+
-
 
+
-
 
+
-
PluThon installs the required dependencies into the Maemo device after you press '''Finnish''' button on Package Validation Wizard, figure [[#fig:pluthon_usage_project_10_validate_wizard|7.10]].
+
-
 
+
-
 
+
-
 
+
-
{| summary="Validate Packages Wizard"
+
-
|+ align="BOTTOM" |'''Figure 7.10:''' Validate Packages Wizard
+
-
|-
+
-
|
+
-
[[Image:project-10-validate-wizard.png|Image project-10-validate-wizard]]
+
-
|}
+
-
 
+
 +
<div id="figure-pluthon_usage_project_10_validate_wizard">
 +
[[Image:project-10-validate-wizard.png|frame|center|alt=Screenshot of package validation wizard|'''Figure 7.10:''' Validate Packages Wizard]]
 +
</div>
Accept any packages PluThon suggests to install and close validation after the packages have been installed.
Accept any packages PluThon suggests to install and close validation after the packages have been installed.
Line 162: Line 89:
During a validation project, dependencies are scanned from projects using Python package imports from source files.
During a validation project, dependencies are scanned from projects using Python package imports from source files.
-
= Running Python Application on Maemo Device =
+
== Running Python Application on Maemo Device ==
In order to run applications on Maemo devices, the Maemo PC Connectivity package must be installed on the device and the Host PC Connectivity package for the host PC. See the PluThon installation chapters for more information.
In order to run applications on Maemo devices, the Maemo PC Connectivity package must be installed on the device and the Host PC Connectivity package for the host PC. See the PluThon installation chapters for more information.
-
You can run Python applications with PluThon by right-clicking a project and choosing '''Run As &gt; PluThon Application''', figure [[#fig:pluthon_usage_run_01_run_as|7.11]].
+
You can run Python applications with PluThon by right-clicking a project and choosing '''Run As &gt; PluThon Application''', figure [[#figure-pluthon_usage_run_01_run_as|7.11]].
 +
<div id="figure-pluthon_usage_run_01_run_as">
 +
[[Image:run-01-run-as.png|frame|center|alt=Screenshot of running PluThon application|Figure 7.11: Run as PluThon Application]]
 +
</div>
 +
Next, select the Python file to be run (do not select setup.py because it is used only for Debian package creation), figure [[#figure-pluthon_usage_run_02_script|7.12]].
-
{| summary="Run as PluThon Application"
+
<div id="figure-pluthon_usage_run_02_script">
-
|+ align="BOTTOM" |'''Figure 7.11:''' Run as PluThon Application
+
[[Image:run-02-script.png|frame|center|alt=Screenshot of executable selection|Figure 7.12: Select Executable]]
-
|-
+
</div>
-
|
+
-
[[Image:run-01-run-as.png|Image run-01-run-as]]
+
-
|}
+
-
 
+
-
 
+
-
 
+
-
Next, select the Python file to be run (do not select setup.py because it is used only for Debian package creation), figure [[#fig:pluthon_usage_run_02_script|7.12]].
+
-
 
+
-
 
+
-
 
+
-
{| summary="Select Executable"
+
-
|+ align="BOTTOM" |'''Figure 7.12:''' Select Executable
+
-
|-
+
-
|
+
-
[[Image:run-02-script.png|Image run-02-script]]
+
-
|}
+
-
 
+
-
 
+
-
 
+
-
Then select the download method as Copy Programs (SSH) (as SBRSH requires configuration), figure [[#fig:pluthon_usage_run_03_download|7.13]].
+
-
 
+
-
 
+
-
 
+
-
{| summary="Select Download Method"
+
-
|+ align="BOTTOM" |'''Figure 7.13:''' Select Download Method
+
-
|-
+
-
|
+
-
[[Image:run-03-download.png|Image run-03-download]]
+
-
|}
+
 +
Then select the download method as Copy Programs (SSH) (as SBRSH requires configuration), figure [[#figure-pluthon_usage_run_03_download|7.13]].
 +
<div id="figure-pluthon_usage_run_03_download">
 +
[[Image:run-03-download.png|frame|center|alt=Screenshot of download manual selection|Figure 7.13: Select Download Method]]
 +
</div>
You can now see the program running on the Maemo device.
You can now see the program running on the Maemo device.
Line 209: Line 115:
You can use VNC Viewer to control the Maemo device and your application running on the device. Choose '''Window &gt; Show View &gt; Other &gt; VNC Viewer'''.
You can use VNC Viewer to control the Maemo device and your application running on the device. Choose '''Window &gt; Show View &gt; Other &gt; VNC Viewer'''.
-
{|
+
{{ambox|text=The <code>x11vnc</code> service must be installed on the Maemo device either separately (<code>apt-get install x11vnc</code>) or as part of Maemo PC Connectivity.}}
-
|-
+
-
| [[Image:dialog-information.png]]
+
-
| '''Note:'''  The <span><font face="monospace">x11vnc</font></span> service must be installed on the Maemo device either separately (apt-get install x11vnc) or as part of Maemo PC Connectivity.
+
-
|}
+
-
= Debugging PluThon Application on Maemo Device =
+
== Debugging PluThon Application on Maemo Device ==
-
In order to debug the project, set at least one breakpoint into one of the source files where you want to start debugging. Open the source file and place the breakpoint at some position by right-clicking the left source side panel and choosing '''Add Breakpoint''', figure [[#fig:pluthon_usage_debug_02_add_breakpoint|7.14]].
+
In order to debug the project, set at least one breakpoint into one of the source files where you want to start debugging. Open the source file and place the breakpoint at some position by right-clicking the left source side panel and choosing '''Add Breakpoint''', figure [[#figure-pluthon_usage_debug_02_add_breakpoint|7.14]].
 +
<div id="figure-pluthon_usage_debug_02_add_breakpoint">
 +
[[Image:debug-02-add-breakpoint.png|frame|center|alt=Screenshot of addng a breakpoint|Figure 7.14: Add Breakpoint]]
 +
</div>
 +
Launch your project in debug mode by right-clicking project and choosing '''Debug As &gt; PluThon Application''' and accept changing to debug perspective, figure [[#figure-pluthon_usage_debug_01_menu|7.15]].
-
{| summary="Add Breakpoint"
+
<div id="figure-pluthon_usage_debug_01_menu">
-
|+ align="BOTTOM" |'''Figure 7.14:''' Add Breakpoint
+
[[Image:debug-01-menu.png|frame|center|alt=Screenshot of debugging as a PluThon application|Figure 7.15: Debug as PluThon Application]]
-
|-
+
</div>
-
|
+
-
[[Image:debug-02-add-breakpoint.png|Image debug-02-add-breakpoint]]
+
-
|}
+
 +
From the debug perspective, you can stop and continue execution, step lines, inspect variables, and so on. See Figures [[#figure-pluthon_usage_python_debug_03_perspective|7.16]] and [[#figure-pluthon_usage_debug_04_variables|7.17]].
 +
{{ambox
 +
|text=You can switch back and forth between perspectives from top-right corner.
 +
}}
-
Launch your project in debug mode by right-clicking project and choosing '''Debug As &gt; PluThon Application''' and accept changing to debug perspective, figure [[#fig:pluthon_usage_debug_01_menu|7.15]].
+
<div id=""figure-pluthon_usage_python_debug_03_perspective>
 +
[[Image:debug-03-debug-view.png|frame|center|alt=Screenshot of debug view|Figure 7.16: Debug View]]
 +
</div>
 +
<div id="figure-pluthon_usage_debug_04_variables">
 +
[[Image:debug-04-variables-view.png|frame|center|alt=Screenshot of variables view|Figure 7.17: Variables View]]
 +
</div>
 +
== Debian Packaging PluThon Project ==
-
{| summary="Debug as PluThon Application"
+
=== Generating Setup Script ===
-
|+ align="BOTTOM" |'''Figure 7.15:''' Debug as PluThon Application
+
-
|-
+
-
|
+
-
[[Image:debug-01-menu.png|Image debug-01-menu]]
+
-
|}
+
 +
The setup script (<code>setup.py</code>) is used to create the Debian installation package for Python projects.
 +
In setup script generator you need to define metadata, packages, executables and datafiles. This information is then used to create <code>setup.py</code> script for the project, figure [[#figure-pluthon_usage_debian_01_setup_wizard|7.18]].
-
From the debug perspective, you can stop and continue execution, step lines, inspect variables, and so on. See Figures [[#fig:pluthon_usage_python_debug_03_perspective|7.16]] and [[#fig:pluthon_usage_debug_04_variables|7.17]].
+
<div id="figure-pluthon_usage_debian_01_setup_wizard">
 +
[[Image:debian-01-setup-wizard.png|frame|center|alt=Screenshot of Debian package setup wizard|Figure 7.18: Debian Package Setup Wizard]]
 +
</div>
-
{|
+
PluThon provides an automated wizard for creating Debian installation packages with this script. You can create the script from '''File &gt; New &gt; Other &gt; PyDev &gt; Setup Script''', figure [[#figure-pluthon_usage_debian_02_setup_wizard|7.19]].
-
|-
+
-
| [[Image:dialog-information.png]]
+
-
| '''Note:''' You can switch back and forth between perspectives from top-right corner.
+
-
|}
+
 +
<div id="figure-pluthon_usage_debian_02_setup_wizard">
 +
[[Image:debian-02-setup-project.png|frame|center|alt=Screenshot of Debian package setup project|Figure 7.19: Debian Package Setup Project]]
 +
</div>
 +
For the <code>setup.py</code> script you need to define certain metadata for the installation pacakge, figure [[#figure-pluthon_usage_debian_03_setup_parameters|7.20]].
-
{| summary="Debug View"
+
<div id="figure-pluthon_usage_debian_03_setup_parameters">
-
|+ align="BOTTOM" |'''Figure 7.16:''' Debug View
+
[[Image:debian-03-setup-parameters.png|frame|center|alt=Screenshot of Debian package setup parameters|Figure 7.20: Debian Package Setup Parameters]]
-
|-
+
</div>
-
|
+
-
[[Image:debug-03-debug-view.png|Image debug-03-debug-view]]
+
-
|}
+
 +
Information about packages included in the installation package, figure [[#figure-pluthon_usage_debian_04_setup_package|7.21]].
 +
<div id="figure-pluthon_usage_debian_04_setup_package">
 +
[[Image:debian-04-setup-package.png|frame|center|alt=Screenshot of Debian packages setup|Figure 7.21: Debian Package Setup Packages]]
 +
</div>
 +
Information about extra resources such as modules, scripts and data files included in the installation package, figure [[#figure-pluthon_usage_debian_05_setup_data|7.22]].
-
 
+
<div id="figure-pluthon_usage_debian_05_setup_data">
-
{| summary="Variables View"
+
[[Image:debian-05-setup-data.png|frame|center|alt=Screenshot of Debian package setup data|Figure 7.22: Debian Package Setup Data]]
-
|+ align="BOTTOM" |'''Figure 7.17:''' Variables View
+
</div>
-
|-
+
-
|
+
-
[[Image:debug-04-variables-view.png|Image debug-04-variables-view]]
+
-
|}
+
-
 
+
-
 
+
-
 
+
-
= Debian Packaging PluThon Project =
+
-
 
+
-
== Generating Setup Script ==
+
-
 
+
-
The setup script (<span><font face="monospace">setup.py</font></span>) is used to create the Debian installation package for Python projects.
+
-
 
+
-
In setup script generator you need to define metadata, packages, executables and datafiles. This information is then used to create <span><font face="monospace">setup.py</font></span> script for the project, figure [[#fig:pluthon_usage_debian_01_setup_wizard|7.18]].
+
-
 
+
-
 
+
-
 
+
-
{| summary="Debian Package Setup Wizard"
+
-
|+ align="BOTTOM" |'''Figure 7.18:''' Debian Package Setup Wizard
+
-
|-
+
-
|
+
-
[[Image:debian-01-setup-wizard.png|Image debian-01-setup-wizard]]
+
-
|}
+
-
 
+
-
 
+
-
 
+
-
PluThon provides an automated wizard for creating Debian installation packages with this script. You can create the script from '''File &gt; New &gt; Other &gt; PyDev &gt; Setup Script''', figure [[#fig:pluthon_usage_debian_02_setup_wizard|7.19]].
+
-
 
+
-
 
+
-
 
+
-
{| summary="Debian Package Setup Project"
+
-
|+ align="BOTTOM" |'''Figure 7.19:''' Debian Package Setup Project
+
-
|-
+
-
|
+
-
[[Image:debian-02-setup-project.png|Image debian-02-setup-project]]
+
-
|}
+
-
 
+
-
 
+
-
 
+
-
For the <span><font face="monospace">setup.py</font></span> script you need to define certain metadata for the installation pacakge, figure [[#fig:pluthon_usage_debian_03_setup_parameters|7.20]].
+
-
 
+
-
 
+
-
 
+
-
{| summary="Debian Package Setup Parameters"
+
-
|+ align="BOTTOM" |'''Figure 7.20:''' Debian Package Setup Parameters
+
-
|-
+
-
|
+
-
[[Image:debian-03-setup-parameters.png|Image debian-03-setup-parameters]]
+
-
|}
+
-
 
+
-
 
+
-
 
+
-
Information about packages included in the installation package, figure [[#fig:pluthon_usage_debian_04_setup_package|7.21]].
+
-
 
+
-
 
+
-
 
+
-
{| summary="Debian Package Setup Packages"
+
-
|+ align="BOTTOM" |'''Figure 7.21:''' Debian Package Setup Packages
+
-
|-
+
-
|
+
-
[[Image:debian-04-setup-package.png|Image debian-04-setup-package]]
+
-
|}
+
-
 
+
-
 
+
-
 
+
-
Information about extra resources such as modules, scripts and data files included in the installation package, figure [[#fig:pluthon_usage_debian_05_setup_data|7.22]].
+
-
 
+
-
 
+
-
 
+
-
{| summary="Debian Package Setup Data"
+
-
|+ align="BOTTOM" |'''Figure 7.22:''' Debian Package Setup Data
+
-
|-
+
-
|
+
-
[[Image:debian-05-setup-data.png|Image debian-05-setup-data]]
+
-
|}
+
-
 
+
-
 
+
You can find more information about the Python setup script from [http://docs.python.org/distutils/setupscript.html Python distutils documentation].
You can find more information about the Python setup script from [http://docs.python.org/distutils/setupscript.html Python distutils documentation].
-
== Create Debian Installation Package ==
+
=== Create Debian Installation Package ===
-
You can export a project to the Debian installation package from '''File &gt; Export &gt; PluThon &gt; Export to Debian Package'''. This command requires that <span><font face="monospace">setup.py</font></span> script has been defined for the project.
+
You can export a project to the Debian installation package from '''File &gt; Export &gt; PluThon &gt; Export to Debian Package'''. This command requires that <code>setup.py</code> script has been defined for the project.
 +
<div id="figure-pluthon_usage_debian_08_export_setup">
 +
[[Image:debian-08-export-setup.png|frame|center|alt=Screenshot of exporting to a Debian package|Figure 7.23: Export to Debian Package]]
 +
</div>
 +
In Debian package export you only need to select the project and setup script. The package is created on the Maemo device using bdist-maemo distutils packages, figure [[#figure-pluthon_usage_debian_08_export_setup|7.23]].
-
{| summary="Export to Debian Package"
+
=== Install Debian Package to Maemo Device ===
-
|+ align="BOTTOM" |'''Figure 7.23:''' Export to Debian Package
+
-
|-
+
-
|
+
-
[[Image:debian-08-export-setup.png|Image debian-08-export-setup]]
+
-
|}
+
-
 
+
-
 
+
-
 
+
-
In Debian package export you only need to select the project and setup script. The package is created on the Maemo device using bdist-maemo distutils packages, figure [[#fig:pluthon_usage_debian_08_export_setup|7.23]].
+
-
 
+
-
== Install Debian Package to Maemo Device ==
+
To install a created Debian package to the Maemo device, right-click project and select '''Install Debian Package on Device''', figure [[#fig:pluthon_usage_debian_06_install_menu|7.24]].
To install a created Debian package to the Maemo device, right-click project and select '''Install Debian Package on Device''', figure [[#fig:pluthon_usage_debian_06_install_menu|7.24]].
 +
<div id="">
 +
[[Image:debian-06-install-menu.png|frame|center|alt=Screenshot of Debian package installation menu|Figure 7.24: Install Debian Package Menu]]
 +
</div>
 +
From the '''Install Debian Package''' wizard select '''Browse''' and set '''Package location''' to created package, select the correct connection and install using the '''Finish''' button, figure [[#figure-pluthon_usage_debian_07_install|7.25]].
-
{| summary="Install Debian Package Menu"
+
<div id="figure-pluthon_usage_debian_07_install">
-
|+ align="BOTTOM" |'''Figure 7.24:''' Install Debian Package Menu
+
[[Image:debian-07-install.png|frame|center|alt=Screenshot of Debian package installation wizard|Figure 7.25: Install Debian Package Wizard]]
-
|-
+
</div>
-
|
+
-
[[Image:debian-06-install-menu.png|Image debian-06-install-menu]]
+
-
|}
+
-
 
+
-
 
+
-
 
+
-
From the '''Install Debian Package''' wizard select '''Browse''' and set '''Package location''' to created package, select the correct connection and install using the '''Finish''' button, figure [[#fig:pluthon_usage_debian_07_install|7.25]].
+
-
 
+
-
 
+
-
{| summary="Install Debian Package Wizard"
+
[[Category:Documentation]]
-
|+ align="BOTTOM" |'''Figure 7.25:''' Install Debian Package Wizard
+
[[Category:Eclipse]]
-
|-
+
-
|
+
-
[[Image:debian-07-install.png|Image debian-07-install]]
+
-
|}
+

Latest revision as of 13:08, 12 November 2010

PluThon supports only Python projects. This chapter briefly shows hot to create Python projects and applications and run, test and debug Python applications with Maemo device.

PluThon requires Python installed on host PC and Maemo Device. See PluThon installation chapters for detailed information how to install PlutThon itself and needed Python development environments. PC Connectivity is needed to connect Maemo Device to host PC and PluThon. See PC Connectivity documentation for details how to install and configure Maemo PC Connectivity to the Maemo Device and Host PC Connectivity to the host PC you are running PluThon Eclipse environment.

Ensure that you can connect to the Maemo device from the host PC (that PC Connectivity has been properly installed and configured) before creating your first project with PluThon.

Contents

[edit] Creating PluThon Python projects

Create new PluThon project from File menu > New > PluThon Project, figure 7.1.

File:Project-01-new.png
Figure 7.1: New Project Menu

[edit] PluThon Project Templates

Templates define the basic structure of the project. Most of the templates are examples, but you can use these examples also as a base structure for your project.

Select any template under Examples. Some of the templates are only for Diablo devices (N800 or N810) and others for Fremantle (N900), figure 7.2.

File:Project-03-template.png
Figure 7.2: PluThon Project Template

[edit] PluThon Project Target

Select your connection to the device from the list. Default IP addresses are the same as PC Connectivity uses as default. The connection must be enabled from device PC Connectivity. See the PC Connectivity documentation for more information.

If you only use SSH connection to your device, or you have other IP values in your PC Connectivity properties, you can configure the connection here by right-clicking connection and selecting configure. Then you need to set Host name and Default User ID, figures 7.3 and 7.4.

File:Project-04-target.png
Figure 7.3: PluThon Project Target
File:Configure-connection.png
Figure 7.4: PluThon Project Target

You can configure connections afterwards from Window > Preferences > Maemo > Installed Targets or use Remote Systems view Window > Show View > Other > Remote Systems > Remote Systems.

[edit] PluThon Project Metadata

Basic Settings page defines some basic variables used by the selected template. You can insert requested information into fields or leave default values, figure 7.5.

File:Project-05-metadata.png
Figure 7.5: PluThon Project Configuration

[edit] PluThon Project Interpreter Configuration

Python configuration is done on the last page. If existing Python configuration is not found, a wizard suggests creating a new configuration.

Leave all values as default and press the Finish button to create project, figure 7.6.

File:Project-06-configuration.png
Figure 7.6: PluThon Project Configuration

If there were no previous configurations for your project, ESbox will ask you to create new configuration. Select Yes to create one, figure 7.7.

File:Project-07-interpreter-dialog.png
Figure 7.7: Python Interpreter Dialog

For the Python interpreter configuration you can select all Python paths and confirm the addition with OK button, figure 7.8.

File:Project-08-interpreter-paths.png
Figure 7.8: Python Interpreter Path Configuration

[edit] Validating PluThon Project Packages on Maemo Device

PluThon suggests package validation when a new project is created. Answer Yes to package validations, figure 7.9.

File:Project-09-validate-dialog.png
Figure 7.9: Validate Packages Dialog

PluThon installs the required dependencies into the Maemo device after you press Finish button on Package Validation Wizard, figure 7.10.

File:Project-10-validate-wizard.png
Figure 7.10: Validate Packages Wizard

Accept any packages PluThon suggests to install and close validation after the packages have been installed.

Package validation can be invoked from menu afterwards. Select Project > Project Menu > Validate installed packages.

During a validation project, dependencies are scanned from projects using Python package imports from source files.

[edit] Running Python Application on Maemo Device

In order to run applications on Maemo devices, the Maemo PC Connectivity package must be installed on the device and the Host PC Connectivity package for the host PC. See the PluThon installation chapters for more information.

You can run Python applications with PluThon by right-clicking a project and choosing Run As > PluThon Application, figure 7.11.

File:Run-01-run-as.png
Figure 7.11: Run as PluThon Application

Next, select the Python file to be run (do not select setup.py because it is used only for Debian package creation), figure 7.12.

File:Run-02-script.png
Figure 7.12: Select Executable

Then select the download method as Copy Programs (SSH) (as SBRSH requires configuration), figure 7.13.

File:Run-03-download.png
Figure 7.13: Select Download Method

You can now see the program running on the Maemo device.

You can use VNC Viewer to control the Maemo device and your application running on the device. Choose Window > Show View > Other > VNC Viewer.

Image:Ambox_notice.png
The x11vnc service must be installed on the Maemo device either separately (apt-get install x11vnc) or as part of Maemo PC Connectivity.

[edit] Debugging PluThon Application on Maemo Device

In order to debug the project, set at least one breakpoint into one of the source files where you want to start debugging. Open the source file and place the breakpoint at some position by right-clicking the left source side panel and choosing Add Breakpoint, figure 7.14.

File:Debug-02-add-breakpoint.png
Figure 7.14: Add Breakpoint

Launch your project in debug mode by right-clicking project and choosing Debug As > PluThon Application and accept changing to debug perspective, figure 7.15.

File:Debug-01-menu.png
Figure 7.15: Debug as PluThon Application

From the debug perspective, you can stop and continue execution, step lines, inspect variables, and so on. See Figures 7.16 and 7.17.

Image:Ambox_notice.png
You can switch back and forth between perspectives from top-right corner.
File:Debug-03-debug-view.png
Figure 7.16: Debug View
File:Debug-04-variables-view.png
Figure 7.17: Variables View

[edit] Debian Packaging PluThon Project

[edit] Generating Setup Script

The setup script (setup.py) is used to create the Debian installation package for Python projects.

In setup script generator you need to define metadata, packages, executables and datafiles. This information is then used to create setup.py script for the project, figure 7.18.

File:Debian-01-setup-wizard.png
Figure 7.18: Debian Package Setup Wizard

PluThon provides an automated wizard for creating Debian installation packages with this script. You can create the script from File > New > Other > PyDev > Setup Script, figure 7.19.

File:Debian-02-setup-project.png
Figure 7.19: Debian Package Setup Project

For the setup.py script you need to define certain metadata for the installation pacakge, figure 7.20.

File:Debian-03-setup-parameters.png
Figure 7.20: Debian Package Setup Parameters

Information about packages included in the installation package, figure 7.21.

File:Debian-04-setup-package.png
Figure 7.21: Debian Package Setup Packages

Information about extra resources such as modules, scripts and data files included in the installation package, figure 7.22.

File:Debian-05-setup-data.png
Figure 7.22: Debian Package Setup Data

You can find more information about the Python setup script from Python distutils documentation.

[edit] Create Debian Installation Package

You can export a project to the Debian installation package from File > Export > PluThon > Export to Debian Package. This command requires that setup.py script has been defined for the project.

File:Debian-08-export-setup.png
Figure 7.23: Export to Debian Package

In Debian package export you only need to select the project and setup script. The package is created on the Maemo device using bdist-maemo distutils packages, figure 7.23.

[edit] Install Debian Package to Maemo Device

To install a created Debian package to the Maemo device, right-click project and select Install Debian Package on Device, figure 7.24.

File:Debian-06-install-menu.png
Figure 7.24: Install Debian Package Menu

From the Install Debian Package wizard select Browse and set Package location to created package, select the correct connection and install using the Finish button, figure 7.25.

File:Debian-07-install.png
Figure 7.25: Install Debian Package Wizard