# -*- coding: utf-8 -*- import os import sys import Hercules.debug as debug if os.name == 'nt' or os.name == 'win32': # default to My Documents import winshell mydocs = winshell.my_documents() hercules_dir = os.path.join(mydocs, 'hercules') else: hercules_dir = os.path.join(os.path.expanduser('~'), '.hercules') try: if not os.path.exists(hercules_dir): debug.debug('Creating %s' % hercules_dir) os.makedirs(hercules_dir) else: debug.debug('Using Hercules directory: %s'% hercules_dir) except OSError: debug.debug("Unable to create hercules directory.") raise sys.exit() if not os.access(hercules_dir, os.W_OK): debug.debug('Cannot write to hercules directory, %s' % hercules_dir) sys.exit()