当前位置: 首页>>代码示例>>Python>>正文


Python error.InternalError类代码示例

本文整理汇总了Python中error.InternalError的典型用法代码示例。如果您正苦于以下问题:Python InternalError类的具体用法?Python InternalError怎么用?Python InternalError使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了InternalError类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get

def get(class_name, id_):
	InternalError.check(class_name in _translations, code=InternalError.ASSERTION,
	                    message="tried to access a not-managed class in hierarchy", data={"class_name": class_name})
	obj = _translations[class_name]['get'](id_)
	UserError.check(obj is not None, UserError.ENTITY_DOES_NOT_EXIST, message="entity doesn't exist.",
	                data={"class_name": class_name, "id_": id_})
	return obj
开发者ID:GLab,项目名称:ToMaTo,代码行数:7,代码来源:hierarchy.py

示例2: get_github_settings

	def get_github_settings(self):
		"""
		get the github config
		:return: the github config, a dict containing 'access-token', 'repository-owner', 'repository-name'
		:rtype: dict(str)
		"""
		InternalError.check('github' in self.original_settings, code=InternalError.CONFIGURATION_ERROR, message="github not configured")
		return {k: v for k, v in self.original_settings['github'].iteritems()}
开发者ID:gitter-badger,项目名称:ToMaTo,代码行数:8,代码来源:settings.py

示例3: get_host_connections_settings

	def get_host_connections_settings(self):
		"""
		get host connections settings
		:return: dict containing 'update-interval', 'availability-halftime', 'resource-sync-interval', 'component-timeout'
		:rtype: dict
		"""
		InternalError.check('host-connections' in self.original_settings[self.tomato_module], code=InternalError.CONFIGURATION_ERROR, message="host connection configuration missing")
		return {k: v for k, v in self.original_settings[self.tomato_module]['host-connections'].iteritems()}
开发者ID:gitter-badger,项目名称:ToMaTo,代码行数:8,代码来源:settings.py

示例4: get_bittorrent_settings

	def get_bittorrent_settings(self):
		"""
		bittorrent settings
		:return: dict containing 'tracker-port' and 'bittorrent-restart'
		:rtype: dict
		"""
		InternalError.check('bittorrent' in self.original_settings[self.tomato_module], code=InternalError.CONFIGURATION_ERROR, message="bittorrent configuration missing")
		return {k: v for k, v in self.original_settings[self.tomato_module]['bittorrent'].iteritems()}
开发者ID:gitter-badger,项目名称:ToMaTo,代码行数:8,代码来源:settings.py

示例5: get_account_info_update_interval

	def get_account_info_update_interval(self):
		"""
		get the interval in which to update user account info
		:return: interval in seconds
		:rtype: int
		"""
		InternalError.check('account-info-update-interval' in self.original_settings[self.tomato_module], code=InternalError.CONFIGURATION_ERROR, message="account-info-update-interval configuration missing")
		return self.original_settings[self.tomato_module]['account-info-update-interval']
开发者ID:gitter-badger,项目名称:ToMaTo,代码行数:8,代码来源:settings.py

示例6: get_duration_log_settings

	def get_duration_log_settings(self):
		"""
		get duration log settings
		:return: dict containing 'enabled', 'location', 'size'
		:rtype: dict
		"""
		InternalError.check('duration-log' in self.original_settings[self.tomato_module], code=InternalError.CONFIGURATION_ERROR, message="duration log configuration missing")
		return {k: v for k, v in self.original_settings[self.tomato_module]['duration-log'].iteritems()}
开发者ID:gitter-badger,项目名称:ToMaTo,代码行数:8,代码来源:settings.py

示例7: get_tasks_settings

	def get_tasks_settings(self):
		"""
		get the tasks settings of the current module
		:return: dict containing Config.TASKS_MAX_WORKERS
		:rtype: dict
		"""
		InternalError.check('tasks' in self.original_settings[self.tomato_module], code=InternalError.CONFIGURATION_ERROR, message="tasks configuration missing")
		return self.original_settings[self.tomato_module]['tasks']
开发者ID:gitter-badger,项目名称:ToMaTo,代码行数:8,代码来源:settings.py

示例8: get_template_dir

	def get_template_dir(self):
		"""
		get the directory where templates will be stored
		:return: directory path
		:rtype: str
		"""
		InternalError.check('templates' in self.original_settings[self.tomato_module]['paths'], code=InternalError.CONFIGURATION_ERROR, message="template directory missing")
		return self.original_settings[self.tomato_module]['paths']['templates']
开发者ID:gitter-badger,项目名称:ToMaTo,代码行数:8,代码来源:settings.py

示例9: get_user_quota

	def get_user_quota(self, config_name):
		"""
		get quota parameters for the configuration configured in settings under this name
		:param str config_name: name of the configuration in settings (/user-quota/[config_name])
		:return: dict containing 'cputime', 'memory', 'diskspace', 'traffic', 'continous-factor'
		:rtype: dict
		"""
		InternalError.check(config_name in self.original_settings['user-quota'], code=InternalError.INVALID_PARAMETER, message="No such quota config", data={"config_name": config_name})
		return {k: v for k, v in self.original_settings['user-quota'][config_name].iteritems()}
开发者ID:gitter-badger,项目名称:ToMaTo,代码行数:9,代码来源:settings.py

示例10: get_web_resource_location

	def get_web_resource_location(self, resource_type):
		"""
		get the url to the specified web resource (Config.WEB_RESOURCE_*)
		:return: url to the resource list
		:rtype: str
		"""
		InternalError.check('web-resources' in self.original_settings[self.tomato_module], code=InternalError.CONFIGURATION_ERROR, message="web resource configuration missing")
		InternalError.check(resource_type in self.original_settings[self.tomato_module]['web-resources'], code=InternalError.INVALID_PARAMETER, message="No such web resource type", data={"resource_type": resource_type})
		return self.original_settings[self.tomato_module]['web-resources'][resource_type]
开发者ID:gitter-badger,项目名称:ToMaTo,代码行数:9,代码来源:settings.py

示例11: get_dumpmanager_enabled

	def get_dumpmanager_enabled(self, tomato_module):
		"""
		get whether dumps on this module are enabled
		:param str tomato_module: tomato module as in Config
		:return: whether dumps on this module are enabled
		:rtype: bool
		"""
		InternalError.check(tomato_module in Config.TOMATO_MODULES, code=InternalError.INVALID_PARAMETER, message="invalid tomato module", todump=False, data={'tomato_module': tomato_module})
		return self.original_settings[tomato_module]['dumps']['enabled']
开发者ID:gitter-badger,项目名称:ToMaTo,代码行数:9,代码来源:settings.py

示例12: get_external_url

	def get_external_url(self, external_url):
		"""
		get the url for the given external link.
		:param external_url: link name (Config.EXTERNAL_URL_*)
		:return: the url
		:rtype: str
		"""
		InternalError.check(external_url in self.original_settings['external-urls'], code=InternalError.INVALID_PARAMETER, message="External URL does not exist", data={"external-url": external_url, 'existing': self.original_settings['external-urls'].keys()})
		return self.original_settings['external-urls'][external_url]
开发者ID:gitter-badger,项目名称:ToMaTo,代码行数:9,代码来源:settings.py

示例13: __init__

	def __init__(self, filename, tomato_module):
		"""
		Load settings from settings file

		:param str filename: path to settings file
		:param str tomato_module: tomato module (e.g., "web" or "backend_core")
		:return: None
		"""
		InternalError.check(tomato_module in Config.TOMATO_MODULES, code=InternalError.INVALID_PARAMETER, message="invalid tomato module %s" % tomato_module, todump=False, data={'tomato_module': tomato_module})
		self.tomato_module = tomato_module
		self.filename = filename

		self.reload()
开发者ID:gitter-badger,项目名称:ToMaTo,代码行数:13,代码来源:settings.py

示例14: reload

	def reload(self):
		InternalError.check(os.path.exists(self.filename), code=InternalError.CONFIGURATION_ERROR, message="configuration missing", todump=False, data={'filename': self.filename})
		with open(self.filename, "r") as f:
			print "reading settings file '%s'." % self.filename
			settings_content = f.read()
		self.original_settings = yaml.load(settings_content % OsFormatter())

		self.secret_key = os.getenv('SECRET_KEY', str(random.random()))

		for path in filter(os.path.exists, ["/etc/tomato/backend.conf", os.path.expanduser("~/.tomato/backend.conf"), "backend.conf"]):
			print >> sys.stderr, "Found old-style config at %s - This is no longer supported." % (path)
		for path in filter(os.path.exists, ["/etc/tomato/web.conf", os.path.expanduser("~/.tomato/web.conf"), "web.conf"]):
			print >> sys.stderr, "Found old-style config at %s - This is no longer supported." % (path)

		print "debugging is %s" % ("ENABLED" if self.debugging_enabled() else "disabled")
开发者ID:gitter-badger,项目名称:ToMaTo,代码行数:15,代码来源:settings.py

示例15: get_email_settings

	def get_email_settings(self, message_type):
		"""
		get email parameters for a certain message type.
		:param str message_type: message type from Config.EMAIL_*
		:return: configuration including 'smtp-server', 'from', 'subject', 'body'
		:trype: dict(str)
		"""
		settings = self.original_settings['email']
		InternalError.check(message_type in settings['messages'], code=InternalError.INVALID_PARAMETER, message="No such message template", data={"message_type": message_type})

		return {
			'smtp-server': settings['smtp-server'],
			'from': settings['from'],
			'subject': settings['messages'][message_type]['subject'],
			'body': settings['messages'][message_type]['body']
		}
开发者ID:gitter-badger,项目名称:ToMaTo,代码行数:16,代码来源:settings.py


注:本文中的error.InternalError类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。