diff options
-rw-r--r--[-rwxr-xr-x] | olpcgames/COPYING | 0 | ||||
-rw-r--r--[-rwxr-xr-x] | olpcgames/__init__.py | 0 | ||||
-rw-r--r--[-rwxr-xr-x] | olpcgames/_cairoimage.py | 0 | ||||
-rw-r--r--[-rwxr-xr-x] | olpcgames/_gtkmain.py | 2 | ||||
-rw-r--r--[-rwxr-xr-x] | olpcgames/_version.py | 0 | ||||
-rw-r--r--[-rwxr-xr-x] | olpcgames/activity.py | 5 | ||||
-rwxr-xr-x | olpcgames/buildmanifest.py | 33 | ||||
-rw-r--r--[-rwxr-xr-x] | olpcgames/camera.py | 3 | ||||
-rw-r--r--[-rwxr-xr-x] | olpcgames/canvas.py | 7 | ||||
-rwxr-xr-x | olpcgames/data/sleeping.svg | 52 | ||||
-rw-r--r--[-rwxr-xr-x] | olpcgames/data/sleeping_svg.py | 0 | ||||
-rw-r--r--[-rwxr-xr-x] | olpcgames/dbusproxy.py | 3 | ||||
-rw-r--r--[-rwxr-xr-x] | olpcgames/eventwrap.py | 20 | ||||
-rw-r--r--[-rwxr-xr-x] | olpcgames/gtkEvent.py | 1 | ||||
-rw-r--r--[-rwxr-xr-x] | olpcgames/mesh.py | 16 | ||||
-rw-r--r--[-rwxr-xr-x] | olpcgames/pangofont.py | 5 | ||||
-rw-r--r--[-rwxr-xr-x] | olpcgames/pausescreen.py | 2 | ||||
-rw-r--r--[-rwxr-xr-x] | olpcgames/svgsprite.py | 2 | ||||
-rw-r--r--[-rwxr-xr-x] | olpcgames/textsprite.py | 0 | ||||
-rw-r--r--[-rwxr-xr-x] | olpcgames/util.py | 0 | ||||
-rw-r--r--[-rwxr-xr-x] | olpcgames/video.py | 17 |
21 files changed, 37 insertions, 131 deletions
diff --git a/olpcgames/COPYING b/olpcgames/COPYING index b8adee0..b8adee0 100755..100644 --- a/olpcgames/COPYING +++ b/olpcgames/COPYING diff --git a/olpcgames/__init__.py b/olpcgames/__init__.py index 504388c..504388c 100755..100644 --- a/olpcgames/__init__.py +++ b/olpcgames/__init__.py diff --git a/olpcgames/_cairoimage.py b/olpcgames/_cairoimage.py index 3cfa22c..3cfa22c 100755..100644 --- a/olpcgames/_cairoimage.py +++ b/olpcgames/_cairoimage.py diff --git a/olpcgames/_gtkmain.py b/olpcgames/_gtkmain.py index 33a6a83..b592e85 100755..100644 --- a/olpcgames/_gtkmain.py +++ b/olpcgames/_gtkmain.py @@ -38,7 +38,7 @@ class _TrackLoop( object ): log.debug( 'GTK loop exiting' ) try: del self.t_loop - except AttributeError, err: + except AttributeError: pass class Holder(): diff --git a/olpcgames/_version.py b/olpcgames/_version.py index 6a4e1db..6a4e1db 100755..100644 --- a/olpcgames/_version.py +++ b/olpcgames/_version.py diff --git a/olpcgames/activity.py b/olpcgames/activity.py index 538ba13..b0f1d28 100755..100644 --- a/olpcgames/activity.py +++ b/olpcgames/activity.py @@ -1,3 +1,5 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- """Embeds the Canvas widget into a Sugar-specific Activity environment The olpcgames.activity module encapsulates creation of a Pygame activity. @@ -161,7 +163,8 @@ class PygameActivity(activity.Activity): self.game_handler or self.game_name ) if self.pygame_mode != 'Cairo': - self._pgc = self.PYGAME_CANVAS_CLASS(*self.game_size) + size = max(gtk.gdk.screen_width(), gtk.gdk.screen_height()) + self._pgc = self.PYGAME_CANVAS_CLASS(*(size, size)) self.set_canvas(self._pgc) self._pgc.grab_focus() self._pgc.connect_game(self.game_handler or self.game_name) diff --git a/olpcgames/buildmanifest.py b/olpcgames/buildmanifest.py deleted file mode 100755 index 899433b..0000000 --- a/olpcgames/buildmanifest.py +++ /dev/null @@ -1,33 +0,0 @@ -#! /usr/bin/env python -"""Stupid little script to automate generation of MANIFEST and po/POTFILES.in - -Really this should have been handled by using distutils, but oh well, -distutils is a hoary beast and I can't fault people for not wanting to -spend days spelunking around inside it to find the solutions... -""" -from distutils.filelist import FileList -import os - -def fileList( template ): - """Produce a formatted file-list for storing in a file""" - files = FileList() - for line in filter(None,template.splitlines()): - files.process_template_line( line ) - content = '\n'.join( files.files ) - return content - - -def main( ): - """Do the quicky finding of files for our manifests""" - content = fileList( open('MANIFEST.in').read() ) - open( 'MANIFEST','w').write( content ) - - content = fileList( open('POTFILES.in').read() ) - try: - os.makedirs( 'po' ) - except OSError, err: - pass - open( os.path.join('po','POTFILES.in'), 'w').write( content ) - -if __name__ == "__main__": - main() diff --git a/olpcgames/camera.py b/olpcgames/camera.py index 249f295..d4d1175 100755..100644 --- a/olpcgames/camera.py +++ b/olpcgames/camera.py @@ -13,7 +13,6 @@ Activity demonstrating usage: import threading, subprocess import logging import olpcgames -import time import os import pygame from olpcgames.util import get_activity_root @@ -127,7 +126,7 @@ class Camera(object): finally: try: os.remove( filename ) - except (IOError,OSError), err: + except (IOError,OSError): pass def snap_async( self, token=None ): """Snap a picture asynchronously generating event on success/failure diff --git a/olpcgames/canvas.py b/olpcgames/canvas.py index 2583827..c575cf0 100755..100644 --- a/olpcgames/canvas.py +++ b/olpcgames/canvas.py @@ -1,16 +1,13 @@ """Implements bridge connection between Sugar/GTK and Pygame""" import os -import sys import logging log = logging.getLogger( 'olpcgames.canvas' ) ##log.setLevel( logging.DEBUG ) import threading -from pprint import pprint import pygtk pygtk.require('2.0') import gtk -import gobject import pygame from olpcgames import gtkEvent, util @@ -84,6 +81,8 @@ class PygameCanvas(gtk.Layout): os.environ['SDL_WINDOWID'] = str(self._socket.get_id()) #print 'Socket ID=%s'%os.environ['SDL_WINDOWID'] pygame.init() + # Maze does not use sound. stop the mixer due to OLPC #12677 + pygame.mixer.quit() self._translator.hook_pygame() @@ -134,7 +133,7 @@ class PygameCanvas(gtk.Layout): eventwrap.clear() finally: log.info( 'Main function finished, calling main_quit' ) - gtk.main_quit() + # gtk.main_quit() source_object_id = None def view_source(self): diff --git a/olpcgames/data/sleeping.svg b/olpcgames/data/sleeping.svg deleted file mode 100755 index 2c7ef50..0000000 --- a/olpcgames/data/sleeping.svg +++ /dev/null @@ -1,52 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?> -<svg - xmlns="http://www.w3.org/2000/svg" - xmlns:xlink="http://www.w3.org/1999/xlink" - width="737" - height="923" - version="1.0"> - <defs> - <linearGradient - id="linearGradient3152"> - <stop - style="stop-color:#b8ffb4;stop-opacity:1;" - offset="0" /> - <stop - offset="0.5" - style="stop-color:#2eff22;stop-opacity:0.5;" /> - <stop - style="stop-color:#ffffff;stop-opacity:0;" - offset="1" /> - </linearGradient> - <radialGradient - xlink:href="#linearGradient3152" - id="radialGradient3158" - cx="260" - cy="235" - fx="260" - fy="235" - r="259" - gradientTransform="matrix(1,0,0,1.2531846,0,-59.560934)" - gradientUnits="userSpaceOnUse" /> - </defs> - <g - transform="translate(-3,-73)"> - <path - style="opacity:1;color:#000000;fill:url(#radialGradient3158);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1.5;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" - id="path2178" - d="M 519 235 A 259 324 0 1 1 0,235 A 259 324 0 1 1 519 235 z" - transform="matrix(1.4203822,0,0,1.4203822,0,200)" /> - <path - style="fill:#000000;fill-opacity:0.75;fill-rule:nonzero;stroke:none;stroke-width:1pt;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" - d="M 420,366 C 438,381 455,400 478,408 C 523,427 576,424 620,405 C 632,400 644,393 655,387 C 652,389 638,397 649,391 C 658,385 666,379 676,376 C 688,370 673,379 669,382 C 637,401 604,421 566,427 C 526,435 482,429 446,408 C 431,398 419,385 405,374 C 410,371 415,368 420,366 z " /> - <path - style="fill:#000000;fill-opacity:0.75;fill-rule:nonzero;stroke:none;stroke-width:1pt;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" - d="M 322,366 C 303,381 286,400 263,408 C 218,427 166,424 121,405 C 109,400 98,393 86,387 C 89,389 103,397 93,391 C 84,385 75,379 65,376 C 53,370 68,379 72,382 C 104,401 137,421 175,427 C 216,435 260,429 295,408 C 310,398 322,385 336,374 C 331,371 326,368 322,366 z " /> - <path - style="fill:#000000;fill-opacity:0.75;fill-rule:nonzero;stroke:none;stroke-width:1pt;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" - d="M 363,383 C 347,418 353,458 345,495 C 339,525 324,551 312,579 C 304,598 298,620 309,639 C 317,655 335,667 353,669 C 379,671 405,664 429,653 C 442,646 405,667 423,656 C 429,652 434,647 441,645 C 455,639 439,650 434,653 C 408,669 378,679 347,679 C 327,679 308,667 297,651 C 285,634 287,613 294,594 C 302,570 316,548 324,523 C 335,493 335,460 338,428 C 340,415 342,401 349,390 C 353,388 358,385 363,383 z " /> - <path - style="fill:#000000;fill-opacity:0.75;fill-rule:nonzero;stroke:none;stroke-width:1pt;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" - d="M 206,735 C 245,737 285,740 324,744 C 357,745 391,746 424,744 C 468,738 510,723 550,703 C 552,703 544,709 541,711 C 531,718 518,722 507,727 C 474,740 440,751 405,754 C 360,756 314,754 268,749 C 243,747 218,746 193,745 C 197,741 201,738 206,735 z " /> - </g> -</svg> diff --git a/olpcgames/data/sleeping_svg.py b/olpcgames/data/sleeping_svg.py index c52398a..c52398a 100755..100644 --- a/olpcgames/data/sleeping_svg.py +++ b/olpcgames/data/sleeping_svg.py diff --git a/olpcgames/dbusproxy.py b/olpcgames/dbusproxy.py index a103e28..5e0c757 100755..100644 --- a/olpcgames/dbusproxy.py +++ b/olpcgames/dbusproxy.py @@ -1,5 +1,5 @@ """Spike test for a safer networking system for DBUS-based objects""" -from olpcgames import eventwrap, util +from olpcgames import util from dbus import proxies import logging log = logging.getLogger( 'dbus' ) @@ -26,7 +26,6 @@ class DBUSProxy( object ): self.__path = path def __getattr__( self, key ): """Retrieve attribute of given key""" - from dbus import proxies return wrap( getattr( self.__proxy, key ) ) def add_signal_receiver( self, callback, eventName, interface, path=None, sender_keyword='sender'): """Add a new signal handler (which will be called many times) for given signal diff --git a/olpcgames/eventwrap.py b/olpcgames/eventwrap.py index 402109c..e87e13b 100755..100644 --- a/olpcgames/eventwrap.py +++ b/olpcgames/eventwrap.py @@ -19,15 +19,15 @@ Extensions: release a few more resources, then a bit more... """ import pygame -import gtk import Queue import thread, threading import logging +from time import time from olpcgames import util log = logging.getLogger( 'olpcgames.eventwrap' ) -from pygame.event import Event, event_name, pump as pygame_pump, get as pygame_get +from pygame.event import pump as pygame_pump, get as pygame_get class Event(object): """Mock pygame events""" @@ -67,7 +67,7 @@ class Event(object): try: self.__lock.set() log.info( '''Released GTK thread on event: %s''', self ) - except AttributeError, err: + except AttributeError: pass class CallbackResult( object ): @@ -105,7 +105,7 @@ def _releaseEvents( ): for event in _EVENTS_TO_RETIRE: try: event.retire() - except AttributeError, err: + except AttributeError: pass def _processCallbacks( events ): @@ -167,9 +167,9 @@ class _FilterQueue( Queue.Queue ): else: if timeout < 0: raise ValueError("'timeout' must be a positive number") - endtime = _time() + timeout + endtime = time() + timeout while self._empty_type( filterFunction ): - remaining = endtime - _time() + remaining = endtime - time() if remaining <= 0.0: raise Queue.Empty self.not_empty.wait(remaining) @@ -202,7 +202,7 @@ class _FilterQueue( Queue.Queue ): if filterFunction( element ): return element return None - except RuntimeError, err: + except RuntimeError: return None # none yet, at least g_events = _FilterQueue() @@ -220,7 +220,7 @@ def _typeChecker( types ): def check( element ): return element.type in types return check - except TypeError, err: + except TypeError: def check( element ): return element.type == types return check @@ -288,9 +288,9 @@ def wait( timeout = None): result = g_events.get(block=True, timeout=timeout) try: return _recordEvents( [result] )[0] - except IndexError, err: + except IndexError: return Event( type=pygame.NOEVENT ) - except Queue.Empty, err: + except Queue.Empty: return None def peek(types=None): diff --git a/olpcgames/gtkEvent.py b/olpcgames/gtkEvent.py index 6b20102..f2258ce 100755..100644 --- a/olpcgames/gtkEvent.py +++ b/olpcgames/gtkEvent.py @@ -105,7 +105,6 @@ class Translator(object): def do_expose_event(self, event, widget): """Handle exposure event (trigger redraw by gst)""" log.info( 'Expose event: %s', event ) - from olpcgames import eventwrap eventwrap.post( eventwrap.Event( eventwrap.pygame.VIDEOEXPOSE )) return True def do_resize_event( self, activity, event ): diff --git a/olpcgames/mesh.py b/olpcgames/mesh.py index 1ad4c43..9f5ff67 100755..100644 --- a/olpcgames/mesh.py +++ b/olpcgames/mesh.py @@ -151,11 +151,11 @@ DBUS_SERVICE = None ### NEW PYGAME EVENTS ### -CONNECT = olpcgames.CONNECT -PARTICIPANT_ADD = olpcgames.PARTICIPANT_ADD +CONNECT = olpcgames.CONNECT +PARTICIPANT_ADD = olpcgames.PARTICIPANT_ADD PARTICIPANT_REMOVE = olpcgames.PARTICIPANT_REMOVE -MESSAGE_UNI = olpcgames.MESSAGE_UNI -MESSAGE_MULTI = olpcgames.MESSAGE_MULTI +MESSAGE_UNI = olpcgames.MESSAGE_UNI +MESSAGE_MULTI = olpcgames.MESSAGE_MULTI # Private objects for useful purposes! @@ -198,10 +198,10 @@ def activity_shared(activity): log.debug('This is my activity: making a tube...') channel = tubes_chan[telepathy.CHANNEL_TYPE_TUBES] if hasattr( channel, 'OfferDBusTube' ): - id = channel.OfferDBusTube( + channel.OfferDBusTube( DBUS_SERVICE, {}) else: - id = channel.OfferTube( + channel.OfferTube( telepathy.TUBE_TYPE_DBUS, DBUS_SERVICE, {}) global connect_callback @@ -422,7 +422,7 @@ def _get_presence_service( ): name, path = pservice.get_preferred_connection() log.debug( ' Name = %s Path = %s', name, path ) except (TypeError,ValueError), err: - log.warn('Working in offline mode, cannot retrieve buddy information for %s: %s', handle, err ) + log.warn('Working in offline mode, cannot retrieve buddy information. %s', err) raise OfflineError( """Unable to retrieve buddy information, currently offline""" ) else: return pservice @@ -539,7 +539,7 @@ def get_participants(): log.debug( 'get_participants' ) try: return instance().ordered_bus_names[:] - except IndexError, err: + except IndexError: return [] # no participants yet, as we don't yet have a connection def dbus_get_object(handle, path, warning=True): diff --git a/olpcgames/pangofont.py b/olpcgames/pangofont.py index 441dfd1..05461bc 100755..100644 --- a/olpcgames/pangofont.py +++ b/olpcgames/pangofont.py @@ -48,9 +48,6 @@ import logging import pangocairo import pygame.rect, pygame.image import gtk -import struct -from pygame import surface -from pygame.font import Font from olpcgames import _cairoimage log = logging.getLogger( 'olpcgames.pangofont' ) @@ -300,7 +297,7 @@ Expanded Extra-Expanded Ultra-Expanded the widest width """ - fd = pango.FontDescription(name) + fd = pango.FontDescription(desc) if bold: fd.set_weight(pango.WEIGHT_BOLD) if italic: diff --git a/olpcgames/pausescreen.py b/olpcgames/pausescreen.py index 113a0ea..fe36a40 100755..100644 --- a/olpcgames/pausescreen.py +++ b/olpcgames/pausescreen.py @@ -100,7 +100,7 @@ def pauseScreen( overlaySVG=None ): # dim the screen and display the 'paused' message in the center. BLACK = (0,0,0) - WHITE = (255,255,255) + #WHITE = (255,255,255) dimmed = screen.copy() dimmed.set_alpha(128) screen.fill(BLACK) diff --git a/olpcgames/svgsprite.py b/olpcgames/svgsprite.py index ad247dd..70c3027 100755..100644 --- a/olpcgames/svgsprite.py +++ b/olpcgames/svgsprite.py @@ -46,7 +46,7 @@ class SVGSprite( sprite.Sprite ): """Render our SVG to a Pygame image""" import rsvg handle = rsvg.Handle( data = self.svg ) - originalSize = (width,height) + #originalSize = (width,height) scale = 1.0 hw,hh = handle.get_dimension_data()[:2] if hw and hh: diff --git a/olpcgames/textsprite.py b/olpcgames/textsprite.py index 7663630..7663630 100755..100644 --- a/olpcgames/textsprite.py +++ b/olpcgames/textsprite.py diff --git a/olpcgames/util.py b/olpcgames/util.py index 49a23b0..49a23b0 100755..100644 --- a/olpcgames/util.py +++ b/olpcgames/util.py diff --git a/olpcgames/video.py b/olpcgames/video.py index 032aa13..8d13794 100755..100644 --- a/olpcgames/video.py +++ b/olpcgames/video.py @@ -8,12 +8,8 @@ import logging log = logging.getLogger( 'olpcgames.video' ) #log.setLevel( logging.INFO ) import os -import signal import pygame -import weakref import olpcgames -from olpcgames import _gtkmain - import pygtk pygtk.require('2.0') import gtk @@ -82,7 +78,7 @@ class PygameWidget( object ): def __init__( self ): try: window_id = pygame.display.get_wm_info()['window'] - except KeyError, err: # pygame-ctypes... + except KeyError: # pygame-ctypes... window_id = int(os.environ['SDL_WINDOWID']) self.window_id = window_id self._imagesink = None @@ -147,14 +143,13 @@ if __name__ == "__main__": # Simple testing code... logging.basicConfig() log.setLevel( logging.DEBUG ) - from pygame import image,display, event - import pygame + def main(): - display.init() - maxX,maxY = display.list_modes()[0] - screen = display.set_mode( (maxX/3, maxY/3 ) ) + pygame.display.init() + maxX,maxY = pygame.display.list_modes()[0] + pygame.display.set_mode( (maxX/3, maxY/3 ) ) - display.flip() + pygame.display.flip() pgw = PygameWidget( ) p = Player( pgw, pipe_desc=Player.test_pipe_desc ) |