From cde5aa7f73632c1af89170decbd2589e743d3f07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Magimel?= Date: Sat, 25 Nov 2017 17:32:11 +0100 Subject: [PATCH] Log: update the fretwork log module The idea is to use the python logging module to manage logs. --- FoFiX.py | 24 ++++++++++--------- fofix/core/Config.py | 4 +++- fofix/core/Data.py | 7 ++++-- fofix/core/GameEngine.py | 8 +++---- fofix/core/Image.py | 7 ++++-- fofix/core/Input.py | 9 ++++++- fofix/core/Language.py | 7 ++++-- fofix/core/Microphone.py | 6 +++-- fofix/core/Mod.py | 7 ++++-- fofix/core/Player.py | 8 +++++-- fofix/core/Resource.py | 6 ++++- fofix/core/Settings.py | 7 ++++-- fofix/core/Shader.py | 9 +++++-- fofix/core/Texture.py | 4 +++- fofix/core/Theme.py | 6 +++-- fofix/core/Video.py | 7 ++++-- fofix/core/View.py | 7 +++--- fofix/game/Credits.py | 5 +++- fofix/game/Debug.py | 5 ++-- fofix/game/Dialogs.py | 9 ++++--- fofix/game/GameResultsScene.py | 10 ++++---- fofix/game/MainMenu.py | 5 +++- fofix/game/Menu.py | 7 ++++-- fofix/game/Scorekeeper.py | 5 +++- fofix/game/SongChoosingScene.py | 8 ++++--- fofix/game/guitarscene/GuitarScene.py | 8 ++++--- fofix/game/guitarscene/Neck.py | 7 ++++-- fofix/game/guitarscene/Rockmeter.py | 6 +++-- fofix/game/guitarscene/Stage.py | 5 +++- fofix/game/guitarscene/instruments/Drum.py | 6 +++-- fofix/game/guitarscene/instruments/Guitar.py | 7 ++++-- .../guitarscene/instruments/Instrument.py | 6 +++-- .../game/guitarscene/instruments/Vocalist.py | 7 ++++-- fofix/game/song/song.py | 5 +++- fofix/tests/__init__.py | 4 ++-- 35 files changed, 168 insertions(+), 80 deletions(-) diff --git a/FoFiX.py b/FoFiX.py index c18543c74..db03aaebd 100644 --- a/FoFiX.py +++ b/FoFiX.py @@ -36,6 +36,8 @@ import platform import subprocess import atexit +import logging + def run_command(command): command = command.split(' ') @@ -120,12 +122,13 @@ def cmd_args(): if os.name == "posix": # Under MacOS X, put the logs in ~/Library/Logs if os.uname()[0] == "Darwin": - logFile = open(os.path.expanduser('~/Library/Logs/%s.log' % Version.PROGRAM_UNIXSTYLE_NAME), 'w') + logfile = os.path.expanduser('~/Library/Logs/%s.log' % Version.PROGRAM_UNIXSTYLE_NAME) else: # GNU/Linux et al. - logFile = VFS.open('/userdata/%s.log' % Version.PROGRAM_UNIXSTYLE_NAME, 'w') + logfile = VFS.resolveWrite('/userdata/%s.log' % Version.PROGRAM_UNIXSTYLE_NAME) else: - logFile = VFS.open('/userdata/%s.log' % Version.PROGRAM_UNIXSTYLE_NAME, 'w') -log.setLogfile(logFile) + logfile = VFS.resolveWrite('/userdata/%s.log' % Version.PROGRAM_UNIXSTYLE_NAME) +log.configure(logfile) +logger = logging.getLogger(__name__) fretworkRequired = (0, 2, 0) reqVerStr = '.'.join([str(i) for i in fretworkRequired]) @@ -220,7 +223,7 @@ def load_config(configPath): return config def restart(self): - log.info("Restarting.") + logger.info("Restarting.") self.engine.audio.close() self.restartRequested = True @@ -233,7 +236,7 @@ def run(self): try: vidPlayer = VideoLayer(self.engine, vidSource, cancellable=True) except (IOError, VideoPlayerError): - log.error("Error loading intro video:") + logger.error("Error loading intro video:") else: vidPlayer.play() self.engine.view.pushLayer(vidPlayer) @@ -253,7 +256,7 @@ def run(self): while self.engine.run(): pass except KeyboardInterrupt: - log.info("Left mainloop due to KeyboardInterrupt.") + logger.info("Left mainloop due to KeyboardInterrupt.") # don't reraise # Restart the program if the engine is asking that we do so. @@ -276,8 +279,8 @@ def run(self): except (KeyboardInterrupt, SystemExit): raise except Exception: - log.error("Terminating due to unhandled exception: ") - _logname = os.path.abspath(log.logFile.name) + logger.error("Terminating due to unhandled exception: ") + _logname = os.path.abspath(logfile) _errmsg = "%s\n\n%s\n%s\n%s\n%s" % ( _("Terminating due to unhandled exception:"), traceback.format_exc(), @@ -290,10 +293,9 @@ def run(self): import win32api import win32con if win32api.MessageBox(0, "%s\n\n%s" % (_errmsg, _("Open the logfile now?")), "%s %s" % (Version.PROGRAM_NAME, Version.version()), win32con.MB_YESNO|win32con.MB_ICONSTOP) == win32con.IDYES: - log.logFile.close() os.startfile(_logname) if hasattr(sys, 'frozen'): sys.exit(1) # don't reraise if py2exe'd so the "Errors occurred" box won't appear after this and confuse the user as to which logfile we actually want else: - print >>sys.stderr, _errmsg + logger.error(_errmsg) raise diff --git a/fofix/core/Config.py b/fofix/core/Config.py index 1205ed251..d1db43766 100644 --- a/fofix/core/Config.py +++ b/fofix/core/Config.py @@ -23,15 +23,17 @@ # MA 02110-1301, USA. # ##################################################################### +import logging import os import StringIO from ConfigParser import RawConfigParser -from fretwork import log from fretwork.unicode import utf8, unicodify from fofix.core import VFS + +log = logging.getLogger(__name__) config = None prototype = {} diff --git a/fofix/core/Data.py b/fofix/core/Data.py index ee0e8d20f..d71c90a1c 100644 --- a/fofix/core/Data.py +++ b/fofix/core/Data.py @@ -23,20 +23,23 @@ # MA 02110-1301, USA. # ##################################################################### +import logging import os import glob import random -from fretwork import log from fretwork.audio import Sound from fofix.core.Font import Font from fofix.core.Image import ImgDrawing - from fofix.core import Config from fofix.core import Version from fofix.core import Player + +log = logging.getLogger(__name__) + + # these constants define a few customized letters in the default font # MFH - with the new simplified Font.py, no more custom glyphs... let's do # a simple replacement here for now... diff --git a/fofix/core/GameEngine.py b/fofix/core/GameEngine.py index 96d4b0d13..954e22246 100644 --- a/fofix/core/GameEngine.py +++ b/fofix/core/GameEngine.py @@ -37,15 +37,14 @@ import os import sys import imp +import logging -from fretwork import log from fretwork.audio import Audio from fretwork.task import TaskEngine from fretwork.timer import FpsTimer from fofix.core.constants import * from fofix.core.Video import Video - from fofix.core.View import View from fofix.core.Input import Input, KeyListener, SystemEventListener from fofix.core.Resource import Resource @@ -55,7 +54,6 @@ from fofix.core.Theme import Theme from fofix.core.Shader import shaders from fofix.core.Image import drawImage - from fofix.core import cmgl from fofix.core import Config from fofix.core import ConfigDefs @@ -63,10 +61,12 @@ from fofix.core import Player from fofix.core import Mod from fofix.game import Dialogs - from fofix.game.World import World from fofix.game.Debug import DebugLayer + +log = logging.getLogger(__name__) + # evilynux - Grab name and version from Version class. version = "%s v%s" % ( Version.PROGRAM_NAME, Version.version() ) diff --git a/fofix/core/Image.py b/fofix/core/Image.py index 18a2a3cca..0644c652f 100644 --- a/fofix/core/Image.py +++ b/fofix/core/Image.py @@ -21,18 +21,21 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, # # MA 02110-1301, USA. # ##################################################################### + from __future__ import with_statement +import logging import numpy as np from PIL import Image from OpenGL.GL import * -from fretwork import log - from fofix.core.Texture import Texture from fofix.core.constants import * from fofix.core import cmgl + +log = logging.getLogger(__name__) + #stump: the last few stubs of DummyAmanith.py are inlined here since this # is the only place in the whole program that uses it now that we've pruned # the dead SVG code. diff --git a/fofix/core/Input.py b/fofix/core/Input.py index a8f089a80..67139d895 100644 --- a/fofix/core/Input.py +++ b/fofix/core/Input.py @@ -22,8 +22,11 @@ # MA 02110-1301, USA. # ##################################################################### +import logging import pygame + +log = logging.getLogger(__name__) haveMidi = False try: @@ -32,7 +35,6 @@ except ImportError: haveMidi = False -from fretwork import log from fretwork.audio import Music from fretwork.task import Task @@ -40,6 +42,7 @@ from fofix.core import Player from fofix.core import Config + class KeyListener(object): def keyPressed(self, key, unicode): pass @@ -53,6 +56,7 @@ def lostFocus(self): def exitRequested(self): pass + class MouseListener(object): def mouseButtonPressed(self, button, pos): pass @@ -63,6 +67,7 @@ def mouseButtonReleased(self, button, pos): def mouseMoved(self, pos, rel): pass + class SystemEventListener(object): def screenResized(self, size): pass @@ -76,8 +81,10 @@ def musicFinished(self): def quit(self): pass + MusicFinished = pygame.USEREVENT + class Input(Task): def __init__(self): diff --git a/fofix/core/Language.py b/fofix/core/Language.py index 660b0a642..fabd46400 100644 --- a/fofix/core/Language.py +++ b/fofix/core/Language.py @@ -19,20 +19,23 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, # # MA 02110-1301, USA. # ##################################################################### + from __future__ import print_function from __future__ import division from __future__ import absolute_import import gettext import glob +import logging import os -from fretwork import log - from fofix.core import Version from fofix.core import Config +log = logging.getLogger(__name__) + + def getAvailableLanguages(): return [os.path.basename(l).capitalize().replace(".mo", "").replace("_", " ") for l in glob.glob(os.path.join(Version.dataPath(), "translations", "*.mo"))] diff --git a/fofix/core/Microphone.py b/fofix/core/Microphone.py index 195979469..a4370ba76 100644 --- a/fofix/core/Microphone.py +++ b/fofix/core/Microphone.py @@ -21,15 +21,17 @@ # MA 02110-1301, USA. # ##################################################################### +import logging import math -import numpy as np -from fretwork import log +import numpy as np from fretwork.task import Task from fretwork.audio import MicrophonePassthroughStream from fofix.core.Language import _ +log = logging.getLogger(__name__) + try: import pyaudio from fofix.core import pypitch diff --git a/fofix/core/Mod.py b/fofix/core/Mod.py index ef5a49cab..440920c45 100644 --- a/fofix/core/Mod.py +++ b/fofix/core/Mod.py @@ -20,14 +20,17 @@ # MA 02110-1301, USA. # ##################################################################### +import logging import os -from fretwork import log - from fofix.core.Language import _ from fofix.core import Config from fofix.core import Theme + +log = logging.getLogger(__name__) + + def _getModPath(engine): return engine.resource.fileName("mods") diff --git a/fofix/core/Player.py b/fofix/core/Player.py index 54b4e8cfb..09c4092af 100644 --- a/fofix/core/Player.py +++ b/fofix/core/Player.py @@ -24,9 +24,9 @@ # MA 02110-1301, USA. # ##################################################################### -import pygame +import logging -from fretwork import log +import pygame from fofix.core.Language import _ from fofix.core import Microphone #stump @@ -34,6 +34,10 @@ from fofix.game import song from fofix.core import VFS + +log = logging.getLogger(__name__) + + class ConfigOption: def __init__(self, id, text): self.id = id diff --git a/fofix/core/Resource.py b/fofix/core/Resource.py index c25e07f52..7a6cdc571 100644 --- a/fofix/core/Resource.py +++ b/fofix/core/Resource.py @@ -22,6 +22,7 @@ # MA 02110-1301, USA. # ##################################################################### +import logging import os import sys import time @@ -30,13 +31,16 @@ from Queue import Queue, Empty from threading import Thread, BoundedSemaphore -from fretwork import log from fretwork.task import Task from fofix.core.VFS import getWritableResourcePath from fofix.core import Version from fofix.core import Config + +log = logging.getLogger(__name__) + + class Loader(Thread): def __init__(self, target, name, function, resultQueue, loaderSemaphore, onLoad = None, onCancel = None): Thread.__init__(self) diff --git a/fofix/core/Settings.py b/fofix/core/Settings.py index bec826874..bd5b1129c 100644 --- a/fofix/core/Settings.py +++ b/fofix/core/Settings.py @@ -29,12 +29,11 @@ # MA 02110-1301, USA. # ##################################################################### +import logging import os import pygame -from fretwork import log - from fofix.core.Language import _ from fofix.core.View import BackgroundLayer from fofix.core.Input import KeyListener @@ -47,6 +46,10 @@ from fofix.core import Mod from fofix.core import VFS + +log = logging.getLogger(__name__) + + class ConfigChoice(Menu.Choice): def __init__(self, engine, config, section, option, autoApply = False, isQuickset = 0): self.engine = engine diff --git a/fofix/core/Shader.py b/fofix/core/Shader.py index 4a91ae898..d1465f328 100644 --- a/fofix/core/Shader.py +++ b/fofix/core/Shader.py @@ -20,6 +20,7 @@ # MA 02110-1301, USA. # ##################################################################### +import logging import os import sys import time @@ -34,20 +35,24 @@ from OpenGL.GL.ARB.multitexture import * from OpenGL.GL.EXT.texture3D import * -from fretwork import log - from fofix.core.constants import isTrue from fofix.core import Config from fofix.core import Version + +log = logging.getLogger(__name__) + + class ShaderCompilationError(Exception): pass + if sys.platform == 'darwin': GL_TEXTURE_3D_EXT = GL_TEXTURE_3D GL_TEXTURE_WRAP_R_EXT = GL_TEXTURE_WRAP_R glTexImage3DEXT = glTexImage3D + # main class for shaders library class ShaderList: def __init__(self): diff --git a/fofix/core/Texture.py b/fofix/core/Texture.py index 62b7ccfeb..f448e9d1e 100644 --- a/fofix/core/Texture.py +++ b/fofix/core/Texture.py @@ -21,13 +21,15 @@ ##################################################################### from __future__ import division +import logging import pygame from PIL import Image from OpenGL.GL import * from OpenGL.GLU import * -from fretwork import log + +log = logging.getLogger(__name__) class TextureException(Exception): diff --git a/fofix/core/Theme.py b/fofix/core/Theme.py index e97cbcec4..c13dddeba 100644 --- a/fofix/core/Theme.py +++ b/fofix/core/Theme.py @@ -23,6 +23,7 @@ # MA 02110-1301, USA. # ##################################################################### +import logging import os import sys import imp @@ -31,8 +32,6 @@ from OpenGL.GL import * from OpenGL.GLU import * - -from fretwork import log from fretwork.task import Task from fofix.core import Version @@ -42,6 +41,9 @@ from fofix.core.Image import drawImage from fofix.core.constants import * + +log = logging.getLogger(__name__) + #Theme Constants. GUITARTYPES = [0, 1, 4] DRUMTYPES = [2, 3] diff --git a/fofix/core/Video.py b/fofix/core/Video.py index 5fa2cfcdc..7e66d99d4 100644 --- a/fofix/core/Video.py +++ b/fofix/core/Video.py @@ -20,6 +20,7 @@ # MA 02110-1301, USA. # ##################################################################### +import logging import os import struct @@ -28,10 +29,12 @@ from OpenGL.GL import * from OpenGL.GL.ARB.multisample import * -from fretwork import log - from fofix.core.Language import _ + +log = logging.getLogger(__name__) + + class Video: def __init__(self, caption = "Game", icon = None): self.screen = None diff --git a/fofix/core/View.py b/fofix/core/View.py index d12e34e67..0ab7400b8 100644 --- a/fofix/core/View.py +++ b/fofix/core/View.py @@ -22,16 +22,17 @@ ##################################################################### from __future__ import division +import logging from OpenGL.GL import * from contextlib import contextmanager - import numpy as np - -from fretwork import log from fretwork.task import Task +log = logging.getLogger(__name__) + + class Layer(Task): def __getattr__(self, name): #for new out-themed rendering if name.startswith("img_"): #rather than try-except, just expect None on no image. diff --git a/fofix/game/Credits.py b/fofix/game/Credits.py index d0dd4acb3..41db87406 100644 --- a/fofix/game/Credits.py +++ b/fofix/game/Credits.py @@ -24,11 +24,11 @@ ##################################################################### from __future__ import with_statement +import logging import os import sys from OpenGL.GL import OpenGL, glColor4f, glTranslatef -from fretwork import log import pygame from fofix.core import Config @@ -42,6 +42,9 @@ from fofix.core.constants import * +log = logging.getLogger(__name__) + + class Element: """A basic element in the credits scroller.""" diff --git a/fofix/game/Debug.py b/fofix/game/Debug.py index d208c9d7d..a8d43a84d 100644 --- a/fofix/game/Debug.py +++ b/fofix/game/Debug.py @@ -23,17 +23,16 @@ ##################################################################### from __future__ import with_statement - import gc +import logging import threading from OpenGL.GL import glColor3f -from fretwork import log - from fofix.core.View import Layer +log = logging.getLogger(__name__) class DebugLayer(Layer): diff --git a/fofix/game/Dialogs.py b/fofix/game/Dialogs.py index de2649a76..e7cd3ca74 100644 --- a/fofix/game/Dialogs.py +++ b/fofix/game/Dialogs.py @@ -31,13 +31,12 @@ from __future__ import with_statement import fnmatch +import logging import math import os import pygame from OpenGL.GL import * - -from fretwork import log from fretwork.unicode import unicodify from fofix.core.View import Layer, BackgroundLayer @@ -51,7 +50,11 @@ from fofix.core import Player from fofix.core import Config -#MFH - for loading phrases + +log = logging.getLogger(__name__) + + +# for loading phrases def wrapCenteredText(font, pos, text, rightMargin = 1.0, scale = 0.002, visibility = 0.0, linespace = 1.0, allowshadowoffset = False, shadowoffset = (.0022, .0005)): """ Wrap a piece of text inside given margins. diff --git a/fofix/game/GameResultsScene.py b/fofix/game/GameResultsScene.py index e4e385513..83803f56d 100644 --- a/fofix/game/GameResultsScene.py +++ b/fofix/game/GameResultsScene.py @@ -31,20 +31,18 @@ import binascii import hashlib -import pygame +import logging import random import urllib import os -import cerealizer from OpenGL.GL import * - -from fretwork import log from fretwork.audio import Sound +import cerealizer +import pygame from fofix.core.Image import drawImage from fofix.core.Scene import Scene - from fofix.core.constants import * from fofix.core.Language import _ from fofix.game.Menu import Menu @@ -54,6 +52,8 @@ from fofix.core import VFS +log = logging.getLogger(__name__) + class GameResultsScene(Scene): def __init__(self, engine, libraryName, songName, scores = None, coOpType = False, careerMode = False): diff --git a/fofix/game/MainMenu.py b/fofix/game/MainMenu.py index d9014b0d0..da2cc0f79 100644 --- a/fofix/game/MainMenu.py +++ b/fofix/game/MainMenu.py @@ -24,11 +24,11 @@ # MA 02110-1301, USA. # ##################################################################### +import logging import os import random import string -from fretwork import log from fretwork.audio import Music from fofix.core.View import BackgroundLayer @@ -43,6 +43,9 @@ from fofix.core import Settings +log = logging.getLogger(__name__) + + class MainMenu(BackgroundLayer): def __init__(self, engine): self.engine = engine diff --git a/fofix/game/Menu.py b/fofix/game/Menu.py index fb90ae924..699c1dcae 100644 --- a/fofix/game/Menu.py +++ b/fofix/game/Menu.py @@ -24,14 +24,13 @@ from __future__ import with_statement +import logging import math import os from OpenGL.GL import * import pygame -from fretwork import log - from fofix.core.Input import KeyListener from fofix.core.Image import drawImage from fofix.core.View import Layer @@ -39,6 +38,10 @@ from fofix.core import Data from fofix.core.constants import * + +log = logging.getLogger(__name__) + + class Choice: def __init__(self, text, callback, name = None, values = None, valueIndex = 0, append_submenu_char = True, tipText = None): self.text = unicode(text) diff --git a/fofix/game/Scorekeeper.py b/fofix/game/Scorekeeper.py index 16efd2203..33f9efa61 100644 --- a/fofix/game/Scorekeeper.py +++ b/fofix/game/Scorekeeper.py @@ -29,12 +29,15 @@ # MA 02110-1301, USA. # ##################################################################### -from fretwork import log +import logging from fofix.core.Language import _ from fofix.game import song from fofix.core import Config + +log = logging.getLogger(__name__) + HANDICAPS = [.75, 1.0, .8, .9, .75, .8, 1.05, 1.1, 1.03, 1.02, 1.01, .95, .9, .85, .7, .95, 0.0, .5, .7, .7] HANDICAP_NAMES = [_("Auto Kick Bass"), _("Medium Assist Mode"), _("Easy Assist Mode"), _("Jurgen Played!"), \ _("Effects Saved SP"), _("All Tapping"), _("HOPO Frequency: Most"), _("HOPO Frequency: Even More"), \ diff --git a/fofix/game/SongChoosingScene.py b/fofix/game/SongChoosingScene.py index 6dab2d5e0..f54223905 100644 --- a/fofix/game/SongChoosingScene.py +++ b/fofix/game/SongChoosingScene.py @@ -24,12 +24,11 @@ from __future__ import with_statement +import logging import os import time -import pygame - -from fretwork import log +import pygame from fofix.core.Scene import Scene from fofix.core.Settings import ConfigChoice, ActiveConfigChoice @@ -45,6 +44,9 @@ from fofix.game.Menu import Menu from fofix.core.constants import * + +log = logging.getLogger(__name__) + PRACTICE = 1 CAREER = 2 diff --git a/fofix/game/guitarscene/GuitarScene.py b/fofix/game/guitarscene/GuitarScene.py index 17c3badc2..d3183044f 100644 --- a/fofix/game/guitarscene/GuitarScene.py +++ b/fofix/game/guitarscene/GuitarScene.py @@ -33,13 +33,11 @@ from __future__ import with_statement from math import degrees, atan +import logging import os import OpenGL.GL as gl - -from fretwork import log - from fofix.game.song import Note, TextEvent, PictureEvent, loadSong, Bars, VocalPhrase from fofix.core.Player import STAR, KILL, CANCEL, KEY1A from fofix.game.guitarscene.instruments import * @@ -58,6 +56,10 @@ import random + +log = logging.getLogger(__name__) + + # The plan with this is to move gamemodes to being subclasses of this class BandPlayBaseScene(Scene): def __init__(self, engine, libraryName, songName): diff --git a/fofix/game/guitarscene/Neck.py b/fofix/game/guitarscene/Neck.py index 7aad84fb5..2071aa5b7 100644 --- a/fofix/game/guitarscene/Neck.py +++ b/fofix/game/guitarscene/Neck.py @@ -21,19 +21,22 @@ # MA 02110-1301, USA. # ##################################################################### +import logging import os import random import OpenGL.GL as gl import numpy as np -from fretwork import log - from fofix.core.Shader import shaders, mixColors from fofix.game.song import Bars, \ MarkerNote, SP_MARKING_NOTE, TK_GUITAR_SOLOS from fofix.core import cmgl + +log = logging.getLogger(__name__) + + class Neck: def __init__(self, engine, instrument, playerObj): diff --git a/fofix/game/guitarscene/Rockmeter.py b/fofix/game/guitarscene/Rockmeter.py index 2d0005073..802b182ba 100644 --- a/fofix/game/guitarscene/Rockmeter.py +++ b/fofix/game/guitarscene/Rockmeter.py @@ -30,14 +30,13 @@ from math import * import locale +import logging import imp import os from PIL import Image, ImageDraw import OpenGL.GL as gl -from fretwork import log - from fofix.core.LinedConfigParser import LinedConfigParser from fofix.core.Theme import halign, valign from fofix.core.Image import ImgDrawing @@ -47,6 +46,9 @@ from fofix.core import Version from fofix.core import cmgl + +log = logging.getLogger(__name__) + #these are the variables for setting the alignment of text and images #when setting them up in the rockmeter.ini you do not have #to put it in all caps, the code will take care of that diff --git a/fofix/game/guitarscene/Stage.py b/fofix/game/guitarscene/Stage.py index 1c1ec7f23..cc82b96a3 100644 --- a/fofix/game/guitarscene/Stage.py +++ b/fofix/game/guitarscene/Stage.py @@ -26,11 +26,11 @@ from __future__ import with_statement +import logging import random import math import os -from fretwork import log import OpenGL.GL as gl from fofix.core.Image import drawImage @@ -42,6 +42,9 @@ from fofix.game.guitarscene import Rockmeter +log = logging.getLogger(__name__) + + class Layer(object): """ A graphical stage layer that can have a number of animation effects associated with it. diff --git a/fofix/game/guitarscene/instruments/Drum.py b/fofix/game/guitarscene/instruments/Drum.py index b26ad49eb..55174e913 100644 --- a/fofix/game/guitarscene/instruments/Drum.py +++ b/fofix/game/guitarscene/instruments/Drum.py @@ -26,14 +26,13 @@ # MA 02110-1301, USA. # ##################################################################### +import logging import os import math import numpy as np import OpenGL.GL as gl -from fretwork import log - from fofix.game.guitarscene.instruments.Instrument import Instrument from fofix.game.guitarscene.Neck import Neck from fofix.game.song import Note, Tempo @@ -42,6 +41,9 @@ from fofix.core.Mesh import Mesh from fofix.core import cmgl + +log = logging.getLogger(__name__) + #Normal guitar key color order: Green, Red, Yellow, Blue, Orange #Drum fret color order: Red, Yellow, Blue, Green #actual drum note numbers: diff --git a/fofix/game/guitarscene/instruments/Guitar.py b/fofix/game/guitarscene/instruments/Guitar.py index 2058bab68..72ff6d9ec 100644 --- a/fofix/game/guitarscene/instruments/Guitar.py +++ b/fofix/game/guitarscene/instruments/Guitar.py @@ -28,14 +28,13 @@ ##################################################################### from copy import deepcopy +import logging import math import os import OpenGL.GL as gl import numpy as np -from fretwork import log - from fofix.game.guitarscene.instruments.Instrument import Instrument from fofix.game.guitarscene.Neck import Neck from fofix.game.song import Note, Tempo @@ -44,6 +43,10 @@ from fofix.core.Mesh import Mesh from fofix.core import cmgl + +log = logging.getLogger(__name__) + + class Guitar(Instrument): def __init__(self, engine, playerObj, scene, player = 0, bass = False): super(Guitar, self).__init__(engine, playerObj, scene, player=player) diff --git a/fofix/game/guitarscene/instruments/Instrument.py b/fofix/game/guitarscene/instruments/Instrument.py index c36e458ae..8e204d923 100644 --- a/fofix/game/guitarscene/instruments/Instrument.py +++ b/fofix/game/guitarscene/instruments/Instrument.py @@ -20,14 +20,13 @@ # MA 02110-1301, USA. # ##################################################################### +import logging import math import os import OpenGL.GL as gl import numpy as np -from fretwork import log - from fofix.game.song import Note, Tempo, \ MarkerNote, FREESTYLE_MARKING_NOTE from fofix.core.Image import draw3Dtex @@ -36,6 +35,9 @@ from fofix.core import cmgl +log = logging.getLogger(__name__) + + class Instrument(object): def __init__(self, engine, playerObj, scene, player = 0): self.engine = engine diff --git a/fofix/game/guitarscene/instruments/Vocalist.py b/fofix/game/guitarscene/instruments/Vocalist.py index 20e2dec1e..a665fa958 100644 --- a/fofix/game/guitarscene/instruments/Vocalist.py +++ b/fofix/game/guitarscene/instruments/Vocalist.py @@ -22,23 +22,26 @@ ##################################################################### from random import random +import logging import os from PIL import Image, ImageDraw import OpenGL.GL as gl import numpy as np -from fretwork import log - from fofix.core.Microphone import Microphone from fofix.core.Image import ImgDrawing from fofix.game.song import VocalNote from fofix.core.constants import * from fofix.core.Language import _ from fofix.core import cmgl + + +log = logging.getLogger(__name__) diffMod = {0: 1.4, 1: 1.6, 2: 1.75, 3: 1.9} baseScores = {0: 1000, 1: 800, 2: 400, 3: 200} + class Vocalist: def __init__(self, engine, playerObj, scene, player = 0): self.engine = engine diff --git a/fofix/game/song/song.py b/fofix/game/song/song.py index c0119be66..ff4cd6a55 100644 --- a/fofix/game/song/song.py +++ b/fofix/game/song/song.py @@ -29,13 +29,13 @@ import copy import glob import hashlib +import logging import os import random import re import time import urllib -from fretwork import log from fretwork import midi from fretwork.audio import StreamingSound from fretwork.unicode import utf8 @@ -50,6 +50,9 @@ from fofix.game.song.songconstants import * +log = logging.getLogger(__name__) + + # code for adding tracks, inside song.py: # self.song.eventTracks[TK_SCRIPT].addEvent(self.abs_time(), event) #MFH - add an event to the script.txt track # self.song.eventTracks[TK_SECTIONS].addEvent(self.abs_time(), event) #MFH - add an event to the sections track diff --git a/fofix/tests/__init__.py b/fofix/tests/__init__.py index 6b461faf6..57c26f675 100644 --- a/fofix/tests/__init__.py +++ b/fofix/tests/__init__.py @@ -4,5 +4,5 @@ # set log file -fp = tempfile.TemporaryFile() -log.setLogfile(fp) +fp = tempfile.NamedTemporaryFile(delete=True) +log.configure(fp.name)