From e2cab6f0ac6504ec1b55ae458812ff05837f7e98 Mon Sep 17 00:00:00 2001 From: Luke Faraone Date: Sat, 21 Aug 2010 21:25:08 +0000 Subject: Handle the case of an unwritable configuration directory. --- (limited to 'turtleart.py') diff --git a/turtleart.py b/turtleart.py index c2933f1..faf5b96 100755 --- a/turtleart.py +++ b/turtleart.py @@ -28,6 +28,7 @@ import getopt import sys import os import os.path +import cStringIO import errno try: @@ -164,8 +165,14 @@ class TurtleMain(): except IOError: # Opening the config file failed # We'll assume it needs to be created - mkdir_p(CONFIG_HOME) - data_file = open(os.path.join(CONFIG_HOME, 'turtleartrc'), 'a+') + try: + mkdir_p(CONFIG_HOME) + data_file = open(os.path.join(CONFIG_HOME, 'turtleartrc'), 'a+') + except IOError: + # We can't write to the configuration file, use + # a faux file that will persist for the length of + # the session. + data_file = cStringIO.StringIO() data_file.write(str(50) + '\n') data_file.write(str(50) + '\n') data_file.write(str(800) + '\n') -- cgit v0.9.1