Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorflavio <fdanesse@gmail.com>2012-07-01 16:35:57 (GMT)
committer flavio <fdanesse@gmail.com>2012-07-01 16:35:57 (GMT)
commit1b4a4011f483104064be9a98c966d8d30fb4dccd (patch)
tree72d16858d20cd5b0142c475175ce91bd858ddb86
parent3de4f3b6d88b531d0c33bd9791250b4f81f55b11 (diff)
De sugar a sugar3
-rw-r--r--olpcgames/activity.py4
-rw-r--r--olpcgames/canvas.py32
-rw-r--r--olpcgames/mesh.py120
-rw-r--r--olpcgames/util.py6
4 files changed, 81 insertions, 81 deletions
diff --git a/olpcgames/activity.py b/olpcgames/activity.py
index 0c1b219..0f3ecd7 100644
--- a/olpcgames/activity.py
+++ b/olpcgames/activity.py
@@ -33,8 +33,8 @@ import gtk
import gtk.gdk
import os
-from sugar.activity import activity
-from sugar.graphics import style
+from sugar3.activity import activity
+from sugar3.graphics import style
from olpcgames.canvas import PygameCanvas
from olpcgames import mesh, util
diff --git a/olpcgames/canvas.py b/olpcgames/canvas.py
index 2583827..9dadeaa 100644
--- a/olpcgames/canvas.py
+++ b/olpcgames/canvas.py
@@ -20,9 +20,9 @@ __all__ = ['PygameCanvas']
class PygameCanvas(gtk.Layout):
"""Canvas providing bridge methods to run Pygame in GTK
- The PygameCanvas creates a secondary thread in which the Pygame instance will
- live, providing synthetic Pygame events to that thread via a Queue. The GUI
- connection is done by having the Pygame canvas use a GTK Port object as it's
+ The PygameCanvas creates a secondary thread in which the Pygame instance will
+ live, providing synthetic Pygame events to that thread via a Queue. The GUI
+ connection is done by having the Pygame canvas use a GTK Port object as it's
window pointer, it draws to that X-level window in order to produce output.
"""
mod_name = None
@@ -31,10 +31,10 @@ class PygameCanvas(gtk.Layout):
width,height -- passed to the inner EventBox in order to request a given size,
the Socket is the only child of this EventBox, and the Pygame commands
- will be writing to the Window ID of the socket. The internal EventBox is
+ will be writing to the Window ID of the socket. The internal EventBox is
centered via an Alignment instance within the PygameCanvas instance.
- XXX Should refactor so that the internal setup can be controlled by the
+ XXX Should refactor so that the internal setup can be controlled by the
sub-class, e.g. to get size from the host window, or something similar.
"""
# Build the main widget
@@ -66,15 +66,15 @@ class PygameCanvas(gtk.Layout):
# <Cue Thus Spract Zarathustra>
self.show()
def connect_game(self, app):
- """Imports the given main-loop and starts processing in secondary thread
+ """Imports the given main-loop and starts processing in secondary thread
- app -- fully-qualified Python path-name for the game's main-loop, with
- name within module as :functionname, if no : character is present then
+ app -- fully-qualified Python path-name for the game's main-loop, with
+ name within module as :functionname, if no : character is present then
:main will be assumed.
Side effects:
- Sets the SDL_WINDOWID variable to our socket's window ID
+ Sets the SDL_WINDOWID variable to our socket's window ID
Calls Pygame init
Causes the gtkEvent.Translator to "hook" Pygame
Creates and starts secondary thread for Game/Pygame event processing.
@@ -106,12 +106,12 @@ class PygameCanvas(gtk.Layout):
import olpcgames
olpcgames.widget = olpcgames.WIDGET = self
try:
- import sugar.activity.activity,os
+ import sugar3.activity.activity,os
except ImportError, err:
log.info( """Running outside Sugar""" )
else:
try:
- os.chdir(sugar.activity.activity.get_bundle_path())
+ os.chdir(sugar3.activity.activity.get_bundle_path())
except KeyError, err:
pass
@@ -138,12 +138,12 @@ class PygameCanvas(gtk.Layout):
source_object_id = None
def view_source(self):
- """Implement the 'view source' key by saving
+ """Implement the 'view source' key by saving
datastore, and then telling the Journal to view it."""
if self.source_object_id is None:
- from sugar import profile
- from sugar.datastore import datastore
- from sugar.activity.activity import get_bundle_name, get_bundle_path
+ from sugar3 import profile
+ from sugar3.datastore import datastore
+ from sugar3.activity.activity import get_bundle_name, get_bundle_path
from gettext import gettext as _
import os.path
jobject = datastore.create()
@@ -165,7 +165,7 @@ class PygameCanvas(gtk.Layout):
"""Invoke journal_show_object from sugar.activity.activity if it
exists."""
try:
- from sugar.activity.activity import show_object_in_journal
+ from sugar3.activity.activity import show_object_in_journal
show_object_in_journal(object_id)
except ImportError:
pass # no love from sugar.
diff --git a/olpcgames/mesh.py b/olpcgames/mesh.py
index 1818214..f3e6324 100644
--- a/olpcgames/mesh.py
+++ b/olpcgames/mesh.py
@@ -1,86 +1,86 @@
'''Utilities for wrapping the telepathy network for Pygame
-The 'mesh' module allows your Pygame game to be Shared
+The 'mesh' module allows your Pygame game to be Shared
across the OLPC networking infrastructure (D-bus and Tubes).
It offers a simplified view of the Telepathy system.
-All Sugar activities have a 'Share' menu (toolbar) which is
-intended to allow other people to join the activity instance
-and collaborate with you. When you select Share, the activity's
+All Sugar activities have a 'Share' menu (toolbar) which is
+intended to allow other people to join the activity instance
+and collaborate with you. When you select Share, the activity's
icon appears on the Neighborhood view of other laptops.
-If you do nothing else with networking, this is all that will
-happen: if anyone selects your shared activity icon, they will
-just spawn a new instance of the activity, and they will get to
+If you do nothing else with networking, this is all that will
+happen: if anyone selects your shared activity icon, they will
+just spawn a new instance of the activity, and they will get to
play your game alone.
-The mesh module automatically sets up a connection from each
+The mesh module automatically sets up a connection from each
participant to every other participant. It provides (string based)
-communications channels that let you either broadcast messages
+communications channels that let you either broadcast messages
to other users or communicate point-to-point to one other user.
-You can use the "handles" which uniquely idenify users to send
-messages to an individual user (send_to( handle, message )) or
+You can use the "handles" which uniquely idenify users to send
+messages to an individual user (send_to( handle, message )) or
broadcast( message ) to send a message to all participants.
-More advanced (structured) networking can be handled by using
-the get_object( handle, path ) function, which looks up an object
-(by DBUS path) shared by the user "handle" and returns a
-DBUS/Telepathy proxy for that object. The object you get back is
-actually an olpcgames.dbusproxy.DBUSProxy instance, which
-enforces asynchronous operations and runs your
+More advanced (structured) networking can be handled by using
+the get_object( handle, path ) function, which looks up an object
+(by DBUS path) shared by the user "handle" and returns a
+DBUS/Telepathy proxy for that object. The object you get back is
+actually an olpcgames.dbusproxy.DBUSProxy instance, which
+enforces asynchronous operations and runs your
reply_handler/error_handler in the Pygame event loop.
NOTE:
- You *cannot* make synchronous calls on these objects!
+ You *cannot* make synchronous calls on these objects!
You must use the named arguments:
reply_handler, error_handler
- for every call which you perform on a shared object (normally
+ for every call which you perform on a shared object (normally
these are ExportedGObject instances).
-If you want to run your callbacks in the GTK event loop (for instance
-because they need to handle GTK-side objects), you can use the
-dbus_get_object function. This is *not* recommended for normal
-usage, as any call to Pygame operations within the GTK event loop
+If you want to run your callbacks in the GTK event loop (for instance
+because they need to handle GTK-side objects), you can use the
+dbus_get_object function. This is *not* recommended for normal
+usage, as any call to Pygame operations within the GTK event loop
can cause a segfault/core of your entire Activity.
Note:
- mesh sets up N**2 connections for each shared activity, obviously
- that will not scale to very large shared activities.
+ mesh sets up N**2 connections for each shared activity, obviously
+ that will not scale to very large shared activities.
-Note:
+Note:
- The intention is that mesh will be refactored, possibly as a
- new module called "olpcgames.network", which would break out
- the various components so that there is no longer an assumed
- networking layout. We will attempt to retain the mesh module's
+ The intention is that mesh will be refactored, possibly as a
+ new module called "olpcgames.network", which would break out
+ the various components so that there is no longer an assumed
+ networking layout. We will attempt to retain the mesh module's
API as we do so.
Events produced:
- olpcgames.CONNECT -- The tube connection was started. (i.e., the
- user clicked Share or started the activity from the Neighborhood
+ olpcgames.CONNECT -- The tube connection was started. (i.e., the
+ user clicked Share or started the activity from the Neighborhood
screen).
Event properties:
- id -- a unique identifier for this connection. (shouldn't be needed
+ id -- a unique identifier for this connection. (shouldn't be needed
for anything)
- olpcgames.PARTICIPANT_ADD -- A participant joined the activity.
- This will trigger for the local user as well as any arriving remote
- users. Note that this *only* occurs after the activity is shared,
- that is, the local user does not appear until after they have
+ olpcgames.PARTICIPANT_ADD -- A participant joined the activity.
+ This will trigger for the local user as well as any arriving remote
+ users. Note that this *only* occurs after the activity is shared,
+ that is, the local user does not appear until after they have
shared a locally-started activity.
Event properties:
- handle -- the arriving user's handle (a uniquely identifying string
- assigned to the user by the Telepathy system, not human
- readable), see lookup_buddy to retrieve human-readable
+ handle -- the arriving user's handle (a uniquely identifying string
+ assigned to the user by the Telepathy system, not human
+ readable), see lookup_buddy to retrieve human-readable
descriptions of the user.
olpcgames.PARTICIPANT_REMOVE -- A participant quit the activity.
@@ -105,14 +105,14 @@ Events produced:
Note:
- Eventually we will stop using top-level Pygame event types for the
- various networking message types (currently four of them). We will
- likely use UserEvent with a sub-type specifier for the various events
+ Eventually we will stop using top-level Pygame event types for the
+ various networking message types (currently four of them). We will
+ likely use UserEvent with a sub-type specifier for the various events
that OLPCGames produces.
See Also:
- http://blog.vrplumber.com/2016 -- Discussion of how Productive uses
+ http://blog.vrplumber.com/2016 -- Discussion of how Productive uses
the mesh module and raw Telepathy (ExportedGObject instances)
'''
import logging
@@ -121,7 +121,7 @@ log = logging.getLogger( 'olpcgames.mesh' )
import olpcgames
from olpcgames.util import get_traceback
try:
- from sugar.presence.tubeconn import TubeConnection
+ from sugar3.presence.tubeconn import TubeConnection
except ImportError, err:
TubeConnection = object
try:
@@ -136,7 +136,7 @@ except ImportError, err:
telepathy = None
try:
- import sugar.presence.presenceservice
+ import sugar3.presence.presenceservice
except Exception, err:
pass
import pygame.event as PEvent
@@ -346,7 +346,7 @@ def _list_tubes_error_cb(e):
def lookup_buddy( dbus_handle, callback, errback=None ):
"""Do a lookup on the buddy information, callback with the information
- Calls callback( buddy ) with the result of the lookup, or errback( error ) with
+ Calls callback( buddy ) with the result of the lookup, or errback( error ) with
a dbus description of the error in the lookup process.
returns None
@@ -387,7 +387,7 @@ def get_buddy(dbus_handle):
"""DEPRECATED: Get a Buddy from a handle
THIS API WAS NOT THREAD SAFE! It has been removed to avoid
- extremely hard-to-debug failures in activities. Use lookup_buddy
+ extremely hard-to-debug failures in activities. Use lookup_buddy
instead!
Code that read:
@@ -416,7 +416,7 @@ def _get_presence_service( ):
log.debug( """About to import sugar.presence.presenceservice""" )
try:
log.debug( 'About to retrieve presence service instance' )
- pservice = sugar.presence.presenceservice.get_instance()
+ pservice = sugar3.presence.presenceservice.get_instance()
try:
log.debug( ' Retrieved presence service instance: %s', pservice )
name, path = pservice.get_preferred_connection()
@@ -521,8 +521,8 @@ def broadcast(content=""):
def my_handle():
'''Returns the handle of this user
- Note, you can get a DBusException from this if you have
- not yet got a unique ID assigned by the bus. You may need
+ Note, you can get a DBusException from this if you have
+ not yet got a unique ID assigned by the bus. You may need
to delay calling until you are sure you are connected.
'''
log.debug( 'my handle' )
@@ -545,9 +545,9 @@ def get_participants():
def dbus_get_object(handle, path, warning=True):
'''Get a D-bus object from another participant
- Note: this *must* be called *only* from the GTK mainloop, calling
- it from Pygame will cause crashes! If you are *sure* you only ever
- want to call methods on this proxy from GTK, you can use
+ Note: this *must* be called *only* from the GTK mainloop, calling
+ it from Pygame will cause crashes! If you are *sure* you only ever
+ want to call methods on this proxy from GTK, you can use
warning=False to silence the warning log message.
'''
if warning:
@@ -560,24 +560,24 @@ def get_object(handle, path):
This is how you can communicate with other participants using
arbitrary D-bus objects without having to manage the participants
yourself. You can use the returned proxy's methods from Pygame,
- with your callbacks occuring in the Pygame thread, rather than
+ with your callbacks occuring in the Pygame thread, rather than
in the DBUS/GTK event loop.
Simply define a D-bus class with an interface and path that you
choose; when you want a reference to the corresponding remote
object on a participant, call this method.
- returns an olpcgames.dbusproxy.DBUSProxy( ) object wrapping
+ returns an olpcgames.dbusproxy.DBUSProxy( ) object wrapping
the DBUSProxy object.
The dbus_get_object_proxy name is deprecated
'''
log.debug( 'DBUS get_object( %r %r )', handle, path )
from olpcgames import dbusproxy
- return dbusproxy.DBUSProxy(
- instance().tube.get_object( handle, path),
- tube=instance().tube,
- path=path
+ return dbusproxy.DBUSProxy(
+ instance().tube.get_object( handle, path),
+ tube=instance().tube,
+ path=path
)
dbus_get_object_proxy = get_object
diff --git a/olpcgames/util.py b/olpcgames/util.py
index 49a23b0..20dc03e 100644
--- a/olpcgames/util.py
+++ b/olpcgames/util.py
@@ -8,7 +8,7 @@ import os.path
NON_SUGAR_ROOT = '~/.sugar/default/olpcgames'
try:
- from sugar.activity.activity import get_bundle_path as _get_bundle_path
+ from sugar3.activity.activity import get_bundle_path as _get_bundle_path
def get_bundle_path( ):
"""Retrieve bundle path from activity with fix for silly registration bug"""
path = _get_bundle_path()
@@ -53,8 +53,8 @@ def get_traceback(error):
try:
doSomething()
except Exception, err:
- log.error(
- '''Failure during doSomething with X,Y,Z parameters: %s''',
+ log.error(
+ '''Failure during doSomething with X,Y,Z parameters: %s''',
util.get_traceback( err ),
)
"""