Skip to content

Commit

Permalink
Updated boto.config to allow for BOTO_PATH, and to re-work how $HOME is
Browse files Browse the repository at this point in the history
handled (or not handled) to make boto work on Windows platforms again
  • Loading branch information
kopertop committed Apr 5, 2011
1 parent 1e1bcf7 commit 33f04cb
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions boto/pyami/config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Copyright (c) 2006,2007 Mitch Garnaat http://garnaat.org/
# Copyright (c) 2011 Chris Moyer http://coredumped.org/
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the
Expand All @@ -23,19 +24,25 @@
import ConfigParser
import boto

# By default we use two locations for the boto configurations,
# /etc/boto.cfg and $HOME/.boto (which is ~/.boto on both Windows and
# Unix platforms for python)
BotoConfigPath = '/etc/boto.cfg'
BotoConfigLocations = [BotoConfigPath]
UserConfigPath = os.path.expanduser('~/.boto')
BotoConfigLocations.append(UserConfigPath)

# IF there's a BOTO_CONFIG variable set, we load ONLY
# that variable
if 'BOTO_CONFIG' in os.environ:
BotoConfigLocations.append(os.path.expanduser(os.environ['BOTO_CONFIG']))
elif 'HOME' in os.environ:
UserConfigPath = os.path.expanduser('~/.boto')
BotoConfigLocations.append(UserConfigPath)
else:
UserConfigPath = None
__home_dir = os.path.expanduser('~')
if __home_dir and __home_dir != '~':
UserConfigPath = os.path.join(__home_dir, '.boto')
BotoConfigLocations.append(UserConfigPath)
BotoConfigLocations[os.path.expanduser(os.environ['BOTO_CONFIG'])]

# If there's a BOTO_PATH variable set, we use anything there
# as the current configuration locations, split with semicolons
elif 'BOTO_PATH' in os.environ:
BotoConfigLocations = []
for path in os.environ['BOTO_PATH'].split(":"):
BotoConfigLocations.append(os.path.expanduser(path))


class Config(ConfigParser.SafeConfigParser):
Expand Down

0 comments on commit 33f04cb

Please sign in to comment.