本文整理汇总了Python中preupg.utils.FileHelper.remove_home_issues方法的典型用法代码示例。如果您正苦于以下问题:Python FileHelper.remove_home_issues方法的具体用法?Python FileHelper.remove_home_issues怎么用?Python FileHelper.remove_home_issues使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类preupg.utils.FileHelper
的用法示例。
在下文中一共展示了FileHelper.remove_home_issues方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
# 需要导入模块: from preupg.utils import FileHelper [as 别名]
# 或者: from preupg.utils.FileHelper import remove_home_issues [as 别名]
#.........这里部分代码省略.........
# We do not want to continue
return ReturnValues.RISK_CLEANUP_KICKSTART
if self.conf.text:
# Test whether w3m, lynx and elinks packages are installed
found = False
for pkg in SystemIdentification.get_convertors():
if xml_manager.get_package_version(pkg):
self.text_convertor = pkg
found = True
break
if not found:
log_message(settings.converter_message.format(' '.join(SystemIdentification.get_convertors())))
return ReturnValues.MISSING_TEXT_CONVERTOR
if os.geteuid() != 0:
print("Need to be root", end="\n")
if not self.conf.debug:
return ReturnValues.ROOT
if self.conf.cleanup:
self.clean_preupgrade_environment()
return 0
self.openscap_helper = OpenSCAPHelper(self.conf.assessment_results_dir,
self.conf.result_prefix,
self.conf.xml_result_name,
self.conf.html_result_name,
self.content)
if self.conf.riskcheck:
if not os.path.exists(self.openscap_helper.get_default_xml_result_path()):
log_message("The 'preupg' command was not run yet. Run it to check for possible risks.")
return ReturnValues.PREUPG_BEFORE_KICKSTART
return_val = XccdfHelper.check_inplace_risk(self.openscap_helper.get_default_xml_result_path(),
self.conf.verbose)
return return_val
if self.conf.kickstart:
if not os.path.exists(self.openscap_helper.get_default_xml_result_path()):
log_message("The 'preupg' command was not run yet. Run it before the Kickstart generation.")
return ReturnValues.PREUPG_BEFORE_KICKSTART
kg = KickstartGenerator(self.conf, settings.KS_DIR,
settings.KS_PATH)
kg.main()
return 0
if self.conf.scan:
self.content = os.path.join(self.conf.source_dir,
self.conf.scan,
settings.content_file)
if self.conf.scan.startswith("/"):
log_message('Specify the correct upgrade path parameter like -s RHEL6_7')
log_message("Upgrade path is provided by the 'preupg --list' command.")
self._check_available_contents()
log_message("The available upgrade paths: '%s'" % '\n'.join(self.list_scans))
return ReturnValues.SCENARIO
if not os.path.isdir(os.path.join(self.conf.source_dir, self.conf.scan)):
log_message('Specify the correct upgrade path parameter like -s RHEL6_7')
self._check_available_contents()
log_message("Upgrade path is provided by the 'preupg --list' command.")
log_message("The available upgrade paths: '%s'" % '\n'.join(self.list_scans))
return ReturnValues.SCENARIO
if self.conf.contents:
self.content = os.path.join(os.getcwd(), self.conf.contents)
# From content path like content-users/RHEL6_7 we need
# to get content-users dir
content_dir = self.conf.contents[:self.conf.contents.find(self.get_scenario())]
self.conf.source_dir = os.path.join(os.getcwd(), content_dir)
self.common = Common(self.conf)
if not self.conf.skip_common:
if not self.common.common_results():
return ReturnValues.SCRIPT_TXT_MISSING
if self.conf.scan or self.conf.contents:
if not os.path.exists(settings.openscap_binary):
log_message("Oscap with SCE enabled is not installed")
return ReturnValues.MISSING_OPENSCAP
if not os.access(settings.openscap_binary, os.X_OK):
log_message("Oscap with SCE %s is not executable" % settings.openscap_binary)
return ReturnValues.MISSING_OPENSCAP
current_dir = os.getcwd()
os.chdir("/tmp")
retval = self.scan_system()
if int(retval) != 0:
return retval
self.summary_report(self.tar_ball_name)
self.common.copy_common_files()
KickstartGenerator.kickstart_scripts()
FileHelper.remove_home_issues()
if self.conf.upload:
self.upload_results(self.tar_ball_name)
os.chdir(current_dir)
return self.report_return_value
log_message('Nothing to do. Give me a task, please.')
self.conf.settings[2].parser.print_help()
return 0
示例2: run
# 需要导入模块: from preupg.utils import FileHelper [as 别名]
# 或者: from preupg.utils.FileHelper import remove_home_issues [as 别名]
#.........这里部分代码省略.........
result_xml_path = os.path.join(settings.assessment_results_dir,
settings.xml_result_name)
if not os.path.exists(result_xml_path):
log_message("System assessment needs to be performed first.")
return ReturnValues.PREUPG_BEFORE_RISKCHECK
return XccdfHelper.check_inplace_risk(result_xml_path,
self.conf.verbose)
if self.conf.upload and self.conf.results:
if not self.upload_results():
return ReturnValues.SEND_REPORT_TO_UI
return 0
if self.conf.cleanup:
if not self.executed_under_root():
return ReturnValues.ROOT
self.clean_preupgrade_environment()
return 0
if self.conf.text:
# Test whether w3m, lynx and elinks packages are installed
found = False
for pkg in SystemIdentification.get_convertors():
if xml_manager.get_package_version(pkg):
self.text_convertor = pkg
found = True
break
if not found:
log_message(settings.converter_message.format(
' '.join(SystemIdentification.get_convertors())))
return ReturnValues.MISSING_TEXT_CONVERTOR
return_code = self.determine_module_set_location()
if return_code:
return return_code
self.determine_module_set_copy_location()
if self.conf.list_rules:
rules = [x for x in
XccdfHelper.get_list_rules(self.all_xccdf_xml_path)]
log_message('\n'.join(rules))
return 0
if self.conf.mode and self.conf.select_rules:
log_message(settings.options_not_allowed)
return ReturnValues.MODE_SELECT_RULES
# If force option is not mentioned and user selects NO then exit
if not self.conf.force:
text = ""
if self.conf.dst_arch:
correct_option = [x for x in settings.migration_options
if self.conf.dst_arch == x]
if not correct_option:
sys.stderr.write(
"Error: Specify correct value for --dst-arch"
" option.\nValid are: %s.\n"
% ", ".join(settings.migration_options)
)
return ReturnValues.INVALID_CLI_OPTION
if SystemIdentification.get_arch() == "i386" or \
SystemIdentification.get_arch() == "i686":
if not self.conf.dst_arch:
text = '\n' + settings.migration_text
logger_debug.debug("Architecture '%s'. Text '%s'.",
SystemIdentification.get_arch(), text)
if not show_message(settings.warning_text + text):
# User does not want to continue
return ReturnValues.USER_ABORT
self.openscap_helper = OpenSCAPHelper(self.conf.assessment_results_dir,
self.conf.result_prefix,
self.conf.xml_result_name,
self.conf.html_result_name,
self.all_xccdf_xml_path)
if not self.executed_under_root():
return ReturnValues.ROOT
if not os.path.exists(settings.openscap_binary):
log_message("Oscap with SCE enabled is not installed")
return ReturnValues.MISSING_OPENSCAP
if not os.access(settings.openscap_binary, os.X_OK):
log_message("Oscap with SCE %s is not executable"
% settings.openscap_binary)
return ReturnValues.MISSING_OPENSCAP
self.execution_dir = os.getcwd()
os.chdir("/tmp")
retval = self.scan_system()
if retval != 0:
return retval
retval = self.summary_report(self.tar_ball_name)
self.common.copy_common_files()
KickstartGenerator.kickstart_scripts()
FileHelper.remove_home_issues()
if self.conf.upload:
if not self.upload_results():
retval = ReturnValues.SEND_REPORT_TO_UI
os.chdir(self.execution_dir)
return retval