本文整理汇总了Python中sos.archive.TarFileArchive.makedirs方法的典型用法代码示例。如果您正苦于以下问题:Python TarFileArchive.makedirs方法的具体用法?Python TarFileArchive.makedirs怎么用?Python TarFileArchive.makedirs使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sos.archive.TarFileArchive
的用法示例。
在下文中一共展示了TarFileArchive.makedirs方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: SoSReport
# 需要导入模块: from sos.archive import TarFileArchive [as 别名]
# 或者: from sos.archive.TarFileArchive import makedirs [as 别名]
class SoSReport(object):
def __init__(self, args):
self.loaded_plugins = deque()
self.skipped_plugins = deque()
self.all_options = deque()
self.xml_report = XmlReport()
self.global_plugin_options = {}
self.archive = None
self.tempfile_util = None
try:
import signal
signal.signal(signal.SIGTERM, self.get_exit_handler())
except Exception:
pass # not available in java, but we don't care
#self.opts = self.parse_options(args)[0]
self.opts = SoSOptions(args)
self._set_debug()
self._read_config()
self.policy = sos.policies.load()
self._is_root = self.policy.is_root()
self.tmpdir = self.policy.get_tmp_dir(self.opts.tmp_dir)
self.tempfile_util = TempFileUtil(self.tmpdir)
self._set_directories()
def print_header(self):
self.ui_log.info("\n%s\n" % _("sosreport (version %s)" % (__version__,)))
def get_commons(self):
return {
'cmddir': self.cmddir,
'logdir': self.logdir,
'rptdir': self.rptdir,
'tmpdir': self.tmpdir,
'soslog': self.soslog,
'proflog' : self.proflog,
'policy': self.policy,
'verbosity': self.opts.verbosity,
'xmlreport': self.xml_report,
'cmdlineopts': self.opts,
'config': self.config,
'global_plugin_options': self.global_plugin_options,
}
def get_temp_file(self):
return self.tempfile_util.new()
def _set_archive(self):
if self.opts.compression_type not in ('auto', 'zip', 'bzip2', 'gzip', 'xz'):
raise Exception("Invalid compression type specified. Options are:" +
"auto, zip, bzip2, gzip and xz")
archive_name = os.path.join(self.tmpdir,self.policy.get_archive_name())
if self.opts.compression_type == 'auto':
auto_archive = self.policy.preferred_archive_name()
self.archive = auto_archive(archive_name, self.tmpdir)
elif self.opts.compression_type == 'zip':
self.archive = ZipFileArchive(archive_name, self.tmpdir)
else:
self.archive = TarFileArchive(archive_name, self.tmpdir)
def _make_archive_paths(self):
self.archive.makedirs(self.cmddir, 0755)
self.archive.makedirs(self.logdir, 0755)
self.archive.makedirs(self.rptdir, 0755)
def _set_directories(self):
self.cmddir = 'sos_commands'
self.logdir = 'sos_logs'
self.rptdir = 'sos_reports'
def _set_debug(self):
if self.opts.debug:
sys.excepthook = self._exception
self.raise_plugins = True
else:
self.raise_plugins = False
@staticmethod
def _exception(etype, eval_, etrace):
""" Wrap exception in debugger if not in tty """
if hasattr(sys, 'ps1') or not sys.stderr.isatty():
# we are in interactive mode or we don't have a tty-like
# device, so we call the default hook
sys.__excepthook__(etype, eval_, etrace)
else:
import traceback, pdb
# we are NOT in interactive mode, print the exception...
traceback.print_exception(etype, eval_, etrace, limit=2, file=sys.stdout)
print
# ...then start the debugger in post-mortem mode.
pdb.pm()
def _exit(self, error=0):
raise SystemExit()
# sys.exit(error)
def get_exit_handler(self):
#.........这里部分代码省略.........
示例2: SoSReport
# 需要导入模块: from sos.archive import TarFileArchive [as 别名]
# 或者: from sos.archive.TarFileArchive import makedirs [as 别名]
class SoSReport(object):
"""The main sosreport class"""
def __init__(self, args):
self.loaded_plugins = deque()
self.skipped_plugins = deque()
self.all_options = deque()
self.xml_report = XmlReport()
self.global_plugin_options = {}
self.archive = None
self.tempfile_util = None
try:
import signal
signal.signal(signal.SIGTERM, self.get_exit_handler())
except Exception:
pass # not available in java, but we don't care
self.opts = SoSOptions(args)
self._set_debug()
self._read_config()
try:
self.policy = sos.policies.load()
except KeyboardInterrupt:
self._exit(0)
self._is_root = self.policy.is_root()
self.tmpdir = os.path.abspath(
self.policy.get_tmp_dir(self.opts.tmp_dir))
if not os.path.isdir(self.tmpdir) \
or not os.access(self.tmpdir, os.W_OK):
# write directly to stderr as logging is not initialised yet
sys.stderr.write("temporary directory %s " % self.tmpdir
+ "does not exist or is not writable\n")
self._exit(1)
self.tempfile_util = TempFileUtil(self.tmpdir)
self._set_directories()
def print_header(self):
self.ui_log.info("\n%s\n" % _("sosreport (version %s)" %
(__version__,)))
def get_commons(self):
return {
'cmddir': self.cmddir,
'logdir': self.logdir,
'rptdir': self.rptdir,
'tmpdir': self.tmpdir,
'soslog': self.soslog,
'policy': self.policy,
'verbosity': self.opts.verbosity,
'xmlreport': self.xml_report,
'cmdlineopts': self.opts,
'config': self.config,
'global_plugin_options': self.global_plugin_options,
}
def get_temp_file(self):
return self.tempfile_util.new()
def _set_archive(self):
archive_name = os.path.join(self.tmpdir,
self.policy.get_archive_name())
if self.opts.compression_type == 'auto':
auto_archive = self.policy.get_preferred_archive()
self.archive = auto_archive(archive_name, self.tmpdir)
elif self.opts.compression_type == 'zip':
self.archive = ZipFileArchive(archive_name, self.tmpdir)
else:
self.archive = TarFileArchive(archive_name, self.tmpdir)
self.archive.set_debug(True if self.opts.debug else False)
def _make_archive_paths(self):
self.archive.makedirs(self.cmddir, 0o755)
self.archive.makedirs(self.logdir, 0o755)
self.archive.makedirs(self.rptdir, 0o755)
def _set_directories(self):
self.cmddir = 'sos_commands'
self.logdir = 'sos_logs'
self.rptdir = 'sos_reports'
def _set_debug(self):
if self.opts.debug:
sys.excepthook = self._exception
self.raise_plugins = True
else:
self.raise_plugins = False
@staticmethod
def _exception(etype, eval_, etrace):
""" Wrap exception in debugger if not in tty """
if hasattr(sys, 'ps1') or not sys.stderr.isatty():
# we are in interactive mode or we don't have a tty-like
# device, so we call the default hook
sys.__excepthook__(etype, eval_, etrace)
else:
import pdb
#.........这里部分代码省略.........