本文整理汇总了Python中tito.common.error_out函数的典型用法代码示例。如果您正苦于以下问题:Python error_out函数的具体用法?Python error_out怎么用?Python error_out使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了error_out函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _bump_version
def _bump_version(self, release=False, zstream=False):
"""
Bump up the package version in the spec file.
Set release to True to bump the package release instead.
Checks for the keep version option and if found, won't actually
bump the version or release.
"""
old_version = get_latest_tagged_version(self.project_name)
if old_version == None:
old_version = "untagged"
# TODO: Do this here instead of calling out to an external Perl script:
if not self.keep_version:
bump_type = "bump-version"
if release:
bump_type = "bump-release"
elif zstream:
bump_type = "bump-zstream"
script_path = get_script_path("bump-version.pl")
cmd = "%s %s --specfile %s" % \
(script_path, bump_type, self.spec_file)
run_command(cmd)
new_version = self._get_spec_version_and_release()
if new_version.strip() == "":
msg = "Error getting bumped package version, try: \n"
msg = msg + " 'rpm -q --specfile %s'" % self.spec_file
error_out(msg)
print("Tagging new version of %s: %s -> %s" % (self.project_name,
old_version, new_version))
return new_version
示例2: _bump_version
def _bump_version(self, release=False, zstream=False):
"""
Bump up the package version in the spec file.
Set release to True to bump the package release instead.
Checks for the keep version option and if found, won't actually
bump the version or release.
"""
old_version = get_latest_tagged_version(self.project_name)
if old_version is None:
old_version = "untagged"
if not self.keep_version:
version_regex = re.compile("^(version:\s*)(.+)$", re.IGNORECASE)
release_regex = re.compile("^(release:\s*)(.+)$", re.IGNORECASE)
in_f = open(self.spec_file, 'r')
out_f = open(self.spec_file + ".new", 'w')
for line in in_f.readlines():
version_match = re.match(version_regex, line)
release_match = re.match(release_regex, line)
if version_match and not zstream and not release:
current_version = version_match.group(2)
if hasattr(self, '_use_version'):
updated_content = self._use_version
else:
updated_content = increase_version(current_version)
line = "".join([version_match.group(1), updated_content, "\n"])
elif release_match:
current_release = release_match.group(2)
if hasattr(self, '_use_release'):
updated_content = self._use_release
elif release:
updated_content = increase_version(current_release)
elif zstream:
updated_content = increase_zstream(current_release)
else:
updated_content = reset_release(current_release)
line = "".join([release_match.group(1), updated_content, "\n"])
out_f.write(line)
in_f.close()
out_f.close()
shutil.move(self.spec_file + ".new", self.spec_file)
new_version = get_spec_version_and_release(self.full_project_dir,
self.spec_file_name)
if new_version.strip() == "":
msg = "Error getting bumped package version, try: \n"
msg = msg + " 'rpm -q --specfile %s'" % self.spec_file
error_out(msg)
info_out("Tagging new version of %s: %s -> %s" % (self.project_name,
old_version, new_version))
return new_version
示例3: patch_upstream
def patch_upstream(self):
""" Create one patch per each release """
ch_dir = self.git_root
if self.relative_project_dir != "/":
ch_dir = os.path.join(self.git_root,
self.relative_project_dir)
os.chdir(ch_dir)
debug("Running /usr/bin/generate-patches.pl -d %s %s %s-1 %s %s"
% (self.rpmbuild_gitcopy, self.project_name, self.upstream_version, self.build_version, self.git_commit_id))
output = run_command("/usr/bin/generate-patches.pl -d %s %s %s-1 %s %s"
% (self.rpmbuild_gitcopy, self.project_name, self.upstream_version, self.build_version, self.git_commit_id))
self.patch_files = output.split("\n")
for p_file in self.patch_files:
(status, output) = getstatusoutput(
"grep 'Binary files .* differ' %s/%s " % (self.rpmbuild_gitcopy, p_file))
if status == 0 and output != "":
error_out("You are doomed. Diff contains binary files. You can not use this builder")
run_command("cp %s/%s %s" % (self.rpmbuild_gitcopy, p_file, self.rpmbuild_sourcedir))
(patch_number, patch_insert_index, patch_apply_index, lines) = self._patch_upstream()
for patch in self.patch_files:
lines.insert(patch_insert_index, "Patch%s: %s\n" % (patch_number, patch))
lines.insert(patch_apply_index, "%%patch%s -p1\n" % (patch_number))
patch_number += 1
patch_insert_index += 1
patch_apply_index += 2
self._write_spec(lines)
示例4: _get_build_version
def _get_build_version(self):
"""
Figure out the git tag and version-release we're building.
"""
# Determine which package version we should build:
build_version = None
if self.build_tag:
build_version = self.build_tag[len(self.project_name + "-"):]
else:
build_version = get_latest_tagged_version(self.project_name)
if build_version is None:
if not self.test:
error_out(["Unable to lookup latest package info.",
"Perhaps you need to tag first?"])
warn_out("unable to lookup latest package "
"tag, building untagged test project")
build_version = get_spec_version_and_release(self.start_dir,
find_spec_like_file(self.start_dir))
self.build_tag = "%s-%s" % (self.project_name, build_version)
self.spec_version = build_version.split('-')[-2]
self.spec_release = build_version.split('-')[-1]
if not self.test:
check_tag_exists(self.build_tag, offline=self.offline)
return build_version
示例5: _build
def _build(self, branch):
""" Submit a Fedora build from current directory. """
target_param = ""
scratch_param = ""
build_target = self._get_build_target_for_branch(branch)
if build_target:
target_param = "--target %s" % build_target
if self.scratch:
scratch_param = "--scratch"
build_cmd = "%s build --nowait %s %s" % (self.cli_tool, scratch_param, target_param)
if self.dry_run:
self.print_dry_run_warning(build_cmd)
return
info_out("Submitting build: %s" % build_cmd)
(status, output) = getstatusoutput(build_cmd)
if status > 0:
if "already been built" in output:
warn_out("Build has been submitted previously, continuing...")
else:
error_out([
"Unable to submit build."
" Status code: %s\n" % status,
" Output: %s\n" % output,
])
# Print the task ID and URL:
for line in extract_task_info(output):
print(line)
示例6: main
def main(self):
BaseCliModule.main(self)
if self.global_config.has_option(GLOBALCONFIG_SECTION,
"block_tagging"):
debug("block_tagging defined in tito.props")
error_out("Tagging has been disabled in this git branch.")
build_dir = os.path.normpath(os.path.abspath(self.options.output_dir))
package_name = get_project_name(tag=None)
self.pkg_config = self._read_project_config(package_name, build_dir,
None, None)
tagger_class = None
if self.pkg_config.has_option("buildconfig", "tagger"):
tagger_class = get_class_by_name(self.pkg_config.get("buildconfig",
"tagger"))
else:
tagger_class = get_class_by_name(self.global_config.get(
GLOBALCONFIG_SECTION, DEFAULT_TAGGER))
debug("Using tagger class: %s" % tagger_class)
tagger = tagger_class(global_config=self.global_config,
keep_version=self.options.keep_version)
tagger.run(self.options)
示例7: _read_global_config
def _read_global_config(self):
"""
Read global build.py configuration from the rel-eng dir of the git
repository we're being run from.
"""
rel_eng_dir = os.path.join(find_git_root(), "rel-eng")
filename = os.path.join(rel_eng_dir, GLOBAL_BUILD_PROPS_FILENAME)
if not os.path.exists(filename):
# HACK: Try the old filename location, pre-tito rename:
oldfilename = os.path.join(rel_eng_dir, "global.build.py.props")
if not os.path.exists(oldfilename):
error_out("Unable to locate branch configuration: %s"
"\nPlease run 'tito init'" % filename)
config = ConfigParser.ConfigParser()
config.read(filename)
# Verify the config contains what we need from it:
required_global_config = [
(GLOBALCONFIG_SECTION, DEFAULT_BUILDER),
(GLOBALCONFIG_SECTION, DEFAULT_TAGGER),
]
for section, option in required_global_config:
if not config.has_section(section) or not \
config.has_option(section, option):
error_out("%s missing required config: %s %s" % (
filename, section, option))
return config
示例8: main
def main(self, argv):
BaseCliModule.main(self, argv)
build_dir = os.path.normpath(os.path.abspath(self.options.output_dir))
package_name = get_project_name(tag=None)
self.load_config(package_name, build_dir, None)
if self.config.has_option(BUILDCONFIG_SECTION,
"block_tagging"):
debug("block_tagging defined in tito.props")
error_out("Tagging has been disabled in this git branch.")
tagger_class = get_class_by_name(self.config.get(
BUILDCONFIG_SECTION, DEFAULT_TAGGER))
debug("Using tagger class: %s" % tagger_class)
tagger = tagger_class(config=self.config,
user_config=self.user_config,
keep_version=self.options.keep_version,
offline=self.options.offline)
try:
return tagger.run(self.options)
except TitoException:
e = sys.exc_info()[1]
error_out(e.message)
示例9: _setup_sources
def _setup_sources(self):
super(GitAnnexBuilder, self)._setup_sources()
old_cwd = os.getcwd()
os.chdir(os.path.join(old_cwd, self.relative_project_dir))
# NOTE: 'which' may not be installed... (docker containers)
(status, output) = getstatusoutput("which git-annex")
if status != 0:
msg = "Please run '%s install git-annex' as root." % package_manager()
error_out('%s' % msg)
run_command("git-annex lock")
annexed_files = run_command("git-annex find --include='*'").splitlines()
run_command("git-annex get")
run_command("git-annex unlock")
debug(" Annex files: %s" % annexed_files)
for annex in annexed_files:
debug("Copying unlocked file %s" % annex)
os.remove(os.path.join(self.rpmbuild_gitcopy, annex))
shutil.copy(annex, self.rpmbuild_gitcopy)
self._lock()
os.chdir(old_cwd)
示例10: _validate_options
def _validate_options(self):
if self.options.all and self.options.all_starting_with:
error_out("Cannot combine --all and --all-starting-with.")
if (self.options.all or self.options.all_starting_with) and \
len(self.args) > 1:
error_out("Cannot use explicit release targets with "
"--all or --all-starting-with.")
示例11: _check_build_dirs_access
def _check_build_dirs_access(self, build_dirs):
"""
Ensure the build directories are writable.
"""
msgs = []
for d in build_dirs:
if not os.access(d, os.W_OK):
msgs.append("%s is not writable." % d)
if msgs:
error_out(msgs)
示例12: _check_required_config
def _check_required_config(self, config):
# Verify the config contains what we need from it:
required_global_config = [
(BUILDCONFIG_SECTION, DEFAULT_BUILDER),
(BUILDCONFIG_SECTION, DEFAULT_TAGGER),
]
for section, option in required_global_config:
if not config.has_section(section) or not \
config.has_option(section, option):
error_out("tito.props missing required config: %s %s" % (
section, option))
示例13: _check_releaser_config
def _check_releaser_config(self):
"""
Verify this release target has all the config options it needs.
"""
for opt in self.GLOBAL_REQUIRED_CONFIG:
if not self.releaser_config.has_option(self.target, opt):
error_out("Release target '%s' missing required option '%s'" %
(self.target, opt))
for opt in self.REQUIRED_CONFIG:
if not self.releaser_config.has_option(self.target, opt):
error_out("Release target '%s' missing required option '%s'" %
(self.target, opt))
示例14: _check_releaser_config
def _check_releaser_config(self):
"""
Verify this release target has all the config options it needs.
"""
if self.releaser_config.has_option(self.target, "remote_location"):
self.remote_location = self.releaser_config.get(self.target, "remote_location")
elif 'COPR_REMOTE_LOCATION' in self.user_config:
self.remote_location = self.user_config['COPR_REMOTE_LOCATION']
else:
error_out(["No remote location for Copr SRPMs found.",
"Either define 'remote_location' in the releaser configuration "
"or 'COPR_REMOTE_LOCATION' in ~/.titorc"])
KojiReleaser._check_releaser_config(self)
示例15: _confirm_commit_msg
def _confirm_commit_msg(self, diff_output):
"""
Generates a commit message in a temporary file, gives the user a
chance to edit it, and returns the filename to the caller.
"""
fd, name = tempfile.mkstemp()
debug("Storing commit message in temp file: %s" % name)
write(fd, "Update %s to %s\n" % (self.project_name,
self.builder.build_version))
# Write out Resolves line for all bugzillas we see in commit diff:
# TODO: move to DistGitBuilder only?
try:
(required_bz_flags, placeholder_bz) = self._get_bz_flags()
extractor = BugzillaExtractor(diff_output,
required_flags=required_bz_flags,
placeholder_bz=placeholder_bz)
for line in extractor.extract():
write(fd, line + "\n")
except MissingBugzillaCredsException:
error_out([
"Releaser specifies required flags but you have not configured",
"a ~/.bugzillarc with your bugzilla credentials.",
"Example:",
"",
"[bugzilla.redhat.com]",
"user = [email protected]",
"password = mypassword"])
print("")
print("##### Commit message: #####")
print("")
os.lseek(fd, 0, 0)
f = os.fdopen(fd)
for line in f.readlines():
print(line)
f.close()
print("")
print("###############################")
print("")
if self._ask_yes_no("Would you like to edit this commit message? [y/n] ", False):
debug("Opening editor for user to edit commit message in: %s" % name)
editor = 'vi'
if "EDITOR" in os.environ:
editor = os.environ["EDITOR"]
subprocess.call(editor.split() + [name])
return name