New config items break existing config files

Bug #250643 reported by Swizec
2
Affects Status Importance Assigned to Milestone
PyRoom
Fix Released
Medium
Florian Heinle
0.3
Fix Released
Undecided
Unassigned

Bug Description

When trying to run pyroom trunk version (from 2 minutes ago) I get this:

Traceback (most recent call last):

  File "pyroom.py", line 89, in <module>
    pyroom = BasicEdit(style=style, pyroom_config=pyroom_config)

  File "/home/swizec/pyroom/basic_edit.py", line 112, in __init__
    pyroom_config=pyroom_config)

  File "/home/swizec/pyroom/preferences.py", line 135, in __init__
    self.linespacing = self.config.get("visual", "linespacing")

  File "/usr/lib/python2.5/ConfigParser.py", line 520, in get
    raise NoOptionError(option, section)

NoOptionError: No option 'linespacing' in section: 'visual'

Please fix soon so I can go try if the new patch for two monitors works :P

Revision history for this message
Adam Rooke (abelianr) wrote : Re: [Bug 250643] [NEW] Programming error in current trunk

sorry that is my fault. The new linespacing option relies on there being a
linespacing option in the config. If you open up ~/.pyroom/pyroom.conf in
your favourite editor and add "linespacing = 2" under the [visual] section
so that it looks like this:

[visual]
theme = green
linenumber = 0
linespacing = 2

[editor]
session = True
autosavetime = 2
autosave = 0

Obviously, it is only the linespacing = 2 line that needs adding, you don't
have to change any of your settings to match those ones.

Its a known bug and is something that needs fixing.
2008/7/21 Swizec <email address hidden>:

> Public bug reported:
>
> When trying to run pyroom trunk version (from 2 minutes ago) I get this:
>
> Traceback (most recent call last):
>
> File "pyroom.py", line 89, in <module>
> pyroom = BasicEdit(style=style, pyroom_config=pyroom_config)
>
> File "/home/swizec/pyroom/basic_edit.py", line 112, in __init__
> pyroom_config=pyroom_config)
>
> File "/home/swizec/pyroom/preferences.py", line 135, in __init__
> self.linespacing = self.config.get("visual", "linespacing")
>
> File "/usr/lib/python2.5/ConfigParser.py", line 520, in get
> raise NoOptionError(option, section)
>
> NoOptionError: No option 'linespacing' in section: 'visual'
>
>
> Please fix soon so I can go try if the new patch for two monitors works :P
>
> ** Affects: pyroom
> Importance: Undecided
> Status: New
>
> --
> Programming error in current trunk
> https://bugs.launchpad.net/bugs/250643
> You received this bug notification because you are a member of PyRoom
> Bug Squad, which is subscribed to PyRoom.
>
> Status in PyRoom: distraction-free writing: New
>
> Bug description:
> When trying to run pyroom trunk version (from 2 minutes ago) I get this:
>
> Traceback (most recent call last):
>
> File "pyroom.py", line 89, in <module>
> pyroom = BasicEdit(style=style, pyroom_config=pyroom_config)
>
> File "/home/swizec/pyroom/basic_edit.py", line 112, in __init__
> pyroom_config=pyroom_config)
>
> File "/home/swizec/pyroom/preferences.py", line 135, in __init__
> self.linespacing = self.config.get("visual", "linespacing")
>
> File "/usr/lib/python2.5/ConfigParser.py", line 520, in get
> raise NoOptionError(option, section)
>
> NoOptionError: No option 'linespacing' in section: 'visual'
>
>
> Please fix soon so I can go try if the new patch for two monitors works :P
>

Revision history for this message
Florian Heinle (tiax) wrote :

we should make that process a little more robust. Missing configuration items should be filled with defaults. Abstracting away from the method we use to write default configs (i.e. switching to ConfigParser here, too) and a try/except clause should allow us to complete existing config files with missing items, so we won't fall into this pit with every new config item we add

Revision history for this message
Adam Rooke (abelianr) wrote : Re: [Bug 250643] Re: New config items break existing config files

I'm not sure how best to deal with this really.

I didn't realise config parser could write straight to a file? I know when I
was implementing it, it just manipulated strings and we then wrote the
changes to the file.

Since the config file is so basic I see no real harm having a try/except and
then adding the default config options to the file if they are missing. Or,
we could have a message that reads "your config file is out of date, do you
want to update it to the latest version or change it yourself" to give the
user some choice. Its basically a question of whether we change their config
file automatically, ask for their permission, or get them to do it.

Before that is implemented, maybe you could add something to your error code
so that a config error is captured and tells the person what to do?

2008/7/22 tiax <email address hidden>:

> we should make that process a little more robust. Missing configuration
> items should be filled with defaults. Abstracting away from the method
> we use to write default configs (i.e. switching to ConfigParser here,
> too) and a try/except clause should allow us to complete existing config
> files with missing items, so we won't fall into this pit with every new
> config item we add
>
> ** Summary changed:
>
> - Programming error in current trunk
> + New config items break existing config files
>
> --
> New config items break existing config files
> https://bugs.launchpad.net/bugs/250643
> You received this bug notification because you are a member of PyRoom
> Bug Squad, which is subscribed to PyRoom.
>
> Status in PyRoom: distraction-free writing: New
>
> Bug description:
> When trying to run pyroom trunk version (from 2 minutes ago) I get this:
>
> Traceback (most recent call last):
>
> File "pyroom.py", line 89, in <module>
> pyroom = BasicEdit(style=style, pyroom_config=pyroom_config)
>
> File "/home/swizec/pyroom/basic_edit.py", line 112, in __init__
> pyroom_config=pyroom_config)
>
> File "/home/swizec/pyroom/preferences.py", line 135, in __init__
> self.linespacing = self.config.get("visual", "linespacing")
>
> File "/usr/lib/python2.5/ConfigParser.py", line 520, in get
> raise NoOptionError(option, section)
>
> NoOptionError: No option 'linespacing' in section: 'visual'
>
>
> Please fix soon so I can go try if the new patch for two monitors works :P
>

Revision history for this message
Florian Heinle (tiax) wrote :

fixed in rev 85

I changed how our ConfigParser works, adding a wrapper that returns default values if a given value isn't available. This includes changing DEFAULT_CONF to a dictionary instead of a string. New config values have to be added to this dictionary, with its values as *strings*

Still, the whole configuration system seems a little clunky. Maybe we should replace it some day.

Changed in pyroom:
assignee: nobody → tiax
importance: Undecided → Medium
status: New → Fix Committed
Revision history for this message
Florian Heinle (tiax) wrote :

added to 0.3 milestone

Changed in pyroom:
milestone: none → 0.3
Florian Heinle (tiax)
Changed in pyroom:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers