From 1c313b7ffb70aaee9e7580e286f50b9b7df80050 Mon Sep 17 00:00:00 2001 From: Alan Aguiar Date: Mon, 06 Jan 2014 23:53:18 +0000 Subject: update olpcgames with pyflakes clean --- 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 @@ - - - - - - - - - - - - - - - - - - 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 ) -- cgit v0.9.1