From ad94595721d99360737ba12b7365e0e6f44f5b4c Mon Sep 17 00:00:00 2001 From: Storm dragon Date: Wed, 30 Mar 2016 18:21:53 -0400 Subject: [PATCH] Working (I hope), config writer. --- numnastics/storm_games.py | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/numnastics/storm_games.py b/numnastics/storm_games.py index bd263c8..6d69681 100755 --- a/numnastics/storm_games.py +++ b/numnastics/storm_games.py @@ -14,12 +14,17 @@ import requests import speechd import time -config = configparser.ConfigParser() +localConfig = configparser.ConfigParser() +globalConfig = configparser.ConfigParser() spd = speechd.Client() -#def write_config(config, path = gamePath + "/config"): - #with open(path, 'w') as configfile: - #config.write(configfile) +def write_config(writeGlobal = False): + if writeGlobal == False: + with open(gamePath, 'w') as configfile: + localConfig.write(configfile) + else: + with open(globalPath, 'w') as configfile: + globalConfig.write(configfile) def speak(text, interupt = True): if interupt == True: spd.cancel() @@ -32,10 +37,11 @@ def exit_game(): def initialize_gui(gameTitle): # Check for, and possibly create, storm-games path - global HOME + global globalPath global gamePath - HOME = BaseDirectory.xdg_config_home + "/storm-games" - gamePath = HOME + "/" + str.lower(str.replace(gameTitle, " ", "-")) + globalPath = BaseDirectory.xdg_config_home + "/storm-games" + gamePath = globalPath + "/" + str.lower(str.replace(gameTitle, " ", "-") + "config") + globalPath = globalPath + "/config" if not os.path.exists(gamePath): os.makedirs(gamePath) # Seed the random generator to the clock random.seed()