/usr/share/pyshared/freevo/games/game.py is in python-freevo 1.9.2b2-4.2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 | # -*- coding: iso-8859-1 -*-
# -----------------------------------------------------------------------
# Freevo module to run games.
# -----------------------------------------------------------------------
# $Id: game.py 11905 2011-11-14 21:54:46Z adam $
#
# Notes:
# Todo:
#
# -----------------------------------------------------------------------
# Freevo - A Home Theater PC framework
# Copyright (C) 2002 Krister Lagerstrom, et al.
# Please see the file freevo/Docs/CREDITS for a complete list of authors.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MER-
# CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# -----------------------------------------------------------------------
import logging
logger = logging.getLogger("freevo.games.game")
import sys
import random
import time, os, glob
import string, popen2, fcntl, select, struct
import config # Configuration handler. reads config file.
import util # Various utilities
import childapp # Handle child applications
import menu # The menu widget class
import osd # The OSD class, used to communicate with the OSD daemon
import rc # The RemoteControl class.
import plugin
import event as em
TRUE = 1
FALSE = 0
# Setting up the default objects:
osd = osd.get_singleton()
# Module variable that contains an initialized Game() object
_singleton = None
def get_singleton():
_debug_('get_singleton()', 2)
global _singleton
# One-time init
if _singleton == None:
_singleton = Game()
return _singleton
class Game:
def __init__(self):
_debug_('Game.__init__()', 2)
self.mode = None
self.event_context = 'games'
def play(self, item, menuw):
_debug_('play(item=%r, menuw=%r)' % (item, menuw), 2)
self.item = item
self.filename = item.filename
self.command = item.command
self.mode = item.mode
self.menuw = menuw
if not os.path.isfile(self.filename):
osd.clearscreen()
osd.drawstring(_('File "%s" not found!') % self.filename, 30, 280)
osd.update()
time.sleep(2.0)
self.menuw.refresh()
return 0
if plugin.getbyname('MIXER'):
plugin.getbyname('MIXER').reset()
if plugin.is_active('joy'):
try:
plugin.getbyname('JOY').disable()
except Exception, why:
_debug_('getbyname("JOY"): %s' % why, DWARNING)
_debug_('Game.play(): Starting thread, cmd=%s' % self.command)
self.app=GameApp(self.command)
rc.suspend()
rc.add_app(self)
def stop(self):
_debug_('stop()', 2)
self.app.stop()
rc.remove_app(self)
rc.resume()
if plugin.is_active('joy'):
try:
plugin.getbyname('JOY').enable()
except Exception, why:
_debug_('getbyname("JOY"): %s' % why, DWARNING)
def eventhandler(self, event, menuw=None):
_debug_('eventhandler(event%r, menuw=%r)' % (event, menuw), 2)
return self.item.eventhandler(event, self.menuw)
# ======================================================================
class GameApp(childapp.ChildApp2):
def stop_event(self):
_debug_('stop_event()', 2)
return em.STOP
|