From aace9864c223e21689d10210de1d27a1879d34a1 Mon Sep 17 00:00:00 2001 From: Dorian Pula Date: Thu, 31 Jul 2014 21:46:11 -0400 Subject: [PATCH] Move app and game debug log into app module. Remove old Java log class. --- justcheckers/LoggingAndStatistics.java | 74 -------------------------- justcheckers/__init__.py | 2 +- justcheckers/app.py | 23 ++++++++ justcheckers/ui/menu_view.py | 25 +-------- justcheckers/ui/window.py | 9 +--- 5 files changed, 28 insertions(+), 105 deletions(-) delete mode 100644 justcheckers/LoggingAndStatistics.java diff --git a/justcheckers/LoggingAndStatistics.java b/justcheckers/LoggingAndStatistics.java deleted file mode 100644 index 7e87a8f..0000000 --- a/justcheckers/LoggingAndStatistics.java +++ /dev/null @@ -1,74 +0,0 @@ -/***************************************************************************** - GameLoop.java - Main controlling class for the justCheckers game. - ***************************************************************************** - - ***************************************************************************** - This file is part of justCheckers. - - justCheckers 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 3 of the License, or - (at your option) any later version. - - justCheckers is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY 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 justCheckers. If not, see . - *****************************************************************************/ - -package org.justcheckers.common; - -// TODO Resolve this with separation of various platform setups... -//import org.justcheckers.android.R; -// -//import android.app.Activity; -//import android.os.Build; -//import android.util.Log; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Functions for logging errors and gathering statistics. - * - * @author Dorian Pula - */ -public abstract class LoggingAndStatistics { - - /** - * Logs information about the program. Displays the game's header and - * relevant system properties at runtime. - */ - public static void logApplicationInfo(String gameVersion, String gameWebsite) { - - // TODO Fix -// String gameVersion = caller.getString(R.string.app_version); -// String gameWebsite = caller.getString(R.string.project_website); - String appInfo = "justCheckers -- Version:" + gameVersion - + " - Website: " + gameWebsite; - - // TODO Clean up... - Logger log = LoggerFactory.getLogger(LoggingAndStatistics.class); - log.info("ApplInfo", appInfo); - } - - /** - * Logs information about the device and system, the app is - * running on. - */ - public static void logDeviceAndSystemInfo() { - - // System properties. -// String sysList = "SDK version: " + Build.VERSION.RELEASE -// + " - API: " + Build.VERSION.SDK_INT -// + " - Device: " + Build.MANUFACTURER + " " + Build.MODEL; - // TODO Fix - String sysList = "FIXME"; - - Logger log = LoggerFactory.getLogger(LoggingAndStatistics.class); - log.info("DevSysInfo", sysList); - } - -} \ No newline at end of file diff --git a/justcheckers/__init__.py b/justcheckers/__init__.py index cce384d..0404d81 100644 --- a/justcheckers/__init__.py +++ b/justcheckers/__init__.py @@ -1 +1 @@ -__version__ = '0.3' +__version__ = '0.3.0' diff --git a/justcheckers/app.py b/justcheckers/app.py index 24ee5f6..2293ce3 100644 --- a/justcheckers/app.py +++ b/justcheckers/app.py @@ -17,20 +17,43 @@ # Please share and enjoy! # +import logging +import os import sys from PySide import QtGui +import justcheckers from justcheckers.ui.window import DesktopGameWindow +LOG = logging.getLogger(__name__) + + def main(): + """Main entry point into the app.""" app = QtGui.QApplication(sys.argv) + log_system_and_game_info() view = DesktopGameWindow() view.show() app.exec_() sys.exit() +def log_system_and_game_info(): + """Logs information about the game and system running the game.""" + LOG.info('justCheckers -- v{}'.format(justcheckers.__version__)) + + message = 'I am running on {os}.\nMy screen is {height}x{width}' + geometry = QtGui.QDesktopWidget().availableGeometry() + + os_sys = sys.platform + if sys.platform == 'posix': + os_name, _, _, _, os_arch = os.uname() + os_sys = '{name} {arch}'.format(name=os_name, arch=os_arch) + + LOG.info(message.format(os=os_sys, height=geometry.height(), width=geometry.width())) + + if __name__ == '__main__': main() diff --git a/justcheckers/ui/menu_view.py b/justcheckers/ui/menu_view.py index 717033c..e8d0cea 100644 --- a/justcheckers/ui/menu_view.py +++ b/justcheckers/ui/menu_view.py @@ -17,21 +17,14 @@ # Please share and enjoy! # -""" -Main window for the game. - -:copyright: Copyright 2013, Dorian Pula -:license: GPL v3+ -""" - -import os -import sys from PySide import QtCore from PySide import QtGui class MainMenuView(QtGui.QWidget): + """Main menu for the game.""" + # TODO Setup functional testing with PySide.QtTest def __init__(self): @@ -40,7 +33,6 @@ class MainMenuView(QtGui.QWidget): def setup_components(self): """Setup the components that make up the widget.""" - print(self.get_system_info()) self.new_game = QtGui.QPushButton('&New Game', self) self.open_game = QtGui.QPushButton('&Open Game', self) self.save_game = QtGui.QPushButton('&Save Game', self) @@ -63,19 +55,6 @@ class MainMenuView(QtGui.QWidget): widget_layout.addStretch() self.setLayout(widget_layout) - @staticmethod - def get_system_info(): - """Retrieve information about the system.""" - message = 'I am running on {os}.\nMy screen is {height}x{width}' - geometry = QtGui.QDesktopWidget().availableGeometry() - - os_sys = sys.platform - if sys.platform == 'posix': - os_name, _, _, _, os_arch = os.uname() - os_sys = '{name} {arch}'.format(name=os_name, arch=os_arch) - - return message.format(os=os_sys, height=geometry.height(), width=geometry.width()) - def exit_app(self): """Exits the application.""" QtCore.QCoreApplication.instance().exit() diff --git a/justcheckers/ui/window.py b/justcheckers/ui/window.py index 95cc3f7..7cfa2ed 100644 --- a/justcheckers/ui/window.py +++ b/justcheckers/ui/window.py @@ -17,13 +17,6 @@ # Please share and enjoy! # -""" -Main window for the game. - -:copyright: Copyright 2013, Dorian Pula -:license: GPL v3+ -""" - import os from PySide import QtGui @@ -32,6 +25,7 @@ from justcheckers.ui.menu_view import MainMenuView class DesktopGameWindow(QtGui.QMainWindow): + """Main window for the game.""" # TODO Setup functional testing with PySide.QtTest def __init__(self): @@ -45,6 +39,7 @@ class DesktopGameWindow(QtGui.QMainWindow): self.center() def add_backdrop(self): + """Adds a backdrop image to the game.""" tile = QtGui.QPixmap(self.path_to_asset('backdrop.jpg')) palette = QtGui.QPalette() palette.setBrush(QtGui.QPalette.Background, tile)