try:
from OpenSSL import SSL
import socket
-
- return hasattr(socket, 'ssl')
+
+ return hasattr(socket, 'ssl') and hasattr(SSL, "Connection")
except:
return False
'xmlrpcs': True,
'translate_in': None,
'translate_out': None,
+ 'overwrite_existing_translations': False,
+ 'load_language': None,
'language': None,
'pg_path': None,
'admin_passwd': 'admin',
'static_http_url_prefix': None,
'secure_cert_file': 'server.cert',
'secure_pkey_file': 'server.pkey',
+ '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(["publisher_warranty_url", "load_language"])
self.misc = {}
self.config_file = fname
"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')
parser.add_option_group(security)
def parse_config(self):
- (opt, args) = self.parser.parse_args()
+ opt = self.parser.parse_args()[0]
def die(cond, msg):
if cond:
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")
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:
# If an explicit TZ was provided in the config, make sure it is known
try:
import pytz
- tz = pytz.timezone(self.options['timezone'])
+ pytz.timezone(self.options['timezone'])
except pytz.UnknownTimeZoneError:
die(True, "The specified timezone (%s) is invalid" % self.options['timezone'])
except:
fp.close()
if is_win32:
- import _winreg
+ try:
+ import _winreg
+ except ImportError:
+ _winreg = None
x=_winreg.ConnectRegistry(None,_winreg.HKEY_LOCAL_MACHINE)
y = _winreg.OpenKey(x, r"SYSTEM\CurrentControlSet\Control\Session Manager\Environment", 0,_winreg.KEY_ALL_ACCESS)
_winreg.SetValueEx(y,"PGPASSFILE", 0, _winreg.REG_EXPAND_SZ, filename )
p = ConfigParser.ConfigParser()
loglevelnames = dict(zip(self._LOGLEVELS.values(), self._LOGLEVELS.keys()))
p.add_section('options')
- for opt in self.options.keys():
- if opt in ('version', 'language', 'translate_out', 'translate_in', 'init', 'update'):
+ for opt in sorted(self.options.keys()):
+ if opt in ('version', 'language', 'translate_out', 'translate_in', 'overwrite_existing_translations', 'init', 'update'):
+ continue
+ if opt in self.blacklist_for_save:
continue
if opt in ('log_level', 'assert_exit_level'):
p.set('options', opt, loglevelnames.get(self.options[opt], self.options[opt]))
else:
p.set('options', opt, self.options[opt])
- for sec in self.misc.keys():
- for opt in self.misc[sec].keys():
+ for sec in sorted(self.misc.keys()):
+ for opt in sorted(self.misc[sec].keys()):
p.set(sec,opt,self.misc[sec][opt])
# 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")