diff options
author | Luke Faraone <luke@faraone.cc> | 2010-08-21 21:25:08 (GMT) |
---|---|---|
committer | Luke Faraone <luke@faraone.cc> | 2010-08-21 21:25:08 (GMT) |
commit | e2cab6f0ac6504ec1b55ae458812ff05837f7e98 (patch) | |
tree | 3ee2aae2135bc54d5e034b9ccd14d06720cfbec9 | |
parent | 3320de738b982ac8af9f9ea751b3dd0cb1db11db (diff) |
Handle the case of an unwritable configuration directory.
-rwxr-xr-x | turtleart.py | 11 |
1 files changed, 9 insertions, 2 deletions
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') |