update_config: Set database.module to pyPgSQL only when psycopg2 v0.6.x
authorPascal Volk <neverseen@users.sourceforge.net>
Wed, 26 Oct 2011 23:32:58 +0000
branchv0.6.x
changeset 436 d296a020f440
parent 435 ee6f8ac06197
child 437 9823548b2717
update_config: Set database.module to pyPgSQL only when psycopg2 is unavailable.
update_config.py
--- a/update_config.py	Wed Oct 26 18:55:30 2011 +0000
+++ b/update_config.py	Wed Oct 26 23:32:58 2011 +0000
@@ -10,6 +10,12 @@
 from shutil import copy2
 from VirtualMailManager.constants.VERSION import VERSION
 
+try:
+    import psycopg2
+except ImportError:
+    has_psycopg2 = False
+else:
+    has_psycopg2 = True
 
 def get_config_file():
     f = None
@@ -110,7 +116,8 @@
                      ('misc.dovecotvers',  'misc.dovecot_version')):
         move_option(cp, src, dst)
     cp.remove_section('maildir')
-    add_option(cp, 'database.module', 'pyPgSQL')
+    if not has_psycopg2:
+        add_option(cp, 'database.module', 'pyPgSQL')
     set_dovecot_version(cp)