views:

39

answers:

1

I try to create a configuration file, where I can store constants.

Whenever I try with ConfigParser, I get an error

Traceback (most recent call last):
  File "/home/baun/google_appengine/google/appengine/ext/webapp        /__init__.py", line 511, in __call__
    handler.get(*groups)
  File "/home/baun/workspace/octopuscloud/s3/S3.py", line 138, in get
    test = parser.get('bucket', 'bucketname')
  File "/usr/lib/python2.5/ConfigParser.py", line 511, in get
    raise NoSectionError(section)
NoSectionError: No section: 'bucket'

simple.cfg:

[bucket]
bucketname: 'octopus_storage'

s3.py:

...
from ConfigParser import SafeConfigParser

parser = SafeConfigParser()
parser.read('simple.cfg')

...

# Get values from the config file
test = parser.get('bucket', 'bucketname')
...

How can I fix this?

===============================

The problem is fixed. The code was correct, but simple.cfg was in the wrong directory.

+1  A: 
[bucket]
bucketname= octopus_storage
number23
Thanks a lot. The problem is fixed. The code and the config file was correct. The config file was in the wrong directory.
Neverland