[REVERT] r3591: causing problem to install some modules
[odoo/odoo.git] / bin / tools / config.py
index 50a127b..6ff7935 100644 (file)
@@ -58,6 +58,8 @@ class configmanager(object):
             'xmlrpcs': True,
             'translate_in': None,
             'translate_out': None,
+            'overwrite_existing_translations': False,
+            'load_language': None,
             'language': None,
             'pg_path': None,
             'admin_passwd': 'admin',
@@ -91,15 +93,12 @@ class configmanager(object):
             'static_http_url_prefix': None,
             'secure_cert_file': 'server.cert',
             'secure_pkey_file': 'server.pkey',
-            'maintenance_server': 'http://tiny.my.odoo.com:8069/xmlrpc/',
-            'maintenance_db': 'tiny_belgium',
-            'maintenance_login': 'maintenance',
-            'maintenance_password': 'maintenance',
-            'ping_url': 'http://tiny.my.odoo.com:8069/phonehome.php',
+            'publisher_warranty_url': 'http://services.openerp.com/publisher-warranty/',
+            'osv_memory_count_limit': None, # number of records in each osv_memory virtual table
+            'osv_memory_age_limit': 1, # hours
         }
         
-        self.blacklist_for_save = set(['maintenance_server', 'maintenance_db',
-            'maintenance_login', 'maintenance_password', "ping_url"])
+        self.blacklist_for_save = set(["publisher_warranty_url", "load_language"])
 
         self.misc = {}
         self.config_file = fname
@@ -214,17 +213,30 @@ class configmanager(object):
             "Option '-l' is mandatory in case of importation"
             )
 
+        group.add_option('--load-language', dest="load_language",
+                         help="specifies the languages for the translations you want to be loaded")
         group.add_option('-l', "--language", dest="language",
                          help="specify the language of the translation file. Use it with --i18n-export or --i18n-import")
         group.add_option("--i18n-export", dest="translate_out",
                          help="export all sentences to be translated to a CSV file, a PO file or a TGZ archive and exit")
         group.add_option("--i18n-import", dest="translate_in",
                          help="import a CSV or a PO file with translations and exit. The '-l' option is required.")
+        group.add_option("--i18n-overwrite", dest="overwrite_existing_translations", action="store_true", default=False,
+                         help="overwrites existing translation terms on importing a CSV or a PO file.")
         group.add_option("--modules", dest="translate_modules",
                          help="specify modules to export. Use in combination with --i18n-export")
         group.add_option("--addons-path", dest="addons_path",
                          help="specify an alternative addons path.",
                          action="callback", callback=self._check_addons_path, nargs=1, type="string")
+        group.add_option("--osv-memory-count-limit", dest="osv_memory_count_limit", default=False,
+                         help="Force a limit on the maximum number of records kept in the virtual "
+                              "osv_memory tables. The default is False, which means no count-based limit.",
+                         type="int")
+        group.add_option("--osv-memory-age-limit", dest="osv_memory_age_limit", default=1.0,
+                         help="Force a limit on the maximum age of records kept in the virtual "
+                              "osv_memory tables. This is a decimal value expressed in hours, "
+                              "and the default is 1 hour.",
+                         type="float")
         parser.add_option_group(group)
 
         security = optparse.OptionGroup(parser, 'Security-related options')
@@ -245,6 +257,9 @@ class configmanager(object):
         die(opt.translate_in and (not opt.language or not opt.db_name),
             "the i18n-import option cannot be used without the language (-l) and the database (-d) options")
 
+        die(opt.overwrite_existing_translations and (not opt.translate_in),
+            "the i18n-overwrite option cannot be used without the i18n-import option")
+
         die(opt.translate_out and (not opt.db_name),
             "the i18n-export option cannot be used without the database (-d) option")
 
@@ -290,10 +305,12 @@ class configmanager(object):
                 self.options[arg] = getattr(opt, arg)
 
         keys = [
-            'language', 'translate_out', 'translate_in', 'debug_mode', 'smtp_ssl',
+            'language', 'translate_out', 'translate_in', 'overwrite_existing_translations',
+            'debug_mode', 'smtp_ssl', 'load_language',
             'stop_after_init', 'logrotate', 'without_demo', 'netrpc', 'xmlrpc', 'syslog',
             'list_db', 'xmlrpcs',
-            'test_file', 'test_disable', 'test_commit', 'test_report_directory'
+            'test_file', 'test_disable', 'test_commit', 'test_report_directory',
+            'osv_memory_count_limit', 'osv_memory_age_limit',
         ]
 
         for arg in keys:
@@ -448,7 +465,7 @@ class configmanager(object):
         loglevelnames = dict(zip(self._LOGLEVELS.values(), self._LOGLEVELS.keys()))
         p.add_section('options')
         for opt in sorted(self.options.keys()):
-            if opt in ('version', 'language', 'translate_out', 'translate_in', 'init', 'update'):
+            if opt in ('version', 'language', 'translate_out', 'translate_in', 'overwrite_existing_translations', 'init', 'update'):
                 continue
             if opt in self.blacklist_for_save:
                 continue
@@ -463,11 +480,13 @@ class configmanager(object):
 
         # try to create the directories and write the file
         try:
-            if not os.path.exists(os.path.dirname(self.rcfile)):
+            rc_exists = os.path.exists(self.rcfile)
+            if not rc_exists and not os.path.exists(os.path.dirname(self.rcfile)):
                 os.makedirs(os.path.dirname(self.rcfile))
             try:
                 p.write(file(self.rcfile, 'w'))
-                os.chmod(self.rcfile, 0600)
+                if not rc_exists:
+                    os.chmod(self.rcfile, 0600)
             except IOError:
                 sys.stderr.write("ERROR: couldn't write the config file\n")