[Elisa-commits] [MERGE] added an upgrade path for 0.3.6 version

Olivier Tilloy olivier at fluendo.com
Thu Apr 24 11:04:46 CEST 2008


bb:comment

See my niggling comments below.

Olivier

Philippe Normand wrote:
> This little patch contains an upgrade path for the 0.3.6 version,
> although it's currently empty.
> 
> I also fixed the media_scanner wrt the media_locations to ignore during
> the scan.
> 
> Philippe
> 
> === modified file 'elisa-core/elisa/core/config_upgrader.py'
> --- elisa-core/elisa/core/config_upgrader.py	2008-04-01 10:21:27 +0000
> +++ elisa-core/elisa/core/config_upgrader.py	2008-04-24 08:31:05 +0000
> @@ -133,8 +133,15 @@
>          cfg.write(full_path)
>  
>      def _update_0_3_5_to_0_3_6(self, cfg=None):
> +        self.info('Upgrading from 0.3.5 to 0.3.6')
> +        self._backup((0, 3, 5), cfg)
> +        if not cfg:
> +            cfg = self._current_config
> +
>          # TODO: implement me
> -        pass
> +            
> +        self._current_version = '0.3.5.1'
> +        return cfg
>  
>      def _update_0_3_4_to_0_3_5(self, cfg=None):
>          self.info('Upgrading from 0.3.4 to 0.3.5')

I dunno anything about the upgrade logic but it seems really ugly to
have to define specific upgrade path functions for each new version.
Isn't there a better way?

> === modified file 'elisa-plugins/elisa/plugins/media_db/media_scanner.py'
> --- elisa-plugins/elisa/plugins/media_db/media_scanner.py	2008-04-01 10:21:27 +0000
> +++ elisa-plugins/elisa/plugins/media_db/media_scanner.py	2008-04-24 08:31:05 +0000
> @@ -27,6 +27,7 @@
>  from elisa.extern import enum
>  from elisa.core.utils import classinit
>  
> +import sys
>  import os
>  import time
>  from twisted.internet import reactor, defer, task
> @@ -114,15 +115,17 @@
>          self._hourly_locations = self.config['hourly_location_updates']
>          self._daily_locations = self.config['daily_location_updates']
>          self._weekly_locations = self.config['weekly_location_updates']
> -        self._ignored_locations = self.config['ignored_locations']
> +        self._ignored_locations = [ unicode(uri)
> +                                    for uri in self.config['ignored_locations']]

The white space before unicode(uri) is useless.

> +        
>          self._update_intervals = dict(fivemin=60 * 5,
> -                hour=60 * 60,
> -                day=60 * 60 * 24,
> -                week=60 * 60 * 24 * 7)
> +                                      hour=60 * 60,
> +                                      day=60 * 60 * 24,
> +                                      week=60 * 60 * 24 * 7)

These could use constants defined in the core maybe? Or at module level
in the plugin?

>          self._interval_locations = {'fivemin': self._fivemin_locations,
> -                              'hour': self._hourly_locations,
> -                              'day': self._daily_locations,
> -                              'week': self._weekly_locations}
> +                                    'hour': self._hourly_locations,
> +                                    'day': self._daily_locations,
> +                                    'week': self._weekly_locations}
>          
>          interval = self.config.as_float('scan_interval')
>          self._scan_interval = max(interval, self.min_scan_interval)


More information about the Elisa-commits mailing list