Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/turtleart.py
diff options
context:
space:
mode:
authorLuke Faraone <luke@faraone.cc>2010-08-20 19:35:28 (GMT)
committer Luke Faraone <luke@faraone.cc>2010-08-20 19:35:28 (GMT)
commit3320de738b982ac8af9f9ea751b3dd0cb1db11db (patch)
treef4fb7a590894347849f71ecde7bb62aae0848e5a /turtleart.py
parent8f172ca9977b70eb68472a17e40e3cc1db79b163 (diff)
Handle issue if the CONFIG_HOME isn't already created.
Diffstat (limited to 'turtleart.py')
-rwxr-xr-xturtleart.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/turtleart.py b/turtleart.py
index 7848320..c2933f1 100755
--- a/turtleart.py
+++ b/turtleart.py
@@ -28,6 +28,7 @@ import getopt
import sys
import os
import os.path
+import errno
try:
import pycurl
@@ -64,6 +65,14 @@ _HELP_MSG = 'turtleart.py: ' + _('usage is') + """
_MAX_FILE_SIZE = 950000
+def mkdir_p(path):
+ '''Create a directory in a fashion similar to `mkdir -p`'''
+ try:
+ os.makedirs(path)
+ except OSError as exc:
+ if exc.errno == errno.EEXIST:
+ pass
+ else: raise
def _make_sub_menu(menu, name):
""" add a new submenu to the toolbar """
@@ -153,6 +162,9 @@ class TurtleMain():
try:
data_file = open(os.path.join(CONFIG_HOME, 'turtleartrc'), 'r')
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+')
data_file.write(str(50) + '\n')
data_file.write(str(50) + '\n')