modoboa / modoboa-imap-migration

An extension to ease the migration between 2 IMAP servers using offlineimap
ISC License
16 stars 12 forks source link

Exception Type: KeyError at /modoboa_imap_migration/ | Exception Value: u'IMAP_MIGRATION' #47

Closed cremesk closed 5 years ago

cremesk commented 5 years ago

Upgrade:

sudo -u modoboa -i
bash
source env/bin/activate
pip install -U modoboa-imap-migration
$ cd <modoboa_instance_dir>
$ python manage.py migrate modoboa_imap_migration
$ python manage.py load_initial_data

After Upgrading from Version 1.2.1 to 1.3.0 i become this Error.

Request Method: | GET
-- | --
https://mail.secnux.net/modoboa_imap_migration/
1.11.18
KeyError
u'IMAP_MIGRATION'
/srv/modoboa/env/local/lib/python2.7/site-packages/webpack_loader/config.py in load_config, line 33
/usr/bin/uwsgi-core
2.7.13
['.',  '',  '/srv/modoboa/env/lib/python2.7',  '/srv/modoboa/env/lib/python2.7/plat-x86_64-linux-gnu',  '/srv/modoboa/env/lib/python2.7/lib-tk',  '/srv/modoboa/env/lib/python2.7/lib-old',  '/srv/modoboa/env/lib/python2.7/lib-dynload',  '/usr/lib/python2.7',  '/usr/lib/python2.7/plat-x86_64-linux-gnu',  '/usr/lib/python2.7/lib-tk',  '/srv/modoboa/env/local/lib/python2.7/site-packages',  '/srv/modoboa/env/lib/python2.7/site-packages']
Thu, 7 Mar 2019 16:35:58 +0100
Environment:

Request Method: GET
Request URL: https://mail.secnux.net/modoboa_imap_migration/

Django Version: 1.11.18
Python Version: 2.7.13
Installed Applications:
(u'django.contrib.auth',
 u'django.contrib.contenttypes',
 u'django.contrib.sessions',
 u'django.contrib.messages',
 u'django.contrib.sites',
 u'django.contrib.staticfiles',
 u'reversion',
 u'ckeditor',
 u'ckeditor_uploader',
 u'rest_framework',
 u'rest_framework.authtoken',
 u'modoboa',
 u'modoboa.core',
 u'modoboa.lib',
 u'modoboa.admin',
 u'modoboa.transport',
 u'modoboa.relaydomains',
 u'modoboa.limits',
 u'modoboa.parameters',
 u'modoboa.dnstools',
 u'modoboa_amavis',
 u'modoboa_pdfcredentials',
 u'modoboa_postfix_autoreply',
 u'modoboa_sievefilters',
 u'modoboa_stats',
 u'modoboa_webmail',
 u'modoboa_contacts',
 u'modoboa_radicale',
 u'modoboa_dmarc',
 u'modoboa_imap_migration',
 'webpack_loader')
Installed Middleware:
(u'x_forwarded_for.middleware.XForwardedForMiddleware',
 u'django.contrib.sessions.middleware.SessionMiddleware',
 u'django.middleware.common.CommonMiddleware',
 u'django.middleware.csrf.CsrfViewMiddleware',
 u'django.contrib.auth.middleware.AuthenticationMiddleware',
 u'django.contrib.messages.middleware.MessageMiddleware',
 u'django.middleware.locale.LocaleMiddleware',
 u'django.middleware.clickjacking.XFrameOptionsMiddleware',
 u'modoboa.core.middleware.LocalConfigMiddleware',
 u'modoboa.lib.middleware.AjaxLoginRedirect',
 u'modoboa.lib.middleware.CommonExceptionCatcher',
 u'modoboa.lib.middleware.RequestCatcherMiddleware')

Traceback:

File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/core/handlers/exception.py" in inner
  41.             response = get_response(request)

File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/core/handlers/base.py" in _get_response
  217.                 response = self.process_exception_by_middleware(e, request)

File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/core/handlers/base.py" in _get_response
  215.                 response = response.render()

File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/template/response.py" in render
  107.             self.content = self.rendered_content

File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/template/response.py" in rendered_content
  84.         content = template.render(context, self._request)

File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/template/backends/django.py" in render
  66.             return self.template.render(context)

File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/template/base.py" in render
  207.                     return self._render(context)

File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/template/base.py" in _render
  199.         return self.nodelist.render(context)

File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/template/base.py" in render
  990.                 bit = node.render_annotated(context)

File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/template/base.py" in render_annotated
  957.             return self.render(context)

File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/template/loader_tags.py" in render
  177.             return compiled_parent._render(context)

File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/template/base.py" in _render
  199.         return self.nodelist.render(context)

File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/template/base.py" in render
  990.                 bit = node.render_annotated(context)

File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/template/base.py" in render_annotated
  957.             return self.render(context)

File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/template/loader_tags.py" in render
  177.             return compiled_parent._render(context)

File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/template/base.py" in _render
  199.         return self.nodelist.render(context)

File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/template/base.py" in render
  990.                 bit = node.render_annotated(context)

File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/template/base.py" in render_annotated
  957.             return self.render(context)

File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/template/loader_tags.py" in render
  72.                 result = block.nodelist.render(context)

File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/template/base.py" in render
  990.                 bit = node.render_annotated(context)

File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/template/base.py" in render_annotated
  957.             return self.render(context)

File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/template/defaulttags.py" in render
  322.                 return nodelist.render(context)

File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/template/base.py" in render
  990.                 bit = node.render_annotated(context)

File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/template/base.py" in render_annotated
  957.             return self.render(context)

File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/template/library.py" in render
  203.         output = self.func(*resolved_args, **resolved_kwargs)

File "/srv/modoboa/env/local/lib/python2.7/site-packages/webpack_loader/templatetags/webpack_loader.py" in render_bundle
  12.     tags = utils.get_as_tags(bundle_name, extension=extension, config=config, attrs=attrs)

File "/srv/modoboa/env/local/lib/python2.7/site-packages/webpack_loader/utils.py" in get_as_tags
  45.     bundle = _get_bundle(bundle_name, extension, config)

File "/srv/modoboa/env/local/lib/python2.7/site-packages/webpack_loader/utils.py" in _get_bundle
  23.     bundle = get_loader(config).get_bundle(bundle_name)

File "/srv/modoboa/env/local/lib/python2.7/site-packages/webpack_loader/utils.py" in get_loader
  11.         _loaders[config_name] = WebpackLoader(config_name)

File "/srv/modoboa/env/local/lib/python2.7/site-packages/webpack_loader/loader.py" in __init__
  22.         self.config = load_config(self.name)

File "/srv/modoboa/env/local/lib/python2.7/site-packages/webpack_loader/config.py" in load_config
  33.     return user_config[name]

Exception Type: KeyError at /modoboa_imap_migration/
Exception Value: u'IMAP_MIGRATION'
tonioo commented 5 years ago

@cremesk I forgot to complete installation instructions. I've just fixed the README, what you need to do is adding the following lines at the end of the settings.py file:

from modoboa_imap_migration import settings as modoboa_imap_migration_settings
modoboa_imap_migration_settings.apply(globals())
cremesk commented 5 years ago

Okay i have add this on the end.

Now:


Request Method: | GET
-- | --
https://mail.secnux.net/modoboa_imap_migration/
1.11.18
IOError
Error reading /srv/modoboa/env/local/lib/python2.7/site-packages/modoboa_imap_migration/../frontend/webpack-stats.json. Are you sure webpack has generated the file and the path is correct?
/srv/modoboa/env/local/lib/python2.7/site-packages/webpack_loader/loader.py in _load_assets, line 32
/usr/bin/uwsgi-core
2.7.13
['.',  '',  '/srv/modoboa/env/lib/python2.7',  '/srv/modoboa/env/lib/python2.7/plat-x86_64-linux-gnu',  '/srv/modoboa/env/lib/python2.7/lib-tk',  '/srv/modoboa/env/lib/python2.7/lib-old',  '/srv/modoboa/env/lib/python2.7/lib-dynload',  '/usr/lib/python2.7',  '/usr/lib/python2.7/plat-x86_64-linux-gnu',  '/usr/lib/python2.7/lib-tk',  '/srv/modoboa/env/local/lib/python2.7/site-packages',  '/srv/modoboa/env/lib/python2.7/site-packages']
Fri, 8 Mar 2019 10:41:36 +0100
Environment:

Request Method: GET
Request URL: https://mail.secnux.net/modoboa_imap_migration/

Django Version: 1.11.18
Python Version: 2.7.13
Installed Applications:
(u'django.contrib.auth',
 u'django.contrib.contenttypes',
 u'django.contrib.sessions',
 u'django.contrib.messages',
 u'django.contrib.sites',
 u'django.contrib.staticfiles',
 u'reversion',
 u'ckeditor',
 u'ckeditor_uploader',
 u'rest_framework',
 u'rest_framework.authtoken',
 u'modoboa',
 u'modoboa.core',
 u'modoboa.lib',
 u'modoboa.admin',
 u'modoboa.transport',
 u'modoboa.relaydomains',
 u'modoboa.limits',
 u'modoboa.parameters',
 u'modoboa.dnstools',
 u'modoboa_amavis',
 u'modoboa_pdfcredentials',
 u'modoboa_postfix_autoreply',
 u'modoboa_sievefilters',
 u'modoboa_stats',
 u'modoboa_webmail',
 u'modoboa_contacts',
 u'modoboa_radicale',
 u'modoboa_dmarc',
 u'modoboa_imap_migration',
 'webpack_loader')
Installed Middleware:
(u'x_forwarded_for.middleware.XForwardedForMiddleware',
 u'django.contrib.sessions.middleware.SessionMiddleware',
 u'django.middleware.common.CommonMiddleware',
 u'django.middleware.csrf.CsrfViewMiddleware',
 u'django.contrib.auth.middleware.AuthenticationMiddleware',
 u'django.contrib.messages.middleware.MessageMiddleware',
 u'django.middleware.locale.LocaleMiddleware',
 u'django.middleware.clickjacking.XFrameOptionsMiddleware',
 u'modoboa.core.middleware.LocalConfigMiddleware',
 u'modoboa.lib.middleware.AjaxLoginRedirect',
 u'modoboa.lib.middleware.CommonExceptionCatcher',
 u'modoboa.lib.middleware.RequestCatcherMiddleware')

Traceback:

File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/core/handlers/exception.py" in inner
  41.             response = get_response(request)

File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/core/handlers/base.py" in _get_response
  217.                 response = self.process_exception_by_middleware(e, request)

File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/core/handlers/base.py" in _get_response
  215.                 response = response.render()

File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/template/response.py" in render
  107.             self.content = self.rendered_content

File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/template/response.py" in rendered_content
  84.         content = template.render(context, self._request)

File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/template/backends/django.py" in render
  66.             return self.template.render(context)

File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/template/base.py" in render
  207.                     return self._render(context)

File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/template/base.py" in _render
  199.         return self.nodelist.render(context)

File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/template/base.py" in render
  990.                 bit = node.render_annotated(context)

File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/template/base.py" in render_annotated
  957.             return self.render(context)

File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/template/loader_tags.py" in render
  177.             return compiled_parent._render(context)

File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/template/base.py" in _render
  199.         return self.nodelist.render(context)

File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/template/base.py" in render
  990.                 bit = node.render_annotated(context)

File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/template/base.py" in render_annotated
  957.             return self.render(context)

File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/template/loader_tags.py" in render
  177.             return compiled_parent._render(context)

File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/template/base.py" in _render
  199.         return self.nodelist.render(context)

File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/template/base.py" in render
  990.                 bit = node.render_annotated(context)

File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/template/base.py" in render_annotated
  957.             return self.render(context)

File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/template/loader_tags.py" in render
  72.                 result = block.nodelist.render(context)

File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/template/base.py" in render
  990.                 bit = node.render_annotated(context)

File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/template/base.py" in render_annotated
  957.             return self.render(context)

File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/template/defaulttags.py" in render
  322.                 return nodelist.render(context)

File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/template/base.py" in render
  990.                 bit = node.render_annotated(context)

File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/template/base.py" in render_annotated
  957.             return self.render(context)

File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/template/library.py" in render
  203.         output = self.func(*resolved_args, **resolved_kwargs)

File "/srv/modoboa/env/local/lib/python2.7/site-packages/webpack_loader/templatetags/webpack_loader.py" in render_bundle
  12.     tags = utils.get_as_tags(bundle_name, extension=extension, config=config, attrs=attrs)

File "/srv/modoboa/env/local/lib/python2.7/site-packages/webpack_loader/utils.py" in get_as_tags
  45.     bundle = _get_bundle(bundle_name, extension, config)

File "/srv/modoboa/env/local/lib/python2.7/site-packages/webpack_loader/utils.py" in _get_bundle
  23.     bundle = get_loader(config).get_bundle(bundle_name)

File "/srv/modoboa/env/local/lib/python2.7/site-packages/webpack_loader/loader.py" in get_bundle
  60.         assets = self.get_assets()

File "/srv/modoboa/env/local/lib/python2.7/site-packages/webpack_loader/loader.py" in get_assets
  39.         return self._load_assets()

File "/srv/modoboa/env/local/lib/python2.7/site-packages/webpack_loader/loader.py" in _load_assets
  32.                     self.config['STATS_FILE']))

Exception Type: IOError at /modoboa_imap_migration/
Exception Value: Error reading /srv/modoboa/env/local/lib/python2.7/site-packages/modoboa_imap_migration/../frontend/webpack-stats.json. Are you sure webpack has generated the file and the path is correct?
cremesk commented 5 years ago

Then i downgrade to Version 1.2.1 i become an error:

Please Help me :/

Request Method: | POST
-- | --
https://mail.secnux.net/accounts/login/
1.11.18
IntegrityError
null value in column "username" violates not-null constraint DETAIL:  Failing row contains (20, gAAAAABcgtTKS2C1ywsdsZk0vpmWTf71RR4cpvmVKtoFqV7go9YfPy9NfVFk4e3_..., 127, null, null).
/srv/modoboa/env/local/lib/python2.7/site-packages/django/db/backends/utils.py in execute, line 64
/usr/bin/uwsgi-core
2.7.13
['.',  '',  '/srv/modoboa/env/lib/python2.7',  '/srv/modoboa/env/lib/python2.7/plat-x86_64-linux-gnu',  '/srv/modoboa/env/lib/python2.7/lib-tk',  '/srv/modoboa/env/lib/python2.7/lib-old',  '/srv/modoboa/env/lib/python2.7/lib-dynload',  '/usr/lib/python2.7',  '/usr/lib/python2.7/plat-x86_64-linux-gnu',  '/usr/lib/python2.7/lib-tk',  '/srv/modoboa/env/local/lib/python2.7/site-packages',  '/srv/modoboa/env/lib/python2.7/site-packages']
Fri, 8 Mar 2019 21:47:06 +0100
Environment:

Request Method: POST
Request URL: https://mail.secnux.net/accounts/login/

Django Version: 1.11.18
Python Version: 2.7.13
Installed Applications:
(u'django.contrib.auth',
 u'django.contrib.contenttypes',
 u'django.contrib.sessions',
 u'django.contrib.messages',
 u'django.contrib.sites',
 u'django.contrib.staticfiles',
 u'reversion',
 u'ckeditor',
 u'ckeditor_uploader',
 u'rest_framework',
 u'rest_framework.authtoken',
 u'modoboa',
 u'modoboa.core',
 u'modoboa.lib',
 u'modoboa.admin',
 u'modoboa.transport',
 u'modoboa.relaydomains',
 u'modoboa.limits',
 u'modoboa.parameters',
 u'modoboa.dnstools',
 u'modoboa_amavis',
 u'modoboa_pdfcredentials',
 u'modoboa_postfix_autoreply',
 u'modoboa_sievefilters',
 u'modoboa_stats',
 u'modoboa_webmail',
 u'modoboa_contacts',
 u'modoboa_radicale',
 u'modoboa_dmarc',
 u'modoboa_imap_migration',
 'webpack_loader')
Installed Middleware:
(u'x_forwarded_for.middleware.XForwardedForMiddleware',
 u'django.contrib.sessions.middleware.SessionMiddleware',
 u'django.middleware.common.CommonMiddleware',
 u'django.middleware.csrf.CsrfViewMiddleware',
 u'django.contrib.auth.middleware.AuthenticationMiddleware',
 u'django.contrib.messages.middleware.MessageMiddleware',
 u'django.middleware.locale.LocaleMiddleware',
 u'django.middleware.clickjacking.XFrameOptionsMiddleware',
 u'modoboa.core.middleware.LocalConfigMiddleware',
 u'modoboa.lib.middleware.AjaxLoginRedirect',
 u'modoboa.lib.middleware.CommonExceptionCatcher',
 u'modoboa.lib.middleware.RequestCatcherMiddleware')

Traceback:

File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/core/handlers/exception.py" in inner
  41.             response = get_response(request)

File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/core/handlers/base.py" in _get_response
  187.                 response = self.process_exception_by_middleware(e, request)

File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/core/handlers/base.py" in _get_response
  185.                 response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/utils/decorators.py" in inner
  185.                     return func(*args, **kwargs)

File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/utils/decorators.py" in inner
  185.                     return func(*args, **kwargs)

File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/views/decorators/cache.py" in _wrapped_view_func
  57.         response = view_func(request, *args, **kwargs)

File "/srv/modoboa/env/local/lib/python2.7/site-packages/modoboa/core/views/auth.py" in dologin
  36.                                 password=form.cleaned_data["password"])

File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/contrib/auth/__init__.py" in authenticate
  70.             user = _authenticate_with_backend(backend, backend_path, request, credentials)

File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/contrib/auth/__init__.py" in _authenticate_with_backend
  116.     return backend.authenticate(*args, **credentials)

File "/srv/modoboa/env/local/lib/python2.7/site-packages/modoboa_imap_migration/auth_backends.py" in authenticate
  44.         return self.get_or_create_user(username, password)

File "/srv/modoboa/env/local/lib/python2.7/site-packages/modoboa_imap_migration/auth_backends.py" in get_or_create_user
  62.             Migration.objects.create(mailbox=user.mailbox, password=password)

File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/db/models/manager.py" in manager_method
  85.                 return getattr(self.get_queryset(), name)(*args, **kwargs)

File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/db/models/query.py" in create
  394.         obj.save(force_insert=True, using=self.db)

File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/db/models/base.py" in save
  808.                        force_update=force_update, update_fields=update_fields)

File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/db/models/base.py" in save_base
  838.             updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields)

File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/db/models/base.py" in _save_table
  924.             result = self._do_insert(cls._base_manager, using, fields, update_pk, raw)

File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/db/models/base.py" in _do_insert
  963.                                using=using, raw=raw)

File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/db/models/manager.py" in manager_method
  85.                 return getattr(self.get_queryset(), name)(*args, **kwargs)

File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/db/models/query.py" in _insert
  1079.         return query.get_compiler(using=using).execute_sql(return_id)

File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py" in execute_sql
  1112.                 cursor.execute(sql, params)

File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/db/backends/utils.py" in execute
  79.             return super(CursorDebugWrapper, self).execute(sql, params)

File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/db/backends/utils.py" in execute
  64.                 return self.cursor.execute(sql, params)

File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/db/utils.py" in __exit__
  94.                 six.reraise(dj_exc_type, dj_exc_value, traceback)

File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/db/backends/utils.py" in execute
  64.                 return self.cursor.execute(sql, params)

Exception Type: IntegrityError at /accounts/login/
Exception Value: null value in column "username" violates not-null constraint
DETAIL:  Failing row contains (20, gAAAAABcgtTKS2C1ywsdsZk0vpmWTf71RR4cpvmVKtoFqV7go9YfPy9NfVFk4e3_..., 127, null, null).
cremesk commented 5 years ago

I have replayed a previous backup to make version 1.2.1 work again. We can test the upgrade to 1.3.0 on Monday. Thanks