Repository: learningequality/kolibri
Issue: Kolibri fails to start if the timezone is detected incorrectly

### Observed behavior

In some environments, the time zone offset detected by tzlocal may not match the time zone offset of Python's `time.localtime()`. In that case, tzlocal's `get_localzone()` raises a `ValueError` exception: https://github.com/regebro/tzlocal/blob/c5282c6feded0d576937c0dcdf1f4fd00a95fbee/tzlocal/utils.py#L34-L46.

### Expected behavior

It looks like Kolibri handles an `UnknownTimeZoneError` exception from pytz already. To solve this issue, we could handle the `ValueError` from tzlocal in the same way: https://github.com/learningequality/kolibri/blob/release-v0.14.x/kolibri/deployment/default/settings/base.py#L252-L257. (It is unfortunate that tzlocal throws such a generic exception here, but we probably need to put up with it).

### User-facing consequences

At the moment, Kolibri is failing to start on Linux when using the `America/Sao_Paulo` timezone:

```
$ flatpak run org.learningequality.Kolibri 
WARNING:ifcfg:Neither `ifconfig` (`ifconfig -a`) nor `ip` (`ip address show`) commands are available, listing network interfaces is likely to fail
Process KolibriServiceMainProcess-1:
Traceback (most recent call last):
  File "/usr/lib/python3.7/multiprocessing/process.py", line 297, in _bootstrap
    self.run()
  File "/app/lib/python3.7/site-packages/kolibri_gnome/kolibri_service/kolibri_service_main.py", line 24, in run
    self.__run_kolibri_start()
  File "/app/lib/python3.7/site-packages/kolibri_gnome/kolibri_service/kolibri_service_main.py", line 49, in __run_kolibri_start
    initialize()
  File "/app/lib/python3.7/site-packages/kolibri/utils/cli.py", line 356, in initialize
    _setup_django()
  File "/app/lib/python3.7/site-packages/kolibri/utils/cli.py", line 293, in _setup_django
    django.setup()
  File "/app/lib/python3.7/site-packages/kolibri/dist/django/__init__.py", line 22, in setup
    configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
  File "/app/lib/python3.7/site-packages/kolibri/dist/django/conf/__init__.py", line 56, in __getattr__
    self._setup(name)
  File "/app/lib/python3.7/site-packages/kolibri/dist/django/conf/__init__.py", line 41, in _setup
    self._wrapped = Settings(settings_module)
  File "/app/lib/python3.7/site-packages/kolibri/dist/django/conf/__init__.py", line 110, in __init__
    mod = importlib.import_module(self.SETTINGS_MODULE)
  File "/usr/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/app/lib/python3.7/site-packages/kolibri_gnome/kolibri_settings.py", line 1, in <module>
    from kolibri.deployment.default.settings.base import *
  File "/app/lib/python3.7/site-packages/kolibri/deployment/default/settings/base.py", line 253, in <module>
    TIME_ZONE = get_localzone().zone
  File "/app/lib/python3.7/site-packages/kolibri/dist/tzlocal/unix.py", line 165, in get_localzone
    _cache_tz = _get_localzone()
  File "/app/lib/python3.7/site-packages/kolibri/dist/tzlocal/unix.py", line 90, in _get_localzone
    utils.assert_tz_offset(tz)
  File "/app/lib/python3.7/site-packages/kolibri/dist/tzlocal/utils.py", line 46, in assert_tz_offset
    raise ValueError(msg)
ValueError: Timezone offset does not match system offset: -7200 != -10800. Please, check your config files.
WARNING:kolibri_gnome.kolibri_service.kolibri_service_monitor:Kolibri service has died
```

(It appears Kolibri is including an old version of pytz which has incorrect information about DST for this timezone, but let's consider that tangential to this issue).

### Steps to reproduce

Change your system timezone to "America/Sao_Paulo" and start Kolibri.


Changed files:
kolibri/deployment/default/settings/base.py

diff --git a/kolibri/deployment/default/settings/base.py b/kolibri/deployment/default/settings/base.py
index 167a1dad4b..627e66e8e0 100644
--- a/kolibri/deployment/default/settings/base.py
+++ b/kolibri/deployment/default/settings/base.py
@@ -251,7 +251,7 @@ LANGUAGE_CODE = (
 
 try:
     TIME_ZONE = get_localzone().zone
-except pytz.UnknownTimeZoneError:
+except (pytz.UnknownTimeZoneError, ValueError):
     # Do not fail at this point because a timezone was not
     # detected.
     TIME_ZONE = pytz.utc.zone