本文整理汇总了Python中bitten.model.BuildConfig.fetch方法的典型用法代码示例。如果您正苦于以下问题:Python BuildConfig.fetch方法的具体用法?Python BuildConfig.fetch怎么用?Python BuildConfig.fetch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bitten.model.BuildConfig
的用法示例。
在下文中一共展示了BuildConfig.fetch方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_process_deactivate_config
# 需要导入模块: from bitten.model import BuildConfig [as 别名]
# 或者: from bitten.model.BuildConfig import fetch [as 别名]
def test_process_deactivate_config(self):
BuildConfig(self.env, name='foo', path='branches/foo',
active=True).insert()
BuildConfig(self.env, name='bar', path='branches/bar',
active=True).insert()
redirected_to = []
def redirect(url):
redirected_to.append(url)
raise RequestDone
req = Mock(method='POST', perm=PermissionCache(self.env, 'joe'),
abs_href=Href('http://example.org/'), redirect=redirect,
authname='joe',
args={'apply': ''})
provider = BuildConfigurationsAdminPageProvider(self.env)
try:
provider.render_admin_panel(req, 'bitten', 'configs', '')
self.fail('Expected RequestDone')
except RequestDone:
self.assertEqual('http://example.org/admin/bitten/configs',
redirected_to[0])
config = BuildConfig.fetch(self.env, name='foo')
self.assertEqual(False, config.active)
config = BuildConfig.fetch(self.env, name='bar')
self.assertEqual(False, config.active)
示例2: should_delete_build
# 需要导入模块: from bitten.model import BuildConfig [as 别名]
# 或者: from bitten.model.BuildConfig import fetch [as 别名]
def should_delete_build(self, build, repos):
config = BuildConfig.fetch(self.env, build.config)
platform = TargetPlatform.fetch(self.env, build.platform)
# Platform may or may not exist anymore - get safe name for logging
platform_name = platform and platform.name \
or 'unknown platform "%s"' % build.platform
# Drop build if platform no longer exists
if not platform:
self.log.info('Dropping build of configuration "%s" at '
'revision [%s] on %s because the platform no longer '
'exists', config.name, build.rev, platform_name)
return True
# Ignore pending builds for deactived build configs
if not config.active:
self.log.info('Dropping build of configuration "%s" at '
'revision [%s] on %s because the configuration is '
'deactivated', config.name, build.rev, platform_name)
return True
# If not 'build_all', drop if a more recent revision is available
if not self.build_all and \
len(list(Build.select(self.env, config=build.config,
min_rev_time=build.rev_time, platform=build.platform))) > 1:
self.log.info('Dropping build of configuration "%s" at revision [%s] '
'on "%s" because a more recent build exists',
config.name, build.rev, platform_name)
return True
return False
示例3: get_annotation_data
# 需要导入模块: from bitten.model import BuildConfig [as 别名]
# 或者: from bitten.model.BuildConfig import fetch [as 别名]
def get_annotation_data(self, context):
add_stylesheet(context.req, 'bitten/bitten_coverage.css')
resource = context.resource
self.log.debug("Looking for coverage report for %[email protected]%s..." % (
resource.id, str(resource.version)))
builds = Build.select(self.env, rev=resource.version)
reports = []
for build in builds:
config = BuildConfig.fetch(self.env, build.config)
if not resource.id.startswith(config.branch):
continue
reports = Report.select(self.env, build=build.id,
category='coverage')
branch_in_config = resource.id[len(config.branch):]
for report in reports:
for item in report.items:
if item.get('file') == branch_in_config:
coverage = item.get('line_hits', '').split()
if coverage:
# Return first result with line data
self.log.debug(
"Coverage annotate for %[email protected]%s: %s" % \
(resource.id, resource.version, coverage))
return coverage
return []
示例4: process_request
# 需要导入模块: from bitten.model import BuildConfig [as 别名]
# 或者: from bitten.model.BuildConfig import fetch [as 别名]
def process_request(self, req):
req.perm.assert_permission('BUILD_EXEC')
if 'id' not in req.args:
if req.method != 'POST':
raise HTTPMethodNotAllowed('Method not allowed')
return self._process_build_creation(req)
build = Build.fetch(self.env, req.args['id'])
if not build:
raise HTTPNotFound('No such build')
config = BuildConfig.fetch(self.env, build.config)
if not req.args['collection']:
if req.method == 'DELETE':
return self._process_build_cancellation(req, config, build)
else:
return self._process_build_initiation(req, config, build)
if req.method != 'POST':
raise HTTPMethodNotAllowed('Method not allowed')
if req.args['collection'] == 'steps':
return self._process_build_step(req, config, build)
else:
raise HTTPNotFound('No such collection')
示例5: should_delete_build
# 需要导入模块: from bitten.model import BuildConfig [as 别名]
# 或者: from bitten.model.BuildConfig import fetch [as 别名]
def should_delete_build(self, build, repos):
# Ignore pending builds for deactived build configs
config = BuildConfig.fetch(self.env, build.config)
if not config.active:
target_platform = TargetPlatform.fetch(self.env, build.platform)
if target_platform:
target_platform_name = '"%s"' % (target_platform.name,)
else:
target_platform_name = 'unknown platform "%s"' % (build.platform,)
log.info('Dropping build of configuration "%s" at '
'revision [%s] on %s because the configuration is '
'deactivated', config.name, build.rev,
target_platform_name)
return True
# Stay within the revision limits of the build config
if (config.min_rev and repos.rev_older_than(build.rev,
config.min_rev)) \
or (config.max_rev and repos.rev_older_than(config.max_rev,
build.rev)):
# This minimum and/or maximum revision has changed since
# this build was enqueued, so drop it
log.info('Dropping build of configuration "%s" at revision [%s] on '
'"%s" because it is outside of the revision range of the '
'configuration', config.name, build.rev,
TargetPlatform.fetch(self.env, build.platform).name)
return True
return False
示例6: test_process_update_config
# 需要导入模块: from bitten.model import BuildConfig [as 别名]
# 或者: from bitten.model.BuildConfig import fetch [as 别名]
def test_process_update_config(self):
BuildConfig(self.env, name='foo', label='Foo', path='branches/foo',
active=True).insert()
redirected_to = []
def redirect(url):
redirected_to.append(url)
raise RequestDone
req = Mock(method='POST', perm=PermissionCache(self.env, 'joe'),
abs_href=Href('http://example.org/'), redirect=redirect,
authname='joe', chrome={'warnings': [], 'notices': []},
href=Href('/'),
args={'save': '', 'name': 'foo', 'label': 'Foobar',
'description': 'Thanks for all the fish!'})
provider = BuildConfigurationsAdminPageProvider(self.env)
try:
provider.render_admin_panel(req, 'bitten', 'configs', 'foo')
self.fail('Expected RequestDone')
except RequestDone:
self.assertEqual(['Configuration Saved.'], req.chrome['notices'])
self.assertEqual('http://example.org/admin/bitten/configs/foo',
redirected_to[0])
config = BuildConfig.fetch(self.env, name='foo')
self.assertEqual('Foobar', config.label)
self.assertEqual('Thanks for all the fish!', config.description)
示例7: resource_exists
# 需要导入模块: from bitten.model import BuildConfig [as 别名]
# 或者: from bitten.model.BuildConfig import fetch [as 别名]
def resource_exists(self, resource):
config_name, build_id = self._parse_resource(resource.id)
if build_id:
build = Build.fetch(self.env, build_id)
return build and build.exists or False
elif config_name:
config = BuildConfig.fetch(self.env, config_name)
return config and config.exists or False
return False
示例8: test_update_no_name
# 需要导入模块: from bitten.model import BuildConfig [as 别名]
# 或者: from bitten.model.BuildConfig import fetch [as 别名]
def test_update_no_name(self):
db = self.env.get_db_cnx()
cursor = db.cursor()
cursor.execute("INSERT INTO bitten_config (name,path,label,active) "
"VALUES (%s,%s,%s,%s)", ('test', 'trunk', 'Test', 0))
config = BuildConfig.fetch(self.env, 'test')
config.name = None
self.assertRaises(AssertionError, config.update)
示例9: process_request
# 需要导入模块: from bitten.model import BuildConfig [as 别名]
# 或者: from bitten.model.BuildConfig import fetch [as 别名]
def process_request(self, req):
req.perm.require('BUILD_VIEW')
db = self.env.get_db_cnx()
build_id = int(req.args.get('id'))
build = Build.fetch(self.env, build_id, db=db)
assert build, 'Build %s does not exist' % build_id
if req.method == 'POST':
if req.args.get('action') == 'invalidate':
self._do_invalidate(req, build, db)
req.redirect(req.href.build(build.config, build.id))
add_link(req, 'up', req.href.build(build.config),
'Build Configuration')
data = {'title': 'Build %s - %s' % (build_id,
_status_title[build.status]),
'page_mode': 'view_build',
'build': {}}
config = BuildConfig.fetch(self.env, build.config, db=db)
data['build']['config'] = {
'name': config.label,
'href': req.href.build(config.name)
}
formatters = []
for formatter in self.log_formatters:
formatters.append(formatter.get_formatter(req, build))
summarizers = {} # keyed by report type
for summarizer in self.report_summarizers:
categories = summarizer.get_supported_categories()
summarizers.update(dict([(cat, summarizer) for cat in categories]))
data['build'].update(_get_build_data(self.env, req, build))
steps = []
for step in BuildStep.select(self.env, build=build.id, db=db):
steps.append({
'name': step.name, 'description': step.description,
'duration': pretty_timedelta(step.started, step.stopped),
'failed': step.status == BuildStep.FAILURE,
'errors': step.errors,
'log': self._render_log(req, build, formatters, step),
'reports': self._render_reports(req, config, build, summarizers,
step)
})
data['build']['steps'] = steps
data['build']['can_delete'] = ('BUILD_DELETE' in req.perm)
repos = self.env.get_repository(req.authname)
repos.authz.assert_permission(config.path)
chgset = repos.get_changeset(build.rev)
data['build']['chgset_author'] = chgset.author
add_script(req, 'bitten/tabset.js')
add_stylesheet(req, 'bitten/bitten.css')
return 'bitten_build.html', data, None
示例10: get_annotation_data
# 需要导入模块: from bitten.model import BuildConfig [as 别名]
# 或者: from bitten.model.BuildConfig import fetch [as 别名]
def get_annotation_data(self, context):
"""add annotation data for lint"""
context.perm.require('BUILD_VIEW')
add_stylesheet(context.req, 'bitten/bitten_coverage.css')
add_stylesheet(context.req, 'bitten/bitten_lintannotator.css')
resource = context.resource
# attempt to use the version passed in with the request,
# otherwise fall back to the latest version of this file.
try:
version = context.req.args['rev']
except (KeyError, TypeError):
version = resource.version
self.log.debug('no version passed to get_annotation_data')
builds = Build.select(self.env, rev=version)
self.log.debug("Looking for lint report for %[email protected]%s [%s]..." % (
resource.id, str(resource.version), version))
self.itemid = 0
data = {}
reports = None
for build in builds:
config = BuildConfig.fetch(self.env, build.config)
if not resource.id.lstrip('/').startswith(config.path.lstrip('/')):
self.log.debug('Skip build %s' % build)
continue
path_in_config = resource.id[len(config.path)+1:].lstrip('/')
reports = Report.select(self.env, build=build.id, category='lint')
for report in reports:
for item in report.items:
if item.get('file') == path_in_config:
line = item.get('line')
if line:
problem = {'category': item.get('category', ''),
'tag': item.get('tag', ''),
'bid': build.id,
'rbuild': report.build,
'rstep': report.step, 'rid': report.id}
data.setdefault(int(line), []).append(problem)
if data:
self.log.debug("Lint annotate for %[email protected]%s: %s results" % \
(resource.id, resource.version, len(data)))
return data
if not builds:
self.log.debug("No builds found")
elif not reports:
self.log.debug("No reports found")
else:
self.log.debug("No item of any report matched (%s)" % reports)
return None
示例11: test_fetch
# 需要导入模块: from bitten.model import BuildConfig [as 别名]
# 或者: from bitten.model.BuildConfig import fetch [as 别名]
def test_fetch(self):
db = self.env.get_db_cnx()
cursor = db.cursor()
cursor.execute("INSERT INTO bitten_config (name,path,label,active) "
"VALUES (%s,%s,%s,%s)", ('test', 'trunk', 'Test', 0))
config = BuildConfig.fetch(self.env, name='test')
assert config.exists
self.assertEqual('test', config.name)
self.assertEqual('trunk', config.path)
self.assertEqual('Test', config.label)
self.assertEqual(False, config.active)
示例12: _format_link
# 需要导入模块: from bitten.model import BuildConfig [as 别名]
# 或者: from bitten.model.BuildConfig import fetch [as 别名]
def _format_link(formatter, ns, name, label):
build = Build.fetch(self.env, int(name))
if build:
config = BuildConfig.fetch(self.env, build.config)
title = "Build %d ([%s] of %s) by %s" % (build.id, build.rev, config.label, build.slave)
return '<a class="build" href="%s" title="%s">%s</a>' % (
formatter.href.build(build.config, build.id),
title,
label,
)
return label
示例13: test_delete
# 需要导入模块: from bitten.model import BuildConfig [as 别名]
# 或者: from bitten.model.BuildConfig import fetch [as 别名]
def test_delete(self):
db = self.env.get_db_cnx()
cursor = db.cursor()
cursor.execute("INSERT INTO bitten_config (name,path,label,active) "
"VALUES (%s,%s,%s,%s)", ('test', 'trunk', 'Test', 0))
config = BuildConfig.fetch(self.env, 'test')
config.delete()
self.assertEqual(False, config.exists)
cursor.execute("SELECT * FROM bitten_config WHERE name=%s", ('test',))
self.assertEqual(None, cursor.fetchone())
示例14: _format_link
# 需要导入模块: from bitten.model import BuildConfig [as 别名]
# 或者: from bitten.model.BuildConfig import fetch [as 别名]
def _format_link(formatter, ns, name, label):
try:
name = int(name)
except ValueError:
return label
build = Build.fetch(self.env, name)
if build:
config = BuildConfig.fetch(self.env, build.config)
title = 'Build %d ([%s] of %s) by %s' % (build.id, build.rev,
config.label, build.slave)
return '<a class="build" href="%s" title="%s">%s</a>' \
% (formatter.href.build(build.config, build.id), title,
label)
return label
示例15: get_formatter
# 需要导入模块: from bitten.model import BuildConfig [as 别名]
# 或者: from bitten.model.BuildConfig import fetch [as 别名]
def get_formatter(self, req, build):
"""Return the log message formatter function."""
config = BuildConfig.fetch(self.env, name=build.config)
repos = self.env.get_repository(authname=req.authname)
assert repos, 'No "(default)" Repository: Add a repository or alias ' \
'named "(default)" to Trac.'
href = req.href.browser
cache = {}
def _replace(m):
filepath = posixpath.normpath(m.group('path').replace('\\', '/'))
if not cache.get(filepath) is True:
parts = filepath.split('/')
path = ''
for part in parts:
path = posixpath.join(path, part)
if path not in cache:
try:
full_path = posixpath.join(config.path, path)
full_path = posixpath.normpath(full_path)
if full_path.startswith(config.path + "/") \
or full_path == config.path:
repos.get_node(full_path,
build.rev)
cache[path] = True
else:
cache[path] = False
except TracError:
cache[path] = False
if cache[path] is False:
return m.group(0)
link = href(config.path, filepath)
if m.group('line'):
link += '#L' + m.group('line')[1:]
return Markup(tag.a(m.group(0), href=link))
def _formatter(step, type, level, message):
buf = []
offset = 0
for mo in self._fileref_re.finditer(message):
start, end = mo.span()
if start > offset:
buf.append(message[offset:start])
buf.append(_replace(mo))
offset = end
if offset < len(message):
buf.append(message[offset:])
return Markup("").join(buf)
return _formatter