本文整理汇总了Python中weblate.trans.util.add_configuration_error函数的典型用法代码示例。如果您正苦于以下问题:Python add_configuration_error函数的具体用法?Python add_configuration_error怎么用?Python add_configuration_error使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了add_configuration_error函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: is_supported
def is_supported(cls):
"""
Checks whether this VCS backend is supported.
"""
if cls._is_supported is not None:
return cls._is_supported
try:
version = cls.get_version()
except OSError:
cls._is_supported = False
return False
if cls.req_version is None:
cls._is_supported = True
elif LooseVersion(version) >= cls.req_version:
cls._is_supported = True
else:
cls._is_supported = False
add_configuration_error(
cls.name.lower(),
'{0} version is too old, please upgrade to {1}.'.format(
cls.name,
cls.req_version
)
)
return cls._is_supported
示例2: test_error
def test_error(self):
add_configuration_error('Test error', 'FOOOOOOOOOOOOOO')
response = self.client.get(reverse('admin:performance'))
self.assertContains(response, 'FOOOOOOOOOOOOOO')
delete_configuration_error('Test error')
response = self.client.get(reverse('admin:performance'))
self.assertNotContains(response, 'FOOOOOOOOOOOOOO')
示例3: test_configuration_health_check
def test_configuration_health_check(self):
add_configuration_error('TEST', 'Message', True)
add_configuration_error('TEST2', 'Message', True)
configuration_health_check(False)
self.assertEqual(ConfigurationError.objects.count(), 2)
delete_configuration_error('TEST2', True)
configuration_health_check(False)
self.assertEqual(ConfigurationError.objects.count(), 1)
configuration_health_check()
示例4: register_fileformat
def register_fileformat(fileformat):
"""
Registers fileformat in dictionary.
"""
try:
fileformat.get_class()
FILE_FORMATS[fileformat.format_id] = fileformat
except (AttributeError, ImportError):
add_configuration_error("File format: {0}".format(fileformat.format_id), traceback.format_exc())
return fileformat
示例5: register_fileformat
def register_fileformat(fileformat):
"""Register fileformat in dictionary."""
try:
fileformat.get_class()
FILE_FORMATS[fileformat.format_id] = fileformat
for autoload in fileformat.autoload:
FILE_DETECT.append((autoload, fileformat))
except (AttributeError, ImportError):
add_configuration_error(
'File format: {0}'.format(fileformat.format_id),
traceback.format_exc()
)
return fileformat
示例6: load_data
def load_data(self):
result = super(FileFormatLoader, self).load_data()
for fileformat in list(result.values()):
try:
fileformat.get_class()
except (AttributeError, ImportError):
add_configuration_error(
'File format: {0}'.format(fileformat.format_id),
traceback.format_exc()
)
result.pop(fileformat.format_id)
return result
示例7: load_data
def load_data(self):
result = super(FileFormatLoader, self).load_data()
for fileformat in list(result.values()):
error_name = 'File format: {0}'.format(fileformat.format_id)
try:
fileformat.get_class()
delete_configuration_error(error_name)
except (AttributeError, ImportError) as error:
result.pop(fileformat.format_id)
if fileformat.format_id == 'rc' and six.PY3:
continue
add_configuration_error(error_name, str(error))
return result
示例8: ready
def ready(self):
# Configure merge driver for Gettext PO
try:
GitRepository.global_setup()
except RepositoryException as error:
add_configuration_error("Git global setup", "Failed to do git setup: {0}".format(error))
# Use it for *.po by default
configdir = os.path.join(data_dir("home"), ".config", "git")
configfile = os.path.join(configdir, "attributes")
if not os.path.exists(configfile):
if not os.path.exists(configdir):
os.makedirs(configdir)
with open(configfile, "w") as handle:
handle.write("*.po merge=weblate-merge-gettext-po\n")
示例9: ready
def ready(self):
# Configure merge driver for Gettext PO
try:
GitRepository.global_setup()
except RepositoryException as error:
add_configuration_error(
'Git global setup',
'Failed to do git setup: {0}'.format(error)
)
# Use it for *.po by default
configdir = os.path.join(data_dir('home'), '.config', 'git')
configfile = os.path.join(configdir, 'attributes')
if not os.path.exists(configfile):
if not os.path.exists(configdir):
os.makedirs(configdir)
with open(configfile, 'w') as handle:
handle.write('*.po merge=weblate-merge-gettext-po\n')
示例10: generate_gpg_key
def generate_gpg_key():
try:
subprocess.check_output(
[
'gpg',
'--batch',
'--pinentry-mode', 'loopback',
'--passphrase', '',
'--quick-generate-key',
settings.WEBLATE_GPG_IDENTITY,
settings.WEBLATE_GPG_ALGO,
'default', 'never',
],
stderr=subprocess.STDOUT,
env=get_clean_env(),
)
return get_gpg_key()
except (subprocess.CalledProcessError, OSError) as exc:
add_configuration_error('GPG key generating', force_text(exc))
return None
示例11: get_gpg_key
def get_gpg_key(silent=False):
try:
output = subprocess.check_output(
[
'gpg',
'--batch',
'--with-colons',
'--list-secret-keys',
settings.WEBLATE_GPG_IDENTITY,
],
stderr=subprocess.STDOUT,
env=get_clean_env(),
).decode('utf-8')
for line in output.splitlines():
if not line.startswith('fpr:'):
continue
return line.split(':')[9]
return None
except (subprocess.CalledProcessError, OSError) as exc:
if not silent:
add_configuration_error('GPG key listing', force_text(exc))
return None
示例12: get_gpg_public_key
def get_gpg_public_key():
key = get_gpg_sign_key()
if key is None:
return None
data = cache.get('gpg-key-public')
if not data:
try:
data = subprocess.check_output(
[
'gpg',
'--batch',
'-armor',
'--export',
key,
],
stderr=subprocess.STDOUT,
env=get_clean_env(),
).decode('utf-8')
cache.set('gpg-key-public', data, 7 * 86400)
except (subprocess.CalledProcessError, OSError) as exc:
add_configuration_error('GPG key public', force_text(exc))
return None
return data
示例13: is_supported
def is_supported(cls):
"""Check whether this VCS backend is supported."""
if cls._is_supported is not None:
return cls._is_supported
try:
version = cls.get_version()
except (OSError, RepositoryException):
cls._is_supported = False
return False
if (cls.req_version is None or
LooseVersion(version) >= LooseVersion(cls.req_version)):
cls._is_supported = True
delete_configuration_error(cls.name.lower())
else:
cls._is_supported = False
add_configuration_error(
cls.name.lower(),
'{0} version is too old, please upgrade to {1}.'.format(
cls.name,
cls.req_version
)
)
return cls._is_supported
示例14: test_error
def test_error(self):
add_configuration_error("Test error", "FOOOOOOOOOOOOOO")
response = self.client.get(reverse("admin-performance"))
self.assertContains(response, "FOOOOOOOOOOOOOO")