lanky / python-rhnapi

python module abstracting the RHN Satellite API for version 5.4.1
16 stars 6 forks source link

NoOptionError thrown when missing password entry in config #3

Closed dekimsey closed 7 years ago

dekimsey commented 10 years ago

Leaving out the password option throws an error. Readme suggests this should be valid.

If you miss out the password=xxxxx bit (or leave it set to None), you'll be prompted for it.

Configuration:
[mysatellite.com]
login=admin
Exception:
Python 2.7.5 (default, Feb 19 2014, 13:47:28) 
[GCC 4.8.2 20131212 (Red Hat 4.8.2-7)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import rhnapi
>>> RHN = rhnapi.rhnSession('mysatellite.com', config='~/.rhninfo')
Jun  6 08:02:40 RHN API[9064]: INFO     - looking up config info in ~/.rhninfo
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/dekimsey/.virtualenvs/satellite/lib/python2.7/site-packages/rhnapi/__init__.py", line 373, in __init__
    self.login, self._password = fetchCreds(self.configfile, self.hostname, self.logger, self.debug)
  File "/home/dekimsey/.virtualenvs/satellite/lib/python2.7/site-packages/rhnapi/__init__.py", line 190, in fetchCreds
    mypass  = confparse.get(servername, 'password')
  File "/usr/lib64/python2.7/ConfigParser.py", line 618, in get
    raise NoOptionError(option, section)
ConfigParser.NoOptionError: No option 'password' in section: 'rhn.cns.ufl.edu'
lanky commented 7 years ago

Ah, that's due to a lack of a [defaults] section, I expect. The provided template file has one. I'm loath to add the defaults into the constructor, as that hardcodes the entry.