User:PIOLPCIntern-1/docs

From OLPC
< User:PIOLPCIntern-1
Revision as of 14:39, 20 September 2008 by Garycmartin (talk | contribs) (comment on bundlebuilder)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

User:PIOLPCIntern-1::Blog::Marching::Description::Docs

This is where I'm keeping any little things I type up while I'm playing around. They're more or less for my own reference, but since they're pretty simple I guess other clueless people could use them :)

Oh, and I've been typing them in gedit so the formatting is kinda wonky on the wiki. I'll fix it eventually.

Creating Activities with Python code

asic Activity Creation for JHBuild w/ python.

note: This is merely a compilation of the various descriptions of activity creation of the olpc wiki (wiki.laptop.org) combined with my experience trying to create a working activity. Sometimes the descriptions are completely copied, some paraphrased, and some are all me.


1. Create a directory called 'activityname-activity' in the sugar-jhbuild/source folder, where 'activityname' is the name of your activity (ie, read, browse). The '-activity' is a naming convention.

2. Within that directory, create another called 'activity'

3. In the activity directory, create a new file called 'activity.info'. This file should have the following in it (lines beginning with # are my comments):

[Activity]

  1. This top line should not change; it should always read [Activity].

name = NameOfActivity

  1. This is the name of the activity as it will appear in Sugar.

service_name = com.Activity.Example

  1. This is the activity's dbus service name. It is required. It is also used
  2. as the activity's default service type when the activity is shared on the
  3. network. To determine this type, the distince parts (separated by the '.'
  4. character) are reversed, any '.' is replaced by a '_' character, and the
  5. type is prefixed by a '_' character. So in this example, the default
  6. service type would be "_Example_Activity_com".

class = myactivity.ActivityClass

  1. This is the location of the main class of the program, where 'myactivity' is the python file with the class in it, and
  2. 'ActivityClass is the name of the class.

icon = icon

  1. The name of the icon image file.

activity_version = 1

  1. The version of the activity.

show_launcher = yes

  1. Whether or not to show the icon in the sugar launcher.

4. Put the image (in .svg format) to be used as the activity's icon in the activity folder.

5. Go back to the activityname-activity directory.

6. In this directory, place the your python code files. Create the following blank files: 'setup.py', 'NEWS', and 'MANIFEST'

7. Open MANIFEST in a text editor, and type in a list of files to include in the package. (myactivity.py, for example.)

8. Edit the setup.py file to read:

  1. !/usr/bin/env python

from sugar.activity import bundlebuilder if __name__ == "__main__":

   bundlebuilder.start("MyActivityName")

where 'MyActivityName' is the name of the activity. I don't really know where this name shows up; I created an activity with this name different from all the other ones I used and didn't see it anywhere. Maybe it's what it calls the .xo when you create an activity bundle?

You can just call bundlebuilder.start(), it will pick up the activity name from your activity/activity.info file (the above usage had no effect and will generate a obtuse warning message). --Garycmartin

9. In the terminal, run ./sugar-jhbuild shell

10. cd to the activityname-activity folder and run 'python ./setup.py dev'

11. The activity should now show up in Sugar. To create an activity bundle instead of installing it to sugar, run 'python ./setup.py dist'

XO emulation Remote Display w/ qemu and vnc

qemu runs disk images and is what we're using here to emulate an XO, kqemu is a module that speeds up qemu emulation, and vnc "provides remote control software which lets you see and interact with desktop applications across the network."

1. Install qemu, kqemu, and vncserver.

The first step is to install kqemu:

$ sudo aptitude install kqemu-common kqemu-source module-assistant


$ sudo m-a prepare


$ sudo m-a build kqemu


$ sudo m-a install kqemu


That all should have kqemu set up. You also may have to run:

$ sudo modprobe kqemu

Then install qemu:

$ sudo aptitude install qemu

Get and install vnc. I used 'http://www.tightvnc.com/'.

2. Get an XO image.

Get the XO image that can be found on this page:

http://wiki.laptop.org/go/Emulating_the_XO/Quick_Start

Extract that image, the final file should be a .img file.

3. Emulate the image on the network and...stuff.

From here, instructions are from http://wiki.laptop.org/go/Remote_Display

Emulate the image using qemu, with vnc options to

 qemu -kernel-kqemu -vnc 0 -k en-us [XO image name].img

I actually used '-vnc 1' because 0 was taken up by something else, I think. Click and drag the img into the terminal to get it's path, or type it in manually.

At this point, the server should be set up. On the computer you want to run the image on, install vncviewer software and use it to open the vncserver.

$ vncviewer [ip]:1

where [ip] is the ip address of the computer that the vncserver is running on. Alternately, on a windows pc, download realvnc and connect to [ip]:1 with it.