5 commits - configure.ac pykolab/setup pykolab/utils.py setup-kolab.py
Jeroen van Meeuwen
vanmeeuwen at kolabsys.com
Sat May 5 22:32:49 CEST 2012
configure.ac | 2
pykolab/setup/setup_freebusy.py | 129 +++++++++++++++++++++++++++++++++++++++
pykolab/setup/setup_roundcube.py | 4 -
pykolab/setup/setup_zpush.py | 97 +++++++++++++++++++++++++++++
pykolab/utils.py | 5 -
setup-kolab.py | 2
6 files changed, 230 insertions(+), 9 deletions(-)
New commits:
commit 06cf3d5976d3a495d2ccce1b71bddc2465368bba
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date: Sat May 5 20:31:47 2012 +0100
Bump pre-release
diff --git a/configure.ac b/configure.ac
index b27202c..a0d03ed 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,5 +1,5 @@
AC_INIT([pykolab], 0.4)
-AC_SUBST([RELEASE], 0.15)
+AC_SUBST([RELEASE], 0.16)
AC_CONFIG_SRCDIR(pykolab/constants.py.in)
commit cf383257f7abe863ddca8eabb20464409c7f0e53
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date: Sat May 5 20:31:16 2012 +0100
Correct running in unbuffered mode
diff --git a/pykolab/utils.py b/pykolab/utils.py
index c40b252..0ba203a 100644
--- a/pykolab/utils.py
+++ b/pykolab/utils.py
@@ -35,11 +35,6 @@ def ask_question(question, default="", password=False):
Usage: pykolab.utils.ask_question("What is the server?", default="localhost")
"""
-
- # Remove any buffering that may exist
- sys.stderr = os.fdopen(sys.stderr.fileno(), 'w', 0)
- sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 0)
-
if password:
if default == "":
answer = getpass.getpass("%s: " % (question))
@@ -62,11 +57,6 @@ def ask_confirmation(question, default="y", all_inclusive_no=True):
and a "yes" or "no" parsing that can either require an explicit, full
"yes" or "no", or take the default or any YyNn answer.
"""
-
- # Remove any buffering that may exist
- sys.stderr = os.fdopen(sys.stderr.fileno(), 'w', 0)
- sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 0)
-
if default in [ "y", "Y" ]:
default_answer = True
default_no = "n"
diff --git a/setup-kolab.py b/setup-kolab.py
index edb9f90..34818a7 100755
--- a/setup-kolab.py
+++ b/setup-kolab.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python -tt
+#!/usr/bin/python -u
# -*- coding: utf-8 -*-
#
# Copyright 2010-2012 Kolab Systems AG (http://www.kolabsys.com)
commit 168171fc34e65879fd6d25a9e4795caabc0e0af8
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date: Sat May 5 17:11:45 2012 +0100
Bump pre-release
diff --git a/configure.ac b/configure.ac
index 0caa293..b27202c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,5 +1,5 @@
AC_INIT([pykolab], 0.4)
-AC_SUBST([RELEASE], 0.14)
+AC_SUBST([RELEASE], 0.15)
AC_CONFIG_SRCDIR(pykolab/constants.py.in)
commit 0a151c662c67c17cffeee7e80e04a6348f0516af
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date: Sat May 5 17:11:07 2012 +0100
Add freebusy and zpush setup routines
Restart httpd server rather then starting it
diff --git a/pykolab/setup/setup_freebusy.py b/pykolab/setup/setup_freebusy.py
new file mode 100644
index 0000000..6dbecab
--- /dev/null
+++ b/pykolab/setup/setup_freebusy.py
@@ -0,0 +1,129 @@
+# -*- coding: utf-8 -*-
+# Copyright 2010-2012 Kolab Systems AG (http://www.kolabsys.com)
+#
+# Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen a kolabsys.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 3 or, at your option, any later version
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Library General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+
+from Cheetah.Template import Template
+import os
+import subprocess
+import sys
+
+import components
+
+import pykolab
+
+from pykolab import utils
+from pykolab.constants import *
+from pykolab.translate import _
+
+log = pykolab.getLogger('pykolab.setup')
+conf = pykolab.getConf()
+
+def __init__():
+ components.register('freebusy', execute, description=description(), after=['mysql','ldap', 'roundcube'])
+
+def description():
+ return _("Setup Free/Busy.")
+
+def execute(*args, **kw):
+ if not os.path.isfile('/etc/kolab/freebusy/config.php'):
+ log.error(_("Free/Busy is not installed on this system"))
+ return
+
+ horde_settings = {
+ 'ldap_base_dn': conf.get('ldap', 'base_dn'),
+ 'ldap_ldap_uri': conf.get('ldap', 'ldap_uri'),
+ 'ldap_service_bind_dn': conf.get('ldap', 'service_bind_dn'),
+ 'ldap_service_bind_pw': conf.get('ldap', 'service_bind_pw'),
+ 'primary_domain': conf.get('kolab', 'primary_domain'),
+ 'roundcube_mysql_password': conf.mysql_roundcube_password
+ }
+
+ want_files = [
+ 'conf.d/10-kolab_conf_base.php',
+ ]
+
+ for want_file in want_files:
+ template_file = None
+ if os.path.isfile('/etc/kolab/templates/horde/%s.tpl' % (want_file)):
+ template_file = '/etc/kolab/templates/horde/%s.tpl' % (want_file)
+ elif os.path.isfile('/usr/share/kolab/templates/horde/%s.tpl' % (want_file)):
+ template_file = '/usr/share/kolab/templates/horde/%s.tpl' % (want_file)
+ elif os.path.isfile(os.path.abspath(os.path.join(__file__, '..', '..', '..', 'share', 'templates', 'horde', '%s.tpl' % (want_file)))):
+ template_file = os.path.abspath(os.path.join(__file__, '..', '..', '..', 'share', 'templates', 'horde', '%s.tpl' % (want_file)))
+
+ if not template_file == None:
+ log.debug(_("Using template file %r") % (template_file), level=8)
+ fp = open(template_file, 'r')
+ template_definition = fp.read()
+ fp.close()
+
+ t = Template(template_definition, searchList=[horde_settings])
+ log.debug(
+ _("Successfully compiled template %r, writing out to %r") % (
+ template_file,
+ '/etc/horde/%s' % (want_file)
+ ),
+ level=8
+ )
+
+ fp = open('/etc/horde/%s' % (want_file), 'w')
+ fp.write(t.__str__())
+ fp.close()
+
+ want_files = [
+ 'config.php',
+ ]
+
+ for want_file in want_files:
+ template_file = None
+ if os.path.isfile('/etc/kolab/templates/freebusy/%s.tpl' % (want_file)):
+ template_file = '/etc/kolab/templates/freebusy/%s.tpl' % (want_file)
+ elif os.path.isfile('/usr/share/kolab/templates/freebusy/%s.tpl' % (want_file)):
+ template_file = '/usr/share/kolab/templates/freebusy/%s.tpl' % (want_file)
+ elif os.path.isfile(os.path.abspath(os.path.join(__file__, '..', '..', '..', 'share', 'templates', 'freebusy', '%s.tpl' % (want_file)))):
+ template_file = os.path.abspath(os.path.join(__file__, '..', '..', '..', 'share', 'templates', 'freebusy', '%s.tpl' % (want_file)))
+
+ if not template_file == None:
+ log.debug(_("Using template file %r") % (template_file), level=8)
+ fp = open(template_file, 'r')
+ template_definition = fp.read()
+ fp.close()
+
+ t = Template(template_definition, searchList=[freebusy_settings])
+ log.debug(
+ _("Successfully compiled template %r, writing out to %r") % (
+ template_file,
+ '/etc/freebusy/%s' % (want_file)
+ ),
+ level=8
+ )
+
+ fp = open('/etc/kolab/freebusy/%s' % (want_file), 'w')
+ fp.write(t.__str__())
+ fp.close()
+
+ if os.path.isfile('/bin/systemctl'):
+ subprocess.call(['/bin/systemctl', 'restart', 'httpd.service'])
+ subprocess.call(['/bin/systemctl', 'enable', 'httpd.service'])
+ elif os.path.isfile('/sbin/service'):
+ subprocess.call(['/sbin/service', 'httpd', 'restart'])
+ subprocess.call(['/sbin/chkconfig', 'httpd', 'on'])
+ else:
+ log.error(_("Could not start and configure to start on boot, the " + \
+ "webserver service."))
+
diff --git a/pykolab/setup/setup_roundcube.py b/pykolab/setup/setup_roundcube.py
index 75c400e..cd6e5d2 100644
--- a/pykolab/setup/setup_roundcube.py
+++ b/pykolab/setup/setup_roundcube.py
@@ -150,10 +150,10 @@ def execute(*args, **kw):
p2.communicate()
if os.path.isfile('/bin/systemctl'):
- subprocess.call(['/bin/systemctl', 'start', 'httpd.service'])
+ subprocess.call(['/bin/systemctl', 'restart', 'httpd.service'])
subprocess.call(['/bin/systemctl', 'enable', 'httpd.service'])
elif os.path.isfile('/sbin/service'):
- subprocess.call(['/sbin/service', 'httpd', 'start'])
+ subprocess.call(['/sbin/service', 'httpd', 'restart'])
subprocess.call(['/sbin/chkconfig', 'httpd', 'on'])
else:
log.error(_("Could not start and configure to start on boot, the " + \
diff --git a/pykolab/setup/setup_zpush.py b/pykolab/setup/setup_zpush.py
new file mode 100644
index 0000000..01739c3
--- /dev/null
+++ b/pykolab/setup/setup_zpush.py
@@ -0,0 +1,97 @@
+# -*- coding: utf-8 -*-
+# Copyright 2010-2012 Kolab Systems AG (http://www.kolabsys.com)
+#
+# Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen a kolabsys.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 3 or, at your option, any later version
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Library General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+
+from Cheetah.Template import Template
+import os
+import subprocess
+import sys
+
+import components
+
+import pykolab
+
+from pykolab import utils
+from pykolab.constants import *
+from pykolab.translate import _
+
+log = pykolab.getLogger('pykolab.setup')
+conf = pykolab.getConf()
+
+def __init__():
+ components.register('zpush', execute, description=description(), after=['mysql','ldap'])
+
+def description():
+ return _("Setup zpush.")
+
+def execute(*args, **kw):
+ if not os.path.isfile('/etc/z-push/config.php'):
+ log.error(_("Z-Push is not installed on this system"))
+ return
+
+ zpush_settings = {
+ 'ldap_base_dn': conf.get('ldap', 'base_dn'),
+ 'ldap_ldap_uri': conf.get('ldap', 'ldap_uri'),
+ 'ldap_service_bind_dn': conf.get('ldap', 'service_bind_dn'),
+ 'ldap_service_bind_pw': conf.get('ldap', 'service_bind_pw'),
+ 'imap_server': "localhost"
+ }
+
+
+ want_files = [
+ 'config.php',
+ ]
+
+ for want_file in want_files:
+ template_file = None
+ if os.path.isfile('/etc/kolab/templates/zpush/%s.tpl' % (want_file)):
+ template_file = '/etc/kolab/templates/zpush/%s.tpl' % (want_file)
+ elif os.path.isfile('/usr/share/kolab/templates/zpush/%s.tpl' % (want_file)):
+ template_file = '/usr/share/kolab/templates/zpush/%s.tpl' % (want_file)
+ elif os.path.isfile(os.path.abspath(os.path.join(__file__, '..', '..', '..', 'share', 'templates', 'zpush', '%s.tpl' % (want_file)))):
+ template_file = os.path.abspath(os.path.join(__file__, '..', '..', '..', 'share', 'templates', 'zpush', '%s.tpl' % (want_file)))
+
+ if not template_file == None:
+ log.debug(_("Using template file %r") % (template_file), level=8)
+ fp = open(template_file, 'r')
+ template_definition = fp.read()
+ fp.close()
+
+ t = Template(template_definition, searchList=[zpush_settings])
+ log.debug(
+ _("Successfully compiled template %r, writing out to %r") % (
+ template_file,
+ '/etc/z-push/%s' % (want_file)
+ ),
+ level=8
+ )
+
+ fp = open('/etc/z-push/%s' % (want_file), 'w')
+ fp.write(t.__str__())
+ fp.close()
+
+ if os.path.isfile('/bin/systemctl'):
+ subprocess.call(['/bin/systemctl', 'restart', 'httpd.service'])
+ subprocess.call(['/bin/systemctl', 'enable', 'httpd.service'])
+ elif os.path.isfile('/sbin/service'):
+ subprocess.call(['/sbin/service', 'httpd', 'restart'])
+ subprocess.call(['/sbin/chkconfig', 'httpd', 'on'])
+ else:
+ log.error(_("Could not start and configure to start on boot, the " + \
+ "webserver service."))
+
commit b3ff42571c0edab8e5b3c064ba3a488a1b534bab
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date: Sat May 5 17:10:23 2012 +0100
Truly remove any buffering that may exist
diff --git a/pykolab/utils.py b/pykolab/utils.py
index 63aacb7..c40b252 100644
--- a/pykolab/utils.py
+++ b/pykolab/utils.py
@@ -35,6 +35,11 @@ def ask_question(question, default="", password=False):
Usage: pykolab.utils.ask_question("What is the server?", default="localhost")
"""
+
+ # Remove any buffering that may exist
+ sys.stderr = os.fdopen(sys.stderr.fileno(), 'w', 0)
+ sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 0)
+
if password:
if default == "":
answer = getpass.getpass("%s: " % (question))
@@ -46,9 +51,6 @@ def ask_question(question, default="", password=False):
else:
answer = raw_input("%s [%s]: " % (question, default))
- sys.stderr.flush()
- sys.stdout.flush()
-
if answer == "":
return default
else:
@@ -61,6 +63,10 @@ def ask_confirmation(question, default="y", all_inclusive_no=True):
"yes" or "no", or take the default or any YyNn answer.
"""
+ # Remove any buffering that may exist
+ sys.stderr = os.fdopen(sys.stderr.fileno(), 'w', 0)
+ sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 0)
+
if default in [ "y", "Y" ]:
default_answer = True
default_no = "n"
@@ -94,7 +100,6 @@ def ask_confirmation(question, default="y", all_inclusive_no=True):
else:
answer = False
print >> sys.stderr, _("Please answer 'yes' or 'no'.")
- sys.stderr.flush()
def generate_password():
import subprocess
More information about the commits
mailing list