diff options
-rw-r--r-- | sos/archive.py | 17 | ||||
-rw-r--r-- | sos/sosreport.py | 6 |
2 files changed, 21 insertions, 2 deletions
diff --git a/sos/archive.py b/sos/archive.py index f1b0b057..3702a91f 100644 --- a/sos/archive.py +++ b/sos/archive.py @@ -41,6 +41,15 @@ class Archive(object): _name = "unset" + def __init__(self, name, tmpdir): + self._name = name + self._tmp_dir = tmpdir + self._archive_path = os.path.join(tmpdir, name) + os.makedirs(self._archive_path, 0700) + + def make_path(self, name): + return (os.path.join(self._archive_path, name)) + def prepend(self, src): if src: name = os.path.split(self._name)[-1] @@ -50,6 +59,10 @@ class Archive(object): def add_link(self, dest, link_name): pass + def makedirs(self, name, mode=0700): + print "Archive.mkdir('%s')" % name + os.makedirs(self.make_path(name), mode) + def compress(self, method): """Compress an archive object via method. ZIP archives are ignored. If method is automatic then the following technologies are tried in order: xz, @@ -59,8 +72,8 @@ class Archive(object): class TarFileArchive(Archive): - def __init__(self, name): - self._name = name + def __init__(self, name, tmpdir): + super(TarFileArchive, self).__init__(name, tmpdir) self._suffix = "tar" self.tarfile = tarfile.open(self.name(), mode="w", format=tarfile.PAX_FORMAT) diff --git a/sos/sosreport.py b/sos/sosreport.py index c58f6310..c86acd15 100644 --- a/sos/sosreport.py +++ b/sos/sosreport.py @@ -569,6 +569,11 @@ class SoSReport(object): else: self.archive = TarFileArchive(archive_name, self.opts.tmp_dir) + 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' @@ -915,6 +920,7 @@ class SoSReport(object): try: self.policy.pre_work() self._set_archive() + self._make_archive_paths() except Exception, e: import traceback traceback.print_exc(e) |