Use configured data dir for autosaves, not ~/.glchess

svn path=/trunk/; revision=6184
This commit is contained in:
Robert Ancell 2007-04-29 03:07:03 +00:00
parent a5cffd9cb1
commit 022148b59f
3 changed files with 9 additions and 26 deletions

View file

@ -1,3 +1,8 @@
2007-04-29 Robert Ancell <robert.ancell@gmail.com>
* Set more configuration defaults in case schema is missing (Bug #434097)
* Use configured data dir for autosaves, not ~/.glchess
2007-04-25 Robert Ancell <robert.ancell@gmail.com>
* Update dummy OpenGL scene to have correct method arguments (Bug #420730)

View file

@ -10,7 +10,9 @@ GLADE_DIR = os.path.join(APP_DATA_DIR, 'glchess')
BASE_DIR = os.path.join(APP_DATA_DIR, 'glchess')
LOCALEDIR = os.path.join(APP_DATA_DIR, 'locale')
DATA_DIR = os.path.expanduser('~/.gnome2/glchess/')
LOG_DIR = os.path.join(DATA_DIR, 'logs')
CONFIG_FILE = os.path.join(DATA_DIR, 'config.xml')
AUTOSAVE_FILE = os.path.join(DATA_DIR, 'autosave.pgn')
LOCAL_AI_CONFIG = os.path.join(DATA_DIR, 'ai.xml')
DOMAIN = 'gnome-games'

View file

@ -30,25 +30,6 @@ from defaults import *
import chess.pgn
class Config:
"""
"""
__directory = None
def __init__(self):
"""Constructor for a configuration object"""
self.__directory = os.path.expanduser('~/.glchess')
# Create the directory if it does not exist
if not os.path.exists(self.__directory):
os.mkdir(self.__directory)
else:
assert(os.path.isdir(self.__directory))
def getAutosavePath(self):
"""Get the path to the autosave file"""
return self.__directory + '/autosave.pgn'
class MovePlayer(game.ChessPlayer):
"""This class provides a pseudo-player to watch for piece movements"""
# The game to control
@ -1014,9 +995,6 @@ class UI(ui.UIFeedback):
class Application:
"""
"""
# The configuration
config = None
# The glChess UI
ui = None
@ -1042,8 +1020,6 @@ class Application:
self.ioHandlers = {}
self.networkConnections = {}
self.config = Config()
self.__detector = None#GameDetector(self)
self.ui = UI(self)
@ -1286,7 +1262,7 @@ class Application:
def __autoload(self):
"""Restore games from the autosave file"""
path = self.config.getAutosavePath()
path = AUTOSAVE_FILE
try:
p = chess.pgn.PGN(path)
@ -1317,7 +1293,7 @@ class Application:
if len(self.__games) == 0:
return
fname = self.config.getAutosavePath()
fname = AUTOSAVE_FILE
print 'Auto-saving to ' + fname + '...'
try: