本文整理汇总了Python中config.Configuration方法的典型用法代码示例。如果您正苦于以下问题:Python config.Configuration方法的具体用法?Python config.Configuration怎么用?Python config.Configuration使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类config
的用法示例。
在下文中一共展示了config.Configuration方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: change_wallpaper
# 需要导入模块: import config [as 别名]
# 或者: from config import Configuration [as 别名]
def change_wallpaper():
config = Configuration()
source = config.get('source')
random = config.get('random')
if random:
modules = get_modules()
selected = randrange(len(modules))
source = modules[selected]
module = importlib.import_module(source)
daily = module.get_daily()
if daily.resolve_url():
if download(daily.get_url()):
if daily.get_title():
title = '{}: {}'.format(daily.get_name(), daily.get_title())
else:
title = daily.get_name()
caption = daily.get_caption()
credit = daily.get_credit()
notify_photo_caption(title, caption, credit)
set_background(comun.POTD)
示例2: post
# 需要导入模块: import config [as 别名]
# 或者: from config import Configuration [as 别名]
def post(self, request, *args, **kwargs):
"""Serves POST requests, updating the repo's configuration."""
del request, args, kwargs # Unused.
self.enforce_xsrf(self.ACTION_ID)
validation_response = self._validate_input()
if validation_response:
return validation_response
self._set_language_config()
self._set_activation_config()
self._set_data_retention_config()
self._set_keywords_config()
self._set_forms_config()
self._set_map_config()
self._set_timezone_config()
self._set_api_access_control_config()
self._set_zero_rating_config()
self._set_spam_config()
# Reload the config since we just changed it.
self.env.config = config.Configuration(self.env.repo)
return self._render_form()
示例3: post
# 需要导入模块: import config [as 别名]
# 或者: from config import Configuration [as 别名]
def post(self, request, *args, **kwargs):
"""Serves POST requests, updating the repo's configuration."""
del request, args, kwargs # Unused.
self.enforce_xsrf(self.ACTION_ID)
validation_response = self._validate_input()
if validation_response:
return validation_response
self._set_sms_config()
self._set_repo_alias_config()
self._set_site_info_config()
self._set_recaptcha_config()
self._set_ganalytics_config()
self._set_gmaps_config()
self._set_gtranslate_config()
self._set_notification_config()
# Reload the config since we just changed it.
self.env.config = config.Configuration('*')
return self._render_form()
示例4: test_edit_activation_status_config
# 需要导入模块: import config [as 别名]
# 或者: from config import Configuration [as 别名]
def test_edit_activation_status_config(self):
# Set the time to an hour past the original update_date.
utils.set_utcnow_for_test(datetime.datetime(2019, 5, 10, 12, 15, 0))
self.login_as_superadmin()
self._post_with_params(
activation_status=str(model.Repo.ActivationStatus.DEACTIVATED),
deactivation_message_html='it is deactivated')
repo = model.Repo.get_by_key_name('haiti')
self.assertEqual(
repo.activation_status, model.Repo.ActivationStatus.DEACTIVATED)
repo_conf = config.Configuration('haiti')
self.assertEqual(
repo_conf.deactivation_message_html, 'it is deactivated')
self.assertEqual(
repo_conf.updated_date,
utils.get_timestamp(datetime.datetime(2019, 5, 10, 12, 15, 0)))
示例5: test_edit_forms_config
# 需要导入模块: import config [as 别名]
# 或者: from config import Configuration [as 别名]
def test_edit_forms_config(self):
self.login_as_superadmin()
self._post_with_params(
use_family_name='true',
family_name_first='true',
use_alternate_names='true',
use_postal_code='true',
allow_believed_dead_via_ui='true',
min_query_word_length='2',
show_profile_entry='true',
# The value for this doesn't really matter.
profile_websites='{"arbitrary": "json"}')
repo_conf = config.Configuration('haiti')
self.assertIs(repo_conf.use_family_name, True)
self.assertIs(repo_conf.family_name_first, True)
self.assertIs(repo_conf.use_alternate_names, True)
self.assertIs(repo_conf.use_postal_code, True)
self.assertIs(repo_conf.allow_believed_dead_via_ui, True)
self.assertEqual(repo_conf.min_query_word_length, 2)
self.assertIs(repo_conf.show_profile_entry, True)
self.assertEqual(repo_conf.profile_websites, {'arbitrary': 'json'})
示例6: test_manager_edit_restrictions
# 需要导入模块: import config [as 别名]
# 或者: from config import Configuration [as 别名]
def test_manager_edit_restrictions(self):
self.login_as_manager()
self._post_with_params(
use_family_name='true',
family_name_first='true',
use_alternate_names='true',
use_postal_code='true',
allow_believed_dead_via_ui='true',
min_query_word_length='2',
show_profile_entry='true',
map_default_zoom='8',
map_default_center='[32.7, 85.6]',
map_size_pixels='[300, 450]',
time_zone_offset='5.75',
time_zone_abbreviation='NPT',
search_auth_key_required='true',
read_auth_key_required='true',
zero_rating_mode='true',
bad_words='voldemort')
repo_conf = config.Configuration('haiti')
for key, value in AdminRepoIndexViewTests._PRIOR_CONFIG.items():
self.assertEqual(repo_conf.get(key), value)
示例7: test_create_repo
# 需要导入模块: import config [as 别名]
# 或者: from config import Configuration [as 别名]
def test_create_repo(self):
"""Tests POST requests to create a new repo."""
get_doc = self.to_doc(self.client.get(
'/global/admin/create_repo/', secure=True))
xsrf_token = get_doc.cssselect_one('input[name="xsrf_token"]').get(
'value')
post_resp = self.client.post('/global/admin/create_repo/', {
'xsrf_token': xsrf_token,
'new_repo': 'idaho'
}, secure=True)
# Check that the user's redirected to the repo's main admin page.
self.assertIsInstance(post_resp, django.http.HttpResponseRedirect)
self.assertEqual(post_resp.url, '/idaho/admin')
# Check that the repo object is put in datastore.
repo = model.Repo.get_by_key_name('idaho')
self.assertIsNotNone(repo)
self.assertEqual(
repo.activation_status, model.Repo.ActivationStatus.STAGING)
self.assertIs(repo.test_mode, False)
# Check a couple of the config fields that are set by default.
repo_conf = config.Configuration('idaho')
self.assertEqual(repo_conf.language_menu_options, ['en', 'fr'])
self.assertIs(repo_conf.launched, False)
self.assertEqual(repo_conf.time_zone_abbreviation, 'UTC')
示例8: load_preferences
# 需要导入模块: import config [as 别名]
# 或者: from config import Configuration [as 别名]
def load_preferences(self):
config = Configuration()
select_value_in_combo(self.combobox_source, config.get('source'))
self.switch_random.set_active(config.get('random'))
self.set_source_state(not config.get('random'))
示例9: save_preferences
# 需要导入模块: import config [as 别名]
# 或者: from config import Configuration [as 别名]
def save_preferences(self):
config = Configuration()
config.set('source', get_selected_value_in_combo(self.combobox_source))
config.set('random', self.switch_random.get_active())
config.save()
示例10: process
# 需要导入模块: import config [as 别名]
# 或者: from config import Configuration [as 别名]
def process(self, repo_patch, alert_callback=None):
data = u'\n'.join(repo_patch.diff.additions).encode('utf-8').strip()
def _alert_callback(alert_action):
alert_config_key = alert_action.get("alert config")
alert_config = self._alert_configs.get(alert_config_key)
if alert_config is None:
logger.error("Alert config for [%s] is None", alert_config_key);
return
if alert_config.get("email"):
default_email = config.Configuration('config.json').get(('email', 'to'))
to_email = alert_config.get("email", default_email)
patch_lines = u'\n'.join(repo_patch.diff.additions).encode('utf-8').strip()
subject = alert_action.get("subject","Unknown Subject")
(text, html) = self.create_alert_email(subject, data, repo_patch.repo_commit)
ea = EmailAlert(Alert(subject=subject,
message=text.encode('utf-8'),
message_html=html.encode('utf-8')),
to_email=to_email)
if (self.test_mode == True):
print ea
else:
ea.send()
else:
logger.warn("Alert type unknown %s" % (alert_config))
if alert_callback is None:
alert_callback = _alert_callback
#data = repo_patch
for rule in self._rules:
self._process(data, rule, alert_callback)
示例11: __init__
# 需要导入模块: import config [as 别名]
# 或者: from config import Configuration [as 别名]
def __init__(self, alert=None, creds=None):
configuration = config.Configuration('config.json')
self.server = configuration.get(('email', 'host'))
self.to_email = configuration.get(('email', 'to'))
self.from_email = self.to_email
self.creds=creds
self.alert=alert
示例12: setUp
# 需要导入模块: import config [as 别名]
# 或者: from config import Configuration [as 别名]
def setUp(self):
configuration = config.Configuration('tests/plugins/test_pluginloader.config.json')
self.plugins = Plugins(configuration)
示例13: set_global_config
# 需要导入模块: import config [as 别名]
# 或者: from config import Configuration [as 别名]
def set_global_config():
configuration = config.Configuration('config.json')
config.providence_configuration = configuration
return configuration
示例14: register_repositories
# 需要导入模块: import config [as 别名]
# 或者: from config import Configuration [as 别名]
def register_repositories(self):
# links each repo in config.json to their corresponding credentials
logger.debug("registering repository")
configuration = config.Configuration('config.json')
repos = {}
for repo in configuration.get('repos'):
repo_type = repo.get('type')
if repo_type == 'perforce':
repo_name = repo.get('name')
creds = config.credential_manager.get_or_create_credentials_for(repo_name, "password")
if creds is None:
logger.error("Failed to load credentials")
return {}
repo_source = PerforceSource(creds=creds, port=repo.get('server'), directory=repo.get('directory'))
repos[repo_name] = {"source":repo_source, "check-every-x-minutes":10}
elif repo_type == 'github':
repo_name = repo.get('name')
creds = config.credential_manager.get_or_create_credentials_for(repo_name, "password")
if creds is None:
logger.error("Failed to load credentials")
return {}
repo_source = GithubSource(creds=creds, host=repo.get('server'), owner=repo.get('owner'), repo=repo.get('directory'))
repos[repo_name] = {"source":repo_source, "check-every-x-minutes":10}
else:
print "Repo Type not supported yet: " + repo_type
return repos
示例15: parse_configs
# 需要导入模块: import config [as 别名]
# 或者: from config import Configuration [as 别名]
def parse_configs(config_files, base_em_dir):
global is_cuda
is_cuda = True
configs = []
for config_file in config_files:
config_file = base_em_dir+config_file+"/config.yaml"
config = configuration.Configuration(model_type, config_file)
config = config.config_dict
is_cuda &= True if (str(config['gpu_core_num']).lower() != "none" and torch.cuda.is_available()) else False
model = get_model(config)
config_obj = {}
config_obj['model'] = model
config_obj['config']= config
configs.append(config_obj)
return configs
开发者ID:hossein1387,项目名称:U-Net-Fixed-Point-Quantization-for-Medical-Image-Segmentation,代码行数:17,代码来源:get_nih_result.py