本文整理汇总了Python中rebasehelper.logger.logger.debug函数的典型用法代码示例。如果您正苦于以下问题:Python debug函数的具体用法?Python debug怎么用?Python debug使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了debug函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _get_initial_sources_list
def _get_initial_sources_list(self):
"""Function returns all sources mentioned in SPEC file"""
# get all regular sources
sources = []
tar_sources = []
sources_list = [x for x in self.spc.sources if x[2] == 1]
remote_files_re = re.compile(r'(http:|https:|ftp:)//.*')
for index, src in enumerate(sorted(sources_list, key=lambda source: source[1])):
# src is type of (SOURCE, Index of source, Type of source (PAtch, Source)
# We need to download all archives and only the one
abs_path = os.path.join(self.sources_location, os.path.basename(src[0]).strip())
sources.append(abs_path)
archive = [x for x in Archive.get_supported_archives() if src[0].endswith(x)]
# if the source is a remote file, download it
if archive:
if remote_files_re.search(src[0]) and self.download and not os.path.isfile(abs_path):
logger.debug("Tarball is not in absolute path {} "
"trying to download one from URL {}".format(abs_path, src[0]))
logger.info("Tarball is not in absolute path. Trying to download it from URL")
try:
DownloadHelper.download_file(src[0], abs_path)
except DownloadError as e:
raise RebaseHelperError("Failed to download file from URL {}. "
"Reason: '{}'. ".format(src[0], str(e)))
tar_sources.append(abs_path)
return sources, tar_sources
示例2: set_version
def set_version(self, version):
"""
Method to update the version in the SPEC file
:param version: string with new version
:return: None
"""
version_re = re.compile('Version:\s*(.+)')
for index, line in enumerate(self.spec_content):
match = version_re.search(line)
if match:
logger.debug("Updating version in SPEC from '%s' with '%s'", self.get_version(), version)
# search for used macros in spec file scope
for m in MacroHelper.get_macros(level=-1, used=True):
if m['name'] in match.group(1):
# redefine the macro, don't touch Version tag
self._set_macro(m['name'], version)
return
self.spec_content[index] = line.replace(match.group(1), version)
break
# save changes to the disc
self.save()
示例3: _update_data
def _update_data(self):
"""
Function updates data from given SPEC file
:return:
"""
# Load rpm information
try:
self.spc = rpm.spec(self.path)
except ValueError:
raise RebaseHelperError("Problem with parsing SPEC file '%s'" % self.path)
self.prep_section = self.spc.prep
# HEADER of SPEC file
self.hdr = self.spc.sourceHeader
# All source file mentioned in SPEC file Source[0-9]*
self.rpm_sections = self._split_sections()
# determine the extra_version
logger.debug("Updating the extra version")
self.sources, self.tar_sources = self._get_initial_sources_list()
_, self.extra_version, separator = SpecFile.extract_version_from_archive_name(
self.get_archive(),
self._get_raw_source_string(0))
self.set_extra_version_separator(separator)
self.patches = self._get_initial_patches_list()
self.macros = MacroHelper.dump()
示例4: _build_srpm
def _build_srpm(cls, spec, sources, patches, results_dir):
"""
Builds the SRPM using rpmbuild
:param spec: absolute path to the SPEC file.
:param sources: list with absolute paths to SOURCES
:param patches: list with absolute paths to PATCHES
:param results_dir: absolute path to DIR where results should be stored
:return: absolute path to SRPM, list with absolute paths to logs
"""
# build SRPM
srpm_results_dir = os.path.join(results_dir, "SRPM")
with RpmbuildTemporaryEnvironment(sources, patches, spec,
srpm_results_dir) as tmp_env:
env = tmp_env.env()
tmp_dir = tmp_env.path()
tmp_spec = env.get(RpmbuildTemporaryEnvironment.TEMPDIR_SPEC)
tmp_results_dir = env.get(
RpmbuildTemporaryEnvironment.TEMPDIR_RESULTS)
srpm = cls._do_build_srpm(tmp_spec, tmp_dir, tmp_results_dir)
if srpm is None:
raise SourcePackageBuildError("Building SRPM failed!")
else:
logger.info("Building SRPM finished successfully")
# srpm path in results_dir
srpm = os.path.join(srpm_results_dir, os.path.basename(srpm))
logger.debug("Successfully built SRPM: '%s'", str(srpm))
# gather logs
logs = [l for l in PathHelper.find_all_files(srpm_results_dir, '*.log')]
logger.debug("logs: '%s'", str(logs))
return srpm, logs
示例5: _prepare_spec_objects
def _prepare_spec_objects(self):
"""
Prepare spec files and initialize objects
:return:
"""
self.rebase_spec_file_path = get_rebase_name(self.spec_file_path)
self.spec_file = SpecFile(self.spec_file_path,
self.execution_dir,
download=not self.conf.not_download_sources)
# Check whether test suite is enabled at build time
if not self.spec_file.is_test_suite_enabled():
OutputLogger.set_info_text('WARNING', 'Test suite is not enabled at build time.')
# create an object representing the rebased SPEC file
self.rebase_spec_file = self.spec_file.copy(self.rebase_spec_file_path)
# check if argument passed as new source is a file or just a version
if [True for ext in Archive.get_supported_archives() if self.conf.sources.endswith(ext)]:
logger.debug("argument passed as a new source is a file")
self.rebase_spec_file.set_version_using_archive(self.conf.sources)
else:
logger.debug("argument passed as a new source is a version")
version, extra_version = SpecFile.split_version_string(self.conf.sources)
self.rebase_spec_file.set_version(version)
if extra_version:
self.rebase_spec_file.set_extra_version(extra_version)
示例6: _delete_workspace_dir
def _delete_workspace_dir(self):
"""
Deletes workspace directory and loggs message
:return:
"""
logger.debug("Removing the workspace directory '%s'", self.workspace_dir)
shutil.rmtree(self.workspace_dir)
示例7: _create_directory_sctructure
def _create_directory_sctructure(self):
# create directory structure
for dir_name in ['SOURCES', 'SPECS', 'RESULTS']:
self._env[self.TEMPDIR + '_' + dir_name] = os.path.join(
self._env[self.TEMPDIR], dir_name)
logger.debug("Creating '%s'",
self._env[self.TEMPDIR + '_' + dir_name])
os.makedirs(self._env[self.TEMPDIR + '_' + dir_name])
示例8: commit_patch
def commit_patch(git_helper, patch_name):
"""Function commits patched files to git"""
logger.debug('Commit patch')
ret_code = git_helper.command_add_files(parameters=['--all'])
if int(ret_code) != 0:
raise GitRebaseError('We are not able to add changed files to local git repository.')
ret_code = git_helper.command_commit(message='Patch: {0}'.format(os.path.basename(patch_name)))
return ret_code
示例9: _write_spec_file_to_disc
def _write_spec_file_to_disc(self):
"""Write the current SPEC file to the disc"""
logger.debug("Writing SPEC file '%s' to the disc", self.path)
try:
with open(self.path, "w") as f:
f.writelines(self.spec_content)
except IOError:
raise RebaseHelperError("Unable to write updated data to SPEC file '%s'", self.path)
示例10: __init__
def __init__(self, cli_conf=None):
"""
Initialize the application
:param cli_conf: CLI object with configuration gathered from commandline
:return:
"""
OutputLogger.clear()
self.conf = cli_conf
if self.conf.verbose:
LoggerHelper.add_stream_handler(logger, logging.DEBUG)
else:
LoggerHelper.add_stream_handler(logger, logging.INFO)
# The directory in which rebase-helper was executed
if self.conf.results_dir is None:
self.execution_dir = os.getcwd()
else:
self.execution_dir = self.conf.results_dir
# Temporary workspace for Builder, checks, ...
self.kwargs['workspace_dir'] = self.workspace_dir = os.path.join(self.execution_dir,
settings.REBASE_HELPER_WORKSPACE_DIR)
# Directory where results should be put
self.kwargs['results_dir'] = self.results_dir = os.path.join(self.execution_dir,
settings.REBASE_HELPER_RESULTS_DIR)
self.kwargs['non_interactive'] = self.conf.non_interactive
# if not continuing, check the results dir
if not self.conf.cont and not self.conf.build_only and not self.conf.comparepkgs:
self._check_results_dir()
# This is used if user executes rebase-helper with --continue
# parameter even when directory does not exist
if not os.path.exists(self.results_dir):
os.makedirs(self.results_dir)
os.makedirs(os.path.join(self.results_dir, settings.REBASE_HELPER_LOGS))
self._add_debug_log_file()
self._add_report_log_file()
logger.debug("Rebase-helper version: %s" % version.VERSION)
if self.conf.build_tasks is None:
self._get_spec_file()
self._prepare_spec_objects()
# check the workspace dir
if not self.conf.cont:
self._check_workspace_dir()
# TODO: Remove the value from kwargs and use only CLI attribute!
self.kwargs['continue'] = self.conf.cont
self._initialize_data()
if self.conf.cont or self.conf.build_only:
self._delete_old_builds()
示例11: _prepare_git
def _prepare_git(cls, upstream_name):
cls.git_helper.command_remote_add(upstream_name, cls.new_sources)
cls.git_helper.command_fetch(upstream_name)
cls.output_data = cls.git_helper.command_log(parameters='--pretty=oneline')
logger.debug('Outputdata from git log %s', cls.output_data)
number = 0
if cls.prep_section:
number = 1
last_hash = GitHelper.get_commit_hash_log(cls.output_data, number=number)
init_hash = GitHelper.get_commit_hash_log(cls.output_data, len(cls.output_data)-1)
return init_hash, last_hash
示例12: _create_directory_sctructure
def _create_directory_sctructure(self):
# create rpmbuild directory structure
for dir_name in ['RESULTS', 'rpmbuild']:
self._env[self.TEMPDIR + '_' + dir_name.upper()] = os.path.join(self._env[self.TEMPDIR], dir_name)
logger.debug("Creating '%s'", self._env[self.TEMPDIR + '_' + dir_name.upper()])
os.makedirs(self._env[self.TEMPDIR + '_' + dir_name.upper()])
for dir_name in ['BUILD', 'BUILDROOT', 'RPMS', 'SOURCES', 'SPECS', 'SRPMS']:
self._env[self.TEMPDIR + '_' + dir_name] = os.path.join(self._env[self.TEMPDIR_RPMBUILD],
dir_name)
logger.debug("Creating '%s'", self._env[self.TEMPDIR + '_' + dir_name])
os.makedirs(self._env[self.TEMPDIR + '_' + dir_name])
示例13: _git_rebase
def _git_rebase(cls):
"""Function performs git rebase between old and new sources"""
# in old_sources do.
# 1) git remote add new_sources <path_to_new_sources>
# 2) git fetch new_sources
# 3 git rebase -i --onto new_sources/master <oldest_commit_old_source> <the_latest_commit_old_sourcese>
if not cls.cont:
logger.info('Git-rebase operation to %s is ongoing...', os.path.basename(cls.new_sources))
upstream = 'new_upstream'
init_hash, last_hash = cls._prepare_git(upstream)
ret_code = cls.git_helper.command_rebase(parameters='--onto', upstream_name=upstream,
first_hash=init_hash, last_hash=last_hash)
else:
logger.info('Git-rebase operation continues...')
ret_code = cls.git_helper.command_rebase(parameters='--skip')
cls._get_git_helper_data()
logger.debug(cls.output_data)
modified_patches = []
deleted_patches = []
unapplied_patches = []
while True:
if int(ret_code) != 0:
patch_name = cls.git_helper.get_unapplied_patch(cls.output_data)
logger.info("Git has problems with rebasing patch %s", patch_name)
if not cls.non_interactive:
cls.git_helper.command_mergetool()
else:
unapplied_patches.append(patch_name)
modified_files = cls.git_helper.command_diff_status()
cls.git_helper.command_add_files(parameters=modified_files)
base_name = os.path.join(cls.kwargs['results_dir'], patch_name)
cls.git_helper.command_diff('HEAD', output_file=base_name)
with open(base_name, "r") as f:
del_patches = f.readlines()
if not del_patches:
deleted_patches.append(base_name)
else:
logger.info('Following files were modified: %s', ','.join(modified_files).decode(defenc))
cls.git_helper.command_commit(message=patch_name)
cls.git_helper.command_diff('HEAD~1', output_file=base_name)
modified_patches.append(base_name)
if not cls.non_interactive:
if not ConsoleHelper.get_message('Do you want to continue with another patch'):
raise KeyboardInterrupt
ret_code = cls.git_helper.command_rebase('--skip')
cls._get_git_helper_data()
else:
break
deleted_patches = cls._update_deleted_patches(deleted_patches)
#TODO correct settings for merge tool in ~/.gitconfig
# currently now meld is not started
return {'modified': modified_patches, 'deleted': deleted_patches, 'unapplied': unapplied_patches}
示例14: patch
def patch(self, old_dir, new_dir, rest_sources, git_helper, patches, prep, **kwargs):
"""
Apply patches and generate rebased patches if needed
:param old_dir: path to dir with old patches
:param new_dir: path to dir with new patches
:param patches: old patches
:param rebased_patches: rebased patches
:param kwargs: --
:return:
"""
logger.debug("Patching source by patch tool %s", self._patch_tool_name)
return self._tool.run_patch(old_dir, new_dir, rest_sources, git_helper, patches, prep, **kwargs)
示例15: run
def run():
debug_log_file = None
try:
# be verbose until debug_log_file is created
handler = LoggerHelper.add_stream_handler(logger, logging.DEBUG)
if "--builder-options" in sys.argv[1:]:
raise RebaseHelperError(
"Wrong format of --builder-options. It must be in the following form:"
' --builder-options="--desired-builder-option".'
)
cli = CLI()
execution_dir, results_dir, debug_log_file, report_log_file = Application.setup(cli)
if not cli.verbose:
handler.setLevel(logging.INFO)
app = Application(cli, execution_dir, results_dir, debug_log_file, report_log_file)
app.run()
except KeyboardInterrupt:
logger.info("\nInterrupted by user")
except RebaseHelperError as e:
if e.args:
logger.error("\n%s", e.args[0] % e.args[1:])
else:
logger.error("\n%s", six.text_type(e))
sys.exit(1)
except SystemExit as e:
sys.exit(e.code)
except BaseException:
if debug_log_file:
logger.error(
"\nrebase-helper failed due to an unexpected error. Please report this problem"
"\nusing the following link: %s"
"\nand include the content of"
"\n'%s'"
"\nfile in the report."
"\nThank you!",
NEW_ISSUE_LINK,
debug_log_file,
)
else:
logger.error(
"\nrebase-helper failed due to an unexpected error. Please report this problem"
"\nusing the following link: %s"
"\nand include the traceback following this message in the report."
"\nThank you!",
NEW_ISSUE_LINK,
)
logger.debug("\n", exc_info=1)
sys.exit(1)
sys.exit(0)