Projects
Kolab:16:Enterprise
pykolab
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
Expand all
Collapse all
Changes of Revision 33
View file
0003-Fix-unicode-in-roundcube-config-templates.patch
Changed
@@ -1,26 +1,27 @@ -From 423c0ead53fa34c3f0ddc7c987ad66b121cce6ca Mon Sep 17 00:00:00 2001 +From 42dd21a3743fb58856feeb42f815d2bee0ce36b5 Mon Sep 17 00:00:00 2001 From: "Jeroen van Meeuwen (Kolab Systems)" <vanmeeuwen@kolabsys.com> Date: Tue, 21 May 2019 17:36:34 +0200 Subject: PATCH 3/3 Fix unicode in roundcube config templates --- - pykolab/setup/setup_roundcube.py | 229 +++++++++++++++++-------------- + pykolab/setup/setup_roundcube.py | 248 +++++++++++++++++-------------- pykolab/translate.py | 21 ++- - 2 files changed, 142 insertions(+), 108 deletions(-) + 2 files changed, 155 insertions(+), 114 deletions(-) diff --git a/pykolab/setup/setup_roundcube.py b/pykolab/setup/setup_roundcube.py -index 9b6d664..9c0c347 100644 +index 9b6d664..b7b38ed 100644 --- a/pykolab/setup/setup_roundcube.py +++ b/pykolab/setup/setup_roundcube.py -@@ -17,7 +17,6 @@ +@@ -17,7 +17,7 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. # -from Cheetah.Template import Template ++import codecs import grp import hashlib import os -@@ -27,6 +26,8 @@ import subprocess +@@ -27,6 +27,8 @@ import subprocess import sys import time @@ -29,7 +30,11 @@ import components import pykolab -@@ -38,63 +39,66 @@ from pykolab.translate import _ +@@ -35,66 +37,70 @@ from pykolab import utils + from pykolab.constants import * + from pykolab.translate import _ + ++# pylint: disable=invalid-name log = pykolab.getLogger('pykolab.setup') conf = pykolab.getConf() @@ -138,7 +143,7 @@ rcpath = '' for rc_path in rc_paths: -@@ -114,22 +118,22 @@ def execute(*args, **kw): +@@ -114,22 +120,22 @@ def execute(*args, **kw): rc_settings'skin' = 'larry' want_files = @@ -177,7 +182,7 @@ for want_file in want_files: template_file = None -@@ -137,29 +141,30 @@ def execute(*args, **kw): +@@ -137,71 +143,77 @@ def execute(*args, **kw): template_file = '/etc/kolab/templates/roundcubemail/%s.tpl' % (want_file) elif os.path.isfile('/usr/share/kolab/templates/roundcubemail/%s.tpl' % (want_file)): template_file = '/usr/share/kolab/templates/roundcubemail/%s.tpl' % (want_file) @@ -186,13 +191,17 @@ - if not template_file == None: + if template_file is not None: ++ # pylint: disable=logging-not-lazy log.debug(_("Using template file %r") % (template_file), level=8) - fp = open(template_file, 'r') -+ fp = codecs.open(template_file, 'r', encoding='utf-8') - template_definition = fp.read() - fp.close() +- template_definition = fp.read() +- fp.close() ++ filep = codecs.open(template_file, 'r', encoding='utf-8') ++ template_definition = filep.read() ++ filep.close() t = Template(template_definition, searchList=rc_settings) ++ # pylint: disable=logging-not-lazy log.debug( - _("Successfully compiled template %r, writing out to %r") % (template_file, want_file), - level=8 @@ -204,22 +213,26 @@ + level=8 + ) - fp = None +- fp = None ++ filep = None if os.path.isdir('/etc/roundcubemail'): - fp = open('/etc/roundcubemail/%s' % (want_file), 'w') -+ fp = codecs.open('/etc/roundcubemail/%s' % (want_file), 'w', encoding='utf-8') ++ filep = codecs.open('/etc/roundcubemail/%s' % (want_file), 'w', encoding='utf-8') elif os.path.isdir('/etc/roundcube'): - fp = open('/etc/roundcube/%s' % (want_file), 'w') -+ fp = codecs.open('/etc/roundcube/%s' % (want_file), 'w', encoding='utf-8') ++ filep = codecs.open('/etc/roundcube/%s' % (want_file), 'w', encoding='utf-8') - if not fp == None: - fp.write(t.__str__()) -+ if fp is not None: -+ fp.write(unicode(t())) - fp.close() +- fp.close() ++ if filep is not None: ++ filep.write(t.respond()) ++ filep.close() schema_files = -@@ -167,41 +172,42 @@ def execute(*args, **kw): ++ ++ # pylint: disable=too-many-nested-blocks + for root, directories, filenames in os.walk('/usr/share/doc/'): directories.sort() for directory in directories: if directory.startswith("roundcubemail"): @@ -234,10 +247,12 @@ + if schema_filepath not in schema_files: schema_files.append(schema_filepath) - if len(schema_files) > 0: +- if len(schema_files) > 0: ++ if schema_files: break +- if len(schema_files) > 0: + - if len(schema_files) > 0: ++ if schema_files: break for root, directories, filenames in os.walk(rcpath + 'plugins/calendar/drivers/kolab/'): @@ -274,7 +289,7 @@ schema_files.append(schema_filepath) if len(schema_files) > 0: -@@ -210,14 +216,9 @@ def execute(*args, **kw): +@@ -210,14 +222,9 @@ def execute(*args, **kw): break if not os.path.isfile('/tmp/kolab-setup-my.cnf'): @@ -291,7 +306,7 @@ data = """ mysql -@@ -226,7 +227,7 @@ password='%s' +@@ -226,7 +233,7 @@ password='%s' """ % (mysql_root_password) fp = open('/tmp/kolab-setup-my.cnf', 'w') @@ -300,7 +315,7 @@ fp.write(data) fp.close() -@@ -235,14 +236,30 @@ password='%s' +@@ -235,14 +242,30 @@ password='%s' p1.stdout.close() p2.communicate() @@ -333,7 +348,7 @@ p1.stdout.close() p2.communicate() -@@ -267,11 +284,13 @@ password='%s' +@@ -267,11 +290,14 @@ password='%s' webserver_gid = None @@ -341,7 +356,8 @@ + for webserver_group in 'apache', 'www-data', 'www': try: - (a,b,webserver_gid,c) = grp.getgrnam(webserver_group) -+ (_, _, webserver_gid, _) = grp.getgrnam(webserver_group) ++ # pylint: disable=unused-variable ++ (a, b, webserver_gid, d) = grp.getgrnam(webserver_group) break - except Exception, errmsg: + @@ -350,7 +366,7 @@ pass if webserver_gid is not None: -@@ -280,11 +299,13 @@ password='%s' +@@ -280,11 +306,13 @@ password='%s' for filename in filenames: try: os.chown( @@ -369,7 +385,7 @@ pass httpservice = 'httpd.service' -@@ -300,7 +321,7 @@ password='%s' +@@ -300,7 +328,7 @@ password='%s' elif os.path.isfile('/sbin/service'): subprocess.call('/sbin/service', 'httpd', 'restart') elif os.path.isfile('/usr/sbin/service'): @@ -378,7 +394,7 @@ else: log.error(_("Could not start the webserver server service.")) -@@ -311,6 +332,6 @@ password='%s' +@@ -311,6 +339,6 @@ password='%s' elif os.path.isfile('/usr/sbin/update-rc.d'): subprocess.call('/usr/sbin/update-rc.d', 'apache2', 'defaults') else:
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.