Saturday, 12 January 2013

Installation for Linux Users


Installation for Linux Users

We assume that your computer has either a built-in Bluetooth capability
or an external Bluetooth dongle. Also, we assume that Bluetooth is
detected correctly by your distribution and you have the obexftp and
hcitool programs installed. In many distributions, they can be installed
from packages obexftp and bluez-utils.
1. Install the downloaded .SIS files to your phone
First, enable Bluetooth on your phone. Then, on the command line,
execute the following command:

hcitool scan


This performs Bluetooth scanning. You should see the name of your
phone in the list, with its Bluetooth address (e.g., 00:17:ED:AC:56:FE).
Next, you can upload the SIS files to your phone with the following
commands:
obexftp -b 00:17:ED:AC:56:FE -c E: -p PythonForS60...SIS
obexftp -b 00:17:ED:AC:56:FE -c E: -p PythonScriptShell...SIS


Replace the Bluetooth address above with your phone’s actual Bluetooth
address. Also, replace the file names with the actual names of the
files that you downloaded.
On the phone, open the File Manager application (usually found on
the desktop of the phone or inside a subfolder e.g. ‘Tools’) and go to
the root of the memory card. You should see the two files there. Click
on the installation files. First, install the PyS60 interpreter (PythonForS60)
and then the user interface for the PyS60 interpreter (PythonScriptShell).
Follow the on-screen instructions on the phone – for instance, select ‘Yes’
if a security warning appears on the phone screen. Also, make sure the
date is set correctly on the phone.


2. Write a Python Script

You can write a Python script on your computer with any text editor.
Useful editors are, for example, Vim or Emacs.
Write the following line in your text editor:
print "Hello world!"
After the code is typed, save the file under the name hello.py. Make
sure that the file ending is .py and not .txt.
The file is now ready to be executed on your phone! You do not have
to build or compile it any way. However, it must be copied to the phone
first.

3. Upload a Python Script to a Phone

We use the same obexftp tool for this as in Step 1. Execute the following
command on the command line, replacing the Bluetooth address with
your phone’s actual address:
obexftp -b 00:17:ED:AC:56:FE -c E: -C Python -p hello.py

4. Test a Python Script

Start the PyS60 interpreter by clicking on the Python icon (Figure 2.1) on
the desktop or inside the appropriate subfolder on your phone. Once the
PyS60 interpreter has started up, select ‘Options’ (Figure 2.4(a)) and then
‘Run script’ (Figure 2.4(b)). Choose your script name, e:hello.py, from
the list and select ‘OK’. Your script should now start up and you should
see a green line stating Hello world! (Figure 2.5).
Congratulations! You have successfully written and executed your
script with PyS60! To go through all the examples in the book, just repeat
steps 2–4 for each new script. Have fun with it






No comments:

Post a Comment