From: "Mike Frysinger" <vapier@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/catalyst:master commit in: catalyst/base/, catalyst/targets/
Date: Sun, 22 May 2016 03:34:50 +0000 (UTC) [thread overview]
Message-ID: <1463722963.415c65624ff62f5ab139666cd5447bc35e1e9e8b.vapier@gentoo> (raw)
commit: 415c65624ff62f5ab139666cd5447bc35e1e9e8b
Author: Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Fri May 20 05:42:43 2016 +0000
Commit: Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Fri May 20 05:42:43 2016 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=415c6562
replace ad-hoc implementations of clear_dir
A few places copy & paste the logic we have in the clear_dir func.
Punt them with a simple call to clear_dir.
catalyst/base/stagebase.py | 9 +--------
catalyst/targets/netboot2.py | 10 ++--------
catalyst/targets/snapshot.py | 20 ++------------------
3 files changed, 5 insertions(+), 34 deletions(-)
diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
index 78e5b94..f0f3ba9 100644
--- a/catalyst/base/stagebase.py
+++ b/catalyst/base/stagebase.py
@@ -3,7 +3,6 @@ import os
import imp
import shutil
import sys
-from stat import ST_UID, ST_GID, ST_MODE
from snakeoil import fileutils
@@ -1202,13 +1201,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
log.warning('not a directory or does not exist, skipping "empty" operation: %s', x)
continue
log.info('Emptying directory %s', x)
- # stat the dir, delete the dir, recreate the dir and set
- # the proper perms and ownership
- mystat=os.stat(myemp)
- shutil.rmtree(myemp)
- ensure_dirs(myemp, mode=0o755)
- os.chown(myemp,mystat[ST_UID],mystat[ST_GID])
- os.chmod(myemp,mystat[ST_MODE])
+ clear_dir(myemp)
self.resume.enable("empty")
def remove(self):
diff --git a/catalyst/targets/netboot2.py b/catalyst/targets/netboot2.py
index da856ba..87dada3 100644
--- a/catalyst/targets/netboot2.py
+++ b/catalyst/targets/netboot2.py
@@ -4,12 +4,10 @@ netboot target, version 2
# NOTE: That^^ docstring has influence catalyst-spec(5) man page generation.
import os
-import shutil
-from stat import ST_UID, ST_GID, ST_MODE
from catalyst import log
from catalyst.support import (CatalystError, normpath, cmd)
-from catalyst.fileops import ensure_dirs, clear_path
+from catalyst.fileops import (ensure_dirs, clear_dir, clear_path)
from catalyst.base.stagebase import StageBase
@@ -152,11 +150,7 @@ class netboot2(StageBase):
log.info('Emptying directory %s', x)
# stat the dir, delete the dir, recreate the dir and set
# the proper perms and ownership
- mystat=os.stat(myemp)
- shutil.rmtree(myemp)
- ensure_dirs(myemp, mode=0o755)
- os.chown(myemp,mystat[ST_UID],mystat[ST_GID])
- os.chmod(myemp,mystat[ST_MODE])
+ clear_dir(myemp)
self.resume.enable("empty")
def set_action_sequence(self):
diff --git a/catalyst/targets/snapshot.py b/catalyst/targets/snapshot.py
index 7ba94b2..8a9acdd 100644
--- a/catalyst/targets/snapshot.py
+++ b/catalyst/targets/snapshot.py
@@ -2,17 +2,13 @@
Snapshot target
"""
-import os
-import shutil
-from stat import ST_UID, ST_GID, ST_MODE
-
from DeComp.compress import CompressMap
from catalyst import log
from catalyst.support import normpath, cmd
from catalyst.base.targetbase import TargetBase
from catalyst.base.genbase import GenBase
-from catalyst.fileops import ensure_dirs
+from catalyst.fileops import (clear_dir, ensure_dirs)
class snapshot(TargetBase, GenBase):
@@ -102,16 +98,4 @@ class snapshot(TargetBase, GenBase):
log.info('Cleaning up ...')
def purge(self):
- myemp=self.settings["tmp_path"]
- if os.path.isdir(myemp):
- log.notice('Emptying directory %s', myemp)
- # stat the dir, delete the dir, recreate the dir and set
- # the proper perms and ownership
- mystat=os.stat(myemp)
- # There's no easy way to change flags recursively in python
- if os.uname()[0] == "FreeBSD":
- os.system("chflags -R noschg "+myemp)
- shutil.rmtree(myemp)
- ensure_dirs(myemp, mode=0o755)
- os.chown(myemp,mystat[ST_UID],mystat[ST_GID])
- os.chmod(myemp,mystat[ST_MODE])
+ clear_dir(self.settings['tmp_path'])
next reply other threads:[~2016-05-22 3:35 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-22 3:34 Mike Frysinger [this message]
-- strict thread matches above, loose matches on Subject: below --
2024-08-03 10:53 [gentoo-commits] proj/catalyst:master commit in: catalyst/base/, catalyst/targets/ Andreas K. Hüttel
2021-01-28 1:54 [gentoo-commits] proj/catalyst:pending/mattst88 commit in: catalyst/targets/, catalyst/base/ Matt Turner
2021-01-23 16:22 ` [gentoo-commits] proj/catalyst:master commit in: catalyst/base/, catalyst/targets/ Matt Turner
2021-01-28 1:54 [gentoo-commits] proj/catalyst:pending/mattst88 commit in: catalyst/targets/, catalyst/base/ Matt Turner
2021-01-23 16:22 ` [gentoo-commits] proj/catalyst:master commit in: catalyst/base/, catalyst/targets/ Matt Turner
2020-12-19 19:56 [gentoo-commits] proj/catalyst:wip/mattst88 " Matt Turner
2020-10-30 22:41 ` [gentoo-commits] proj/catalyst:master " Matt Turner
2020-10-30 22:41 Matt Turner
2020-04-18 20:30 Matt Turner
2020-04-15 18:29 Matt Turner
2020-04-13 20:43 Matt Turner
2015-11-20 21:26 Brian Dolbec
2015-09-06 21:18 [gentoo-commits] proj/catalyst:pending " Brian Dolbec
2015-09-06 21:21 ` [gentoo-commits] proj/catalyst:master " Brian Dolbec
2015-02-26 19:25 [gentoo-commits] proj/catalyst:pending " Brian Dolbec
2015-02-26 20:12 ` [gentoo-commits] proj/catalyst:master " Brian Dolbec
2015-02-26 4:12 Brian Dolbec
2015-01-01 5:59 [gentoo-commits] proj/catalyst:pending commit in: catalyst/targets/, catalyst/base/ Brian Dolbec
2015-02-26 20:12 ` [gentoo-commits] proj/catalyst:master commit in: catalyst/base/, catalyst/targets/ Brian Dolbec
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1463722963.415c65624ff62f5ab139666cd5447bc35e1e9e8b.vapier@gentoo \
--to=vapier@gentoo.org \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox