Preferences in conf.d issues


#1

Hi All,
I have been struggling with the strange behaviour of the configuration
files in /usr/local/etc/gnuradio/conf.d
This is the place where the following files with gnuradio user
preferences live:
gnuradio-core.conf gr-audio-jack.conf gr-wxgui.conf
gr-audio-alsa.conf gr-audio-oss.conf

WHen trying some settings out, I backuped the original file
gr-wxgui.conf to gr-wxgui.conf.orig and changed settings in
gr-wxgui.conf

Whatever I filled in, the old values where still used.

It took me a while to find out that the filenames aren’t even looked at.
They are all read in by gnuradio/gr/prefs.py with the following code:
def _sys_prefs_filenames(self):
dir = _sys_prefs_dirname()
try:
fnames = os.listdir(dir)
except (IOError, OSError):
return []
fnames.sort()
return [os.path.join(dir, f) for f in fnames]

def _read_files(self):
    filenames = self._sys_prefs_filenames()
    filenames.append(_user_prefs_filename())
    #print "filenames: ", filenames
    self.cp.read(filenames)

What this comes down to that ALL files in conf.d are read in in
alphabetical order.
The last file read in overrides all values from the previous files.

I don’t know if this is documented somewhere, but it is something to be
aware about.
Don’t make backup copies in conf.d

But that is not all.
I had already found out previously that the inline comments in the pref
files prevent the settings from being read.

For example in gr-wxgui.conf is:
[wxgui]
style = auto # ‘gl’, ‘nongl’, or ‘auto’
fft_rate = 10 # fftsink and waterfallsink
frame_decim = 1 # scopesink

The value the code gets for fft_rate is then:
“10 # fftsink and waterfallsink”

This gives an error because the code expects only a number. 10
Because of the error the build-in default of 15 will still be used.

What would work is the following:

#style = auto #‘gl’, ‘nongl’, or ‘auto’
#fft_rate = 15 #fftsink and waterfallsink
#frame_decim = 1 # scopesink
[wxgui]
style = auto
fft_rate = 10
frame_decim = 1

The uncommented lines before [wxgui] function only as documentation
The lines after [wxgui] are the actual settings, no #comments allowed.

The same problems are in gr-audio-alsa.conf and maybe others

Greetings,
Martin


#2

On Sun, Jan 4, 2009 at 12:27 PM, Martin DvH
removed_email_address@domain.invalid wrote:

What this comes down to that ALL files in conf.d are read in in
alphabetical order.

This is a typical pattern for configuration directories, where
depositing any file in the directory results in it being read in
alphanumeric sort order.

I had already found out previously that the inline comments in the pref
files prevent the settings from being read.

This should be considered a bug. I have updated the wxgui config file
in the source tree to move the comments, but I agree that the parser
should remove these.

-Johnathan