1

Topic: setting timezone for admin user gives internal server error

======== Required information ====
- iRedMail version (check /etc/iredmail-release): 0.9.4
- Linux/BSD distribution name and version: CentOS Linux 7.2.1511
- Store mail accounts in which backend (LDAP/MySQL/PGSQL): PGSQL
- Web server (Apache or Nginx): Nginx
- Manage mail accounts with iRedAdmin-Pro? 2.3.1
- Related log if you're reporting an issue:
====

Apr 21 07:46:55 mx uwsgi: Traceback (most recent call last):
Apr 21 07:46:55 mx uwsgi: File "/usr/lib/python2.7/site-packages/web/application.py", line 239, in process
Apr 21 07:46:55 mx uwsgi: return self.handle()
Apr 21 07:46:55 mx uwsgi: File "/usr/lib/python2.7/site-packages/web/application.py", line 230, in handle
Apr 21 07:46:55 mx uwsgi: return self._delegate(fn, self.fvars, args)
Apr 21 07:46:55 mx uwsgi: File "/usr/lib/python2.7/site-packages/web/application.py", line 420, in _delegate
Apr 21 07:46:55 mx uwsgi: return handle_class(cls)
Apr 21 07:46:55 mx uwsgi: File "/usr/lib/python2.7/site-packages/web/application.py", line 396, in handle_class
Apr 21 07:46:55 mx uwsgi: return tocall(*args)
Apr 21 07:46:55 mx uwsgi: File "/var/www/iRedAdmin-Pro-SQL-2.3.1/controllers/decorators.py", line 22, in proxyfunc
Apr 21 07:46:55 mx uwsgi: return func(self, *args, **kw)
Apr 21 07:46:55 mx uwsgi: File "/var/www/iRedAdmin-Pro-SQL-2.3.1/controllers/panel/log.py", line 91, in GET
Apr 21 07:46:55 mx uwsgi: msg=i.get('msg'),
Apr 21 07:46:55 mx uwsgi: File "/var/www/iRedAdmin-Pro-SQL-2.3.1/libs/iredbase.py", line 185, in render_template
Apr 21 07:46:55 mx uwsgi: return jinja_env.get_template(template_name).render(context)
Apr 21 07:46:55 mx uwsgi: File "/usr/lib/python2.7/site-packages/jinja2/environment.py", line 969, in render
Apr 21 07:46:55 mx uwsgi: return self.environment.handle_exception(exc_info, True)
Apr 21 07:46:55 mx uwsgi: File "/usr/lib/python2.7/site-packages/jinja2/environment.py", line 742, in handle_exception
Apr 21 07:46:55 mx uwsgi: reraise(exc_type, exc_value, tb)
Apr 21 07:46:55 mx uwsgi: File "/var/www/iRedAdmin-Pro-SQL-2.3.1/libs/../templates/default/panel/log.html", line 9, in top-level template code
Apr 21 07:46:55 mx uwsgi: {% from "macros/msgHandlers.html" import logMsgHandler with context %}
Apr 21 07:46:55 mx uwsgi: File "/var/www/iRedAdmin-Pro-SQL-2.3.1/libs/../templates/default/layout.html", line 159, in top-level template code
Apr 21 07:46:55 mx uwsgi: {% block main %}{% endblock %}
Apr 21 07:46:55 mx uwsgi: File "/var/www/iRedAdmin-Pro-SQL-2.3.1/libs/../templates/default/panel/log.html", line 97, in block "main"
Apr 21 07:46:55 mx uwsgi: <td style="white-space: nowrap;">{{ log.timestamp |set_datetime_format |convert_utc_to_timezone(timezone=session['timezone'])}}</td>
Apr 21 07:46:55 mx uwsgi: File "/var/www/iRedAdmin-Pro-SQL-2.3.1/libs/ireddate.py", line 193, in convert_utc_to_timezone
Apr 21 07:46:55 mx uwsgi: ft += timedelta(seconds=3600)
Apr 21 07:46:55 mx uwsgi: TypeError: unsupported operand type(s) for +=: 'NoneType' and 'datetime.timedelta'

----

Spider Email Archiver: On-Premises, lightweight email archiving software developed by iRedMail team. Supports Amazon S3 compatible storage and custom branding.

2

Re: setting timezone for admin user gives internal server error

Please try below patch:

diff -r b7a9fdc8def0 -r 6c2f13b4156b libs/ireddate.py
--- a/libs/ireddate.py    Thu Apr 07 20:23:19 2016 +0800
+++ b/libs/ireddate.py    Thu Apr 07 21:23:09 2016 +0800
@@ -188,11 +188,11 @@
     # local timezone.
     ft = to_datetime_with_tzinfo(t, tzinfo=timezone)
 
-    # Check 'daylight saving time'
-    if time.localtime().tm_isdst:
-        ft += timedelta(seconds=3600)
+    if ft:
+        # Check 'daylight saving time'
+        if time.localtime().tm_isdst:
+            ft += timedelta(seconds=3600)
 
-    if ft:
         return ft.strftime(format)
     else:
         return '--'

3 (edited by justinr 2016-04-21 22:24:54)

Re: setting timezone for admin user gives internal server error

still internal error


Apr 21 09:21:42 mx uwsgi: Traceback (most recent call last):
Apr 21 09:21:42 mx uwsgi: File "/usr/lib/python2.7/site-packages/web/application.py", line 239, in process
Apr 21 09:21:42 mx uwsgi: return self.handle()
Apr 21 09:21:42 mx uwsgi: File "/usr/lib/python2.7/site-packages/web/application.py", line 230, in handle
Apr 21 09:21:42 mx uwsgi: return self._delegate(fn, self.fvars, args)
Apr 21 09:21:42 mx uwsgi: File "/usr/lib/python2.7/site-packages/web/application.py", line 420, in _delegate
Apr 21 09:21:42 mx uwsgi: return handle_class(cls)
Apr 21 09:21:42 mx uwsgi: File "/usr/lib/python2.7/site-packages/web/application.py", line 396, in handle_class
Apr 21 09:21:42 mx uwsgi: return tocall(*args)
Apr 21 09:21:42 mx uwsgi: File "/var/www/iRedAdmin-Pro-SQL-2.3.1/controllers/decorators.py", line 22, in proxyfunc
Apr 21 09:21:42 mx uwsgi: return func(self, *args, **kw)
Apr 21 09:21:42 mx uwsgi: File "/var/www/iRedAdmin-Pro-SQL-2.3.1/controllers/panel/log.py", line 91, in GET
Apr 21 09:21:42 mx uwsgi: msg=i.get('msg'),
Apr 21 09:21:42 mx uwsgi: File "/var/www/iRedAdmin-Pro-SQL-2.3.1/libs/iredbase.py", line 185, in render_template
Apr 21 09:21:42 mx uwsgi: return jinja_env.get_template(template_name).render(context)
Apr 21 09:21:42 mx uwsgi: File "/usr/lib/python2.7/site-packages/jinja2/environment.py", line 969, in render
Apr 21 09:21:42 mx uwsgi: return self.environment.handle_exception(exc_info, True)
Apr 21 09:21:42 mx uwsgi: File "/usr/lib/python2.7/site-packages/jinja2/environment.py", line 742, in handle_exception
Apr 21 09:21:42 mx uwsgi: reraise(exc_type, exc_value, tb)
Apr 21 09:21:42 mx uwsgi: File "/var/www/iRedAdmin-Pro-SQL-2.3.1/libs/../templates/default/panel/log.html", line 9, in top-level template code
Apr 21 09:21:42 mx uwsgi: {% from "macros/msgHandlers.html" import logMsgHandler with context %}
Apr 21 09:21:42 mx uwsgi: File "/var/www/iRedAdmin-Pro-SQL-2.3.1/libs/../templates/default/layout.html", line 159, in top-level template code
Apr 21 09:21:42 mx uwsgi: {% block main %}{% endblock %}
Apr 21 09:21:42 mx uwsgi: File "/var/www/iRedAdmin-Pro-SQL-2.3.1/libs/../templates/default/panel/log.html", line 97, in block "main"
Apr 21 09:21:42 mx uwsgi: <td style="white-space: nowrap;">{{ log.timestamp |set_datetime_format |convert_utc_to_timezone(timezone=session['timezone'])}}</td>
Apr 21 09:21:42 mx uwsgi: File "/var/www/iRedAdmin-Pro-SQL-2.3.1/libs/ireddate.py", line 193, in convert_utc_to_timezone
Apr 21 09:21:42 mx uwsgi: if time.localtime().tm_isdst:
Apr 21 09:21:42 mx uwsgi: TypeError: unsupported operand type(s) for +=: 'NoneType' and 'datetime.timedelta'


this is from the ireddate.py:

    # Convert original timestamp (with UTC timezone) to timestamp with
    # local timezone.
    ft = to_datetime_with_tzinfo(t, tzinfo=timezone)

    if ft:
       # Check 'daylight saving time'
       if time.localtime().tm_isdst:
           ft += timedelta(seconds=3600)

        return ft.strftime(format)
    else:
        return '--'

4

Re: setting timezone for admin user gives internal server error

Did you restart uwsgi service to reload modified iRedAdmin-Pro file?

5 (edited by justinr 2016-04-22 01:03:35)

Re: setting timezone for admin user gives internal server error

yes sir i did and it is now working