From: "Brian Dolbec" <dolsen@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/catalyst:master commit in: catalyst/base/
Date: Thu, 26 Feb 2015 20:12:43 +0000 (UTC) [thread overview]
Message-ID: <1420091887.80493d8d32cb21d622bb2f514da68ac3106b7c35.dolsen@gentoo> (raw)
Message-ID: <20150226201243.0u0r34aCnciIJBgg55WjYTK2xZgNEoEnLNbYztiesrM@z> (raw)
commit: 80493d8d32cb21d622bb2f514da68ac3106b7c35
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sat Jun 1 06:24:46 2013 +0000
Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Thu Jan 1 05:58:07 2015 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/catalyst.git;a=commit;h=80493d8d
Refactor ClearBase code to remove code duplication.
---
catalyst/base/clearbase.py | 73 ++++++++++++++++++----------------------------
1 file changed, 29 insertions(+), 44 deletions(-)
diff --git a/catalyst/base/clearbase.py b/catalyst/base/clearbase.py
index 585d4f2..8462a3c 100644
--- a/catalyst/base/clearbase.py
+++ b/catalyst/base/clearbase.py
@@ -41,60 +41,20 @@ class ClearBase(object):
def clear_chroot(self):
- myemp=self.settings["chroot_path"]
- if os.path.isdir(myemp):
- print "Emptying directory",myemp
- """
- stat the dir, delete the dir, recreate the dir and set
- the proper perms and ownership
- """
- mystat=os.stat(myemp)
- #cmd("rm -rf "+myemp, "Could not remove existing file: "+myemp,env=self.env)
- """ 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=0755)
- os.chown(myemp,mystat[ST_UID],mystat[ST_GID])
- os.chmod(myemp,mystat[ST_MODE])
+ print 'Clearing the chroot path ...'
+ self.clear_dir(self.settings["chroot_path"], 0755, True)
def clear_packages(self):
if "pkgcache" in self.settings["options"]:
print "purging the pkgcache ..."
-
- myemp=self.settings["pkgcache_path"]
- if os.path.isdir(myemp):
- print "Emptying directory",myemp
- """
- stat the dir, delete the dir, recreate the dir and set
- the proper perms and ownership
- """
- mystat=os.stat(myemp)
- #cmd("rm -rf "+myemp, "Could not remove existing file: "+myemp,env=self.env)
- shutil.rmtree(myemp)
- ensure_dirs(myemp, mode=0755)
- os.chown(myemp,mystat[ST_UID],mystat[ST_GID])
- os.chmod(myemp,mystat[ST_MODE])
+ self.clear_dir(self.settings["pkgcache_path"])
def clear_kerncache(self):
if "kerncache" in self.settings["options"]:
print "purging the kerncache ..."
-
- myemp=self.settings["kerncache_path"]
- if os.path.isdir(myemp):
- print "Emptying directory",myemp
- """
- stat the dir, delete the dir, recreate the dir and set
- the proper perms and ownership
- """
- mystat=os.stat(myemp)
- #cmd("rm -rf "+myemp, "Could not remove existing file: "+myemp,env=self.env)
- shutil.rmtree(myemp)
- ensure_dirs(myemp, mode=0755)
- os.chown(myemp,mystat[ST_UID],mystat[ST_GID])
- os.chmod(myemp,mystat[ST_MODE])
+ self.clear_dir(self.settings["kerncache_path"])
def purge(self):
@@ -113,3 +73,28 @@ class ClearBase(object):
print "clearing kerncache ..."
self.clear_kerncache()
+
+ def clear_dir(self, myemp, mode=0755, chg_flags=False):
+ '''Universal directory clearing function
+ '''
+ if not myemp:
+ return False
+ if os.path.isdir(myemp):
+ print "Emptying directory" , myemp
+ """
+ stat the dir, delete the dir, recreate the dir and set
+ the proper perms and ownership
+ """
+ try:
+ mystat=os.stat(myemp)
+ """ There's no easy way to change flags recursively in python """
+ if chg_flags and os.uname()[0] == "FreeBSD":
+ os.system("chflags -R noschg " + myemp)
+ shutil.rmtree(myemp)
+ ensure_dirs(myemp, mode=mode)
+ os.chown(myemp,mystat[ST_UID],mystat[ST_GID])
+ os.chmod(myemp,mystat[ST_MODE])
+ except Exception as e:
+ print CatalystError("clear_dir(); Exeption: %s" % str(e))
+ return False
+ return True
next reply other threads:[~2015-02-26 20:13 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-01 5:59 Brian Dolbec [this message]
2015-02-26 20:12 ` [gentoo-commits] proj/catalyst:master commit in: catalyst/base/ Brian Dolbec
-- strict thread matches above, loose matches on Subject: below --
2015-02-26 22:18 Brian Dolbec
2015-02-26 20:44 ` [gentoo-commits] proj/catalyst:pending " Brian Dolbec
2015-05-21 23:53 Brian Dolbec
2015-05-21 23:53 Brian Dolbec
2015-05-21 23:53 Brian Dolbec
2015-05-24 0:08 [gentoo-commits] proj/catalyst:master " Brian Dolbec
2015-05-21 23:53 ` [gentoo-commits] proj/catalyst:pending " Brian Dolbec
2015-05-24 0:08 [gentoo-commits] proj/catalyst:master " Brian Dolbec
2015-05-21 23:53 ` [gentoo-commits] proj/catalyst:pending " Brian Dolbec
2015-05-24 0:08 [gentoo-commits] proj/catalyst:master " Brian Dolbec
2015-05-21 23:53 ` [gentoo-commits] proj/catalyst:pending " Brian Dolbec
2015-06-15 20:25 Brian Dolbec
2015-09-01 5:58 Brian Dolbec
2015-09-01 5:58 Brian Dolbec
2015-09-03 15:14 Brian Dolbec
2015-09-03 15:14 Brian Dolbec
2015-09-03 15:14 Brian Dolbec
2015-09-03 15:14 Brian Dolbec
2015-09-03 15:14 Brian Dolbec
2015-09-04 15:20 Brian Dolbec
2015-09-06 21:18 Brian Dolbec
2015-09-08 14:14 Brian Dolbec
2015-09-08 14:17 [gentoo-commits] proj/catalyst:master " Brian Dolbec
2015-09-08 14:14 ` [gentoo-commits] proj/catalyst:pending " Brian Dolbec
2015-09-08 14:17 [gentoo-commits] proj/catalyst:master " Brian Dolbec
2015-09-08 14:14 ` [gentoo-commits] proj/catalyst:pending " Brian Dolbec
2015-10-31 20:35 [gentoo-commits] proj/catalyst:master " Brian Dolbec
2015-11-21 1:33 ` [gentoo-commits] proj/catalyst:pending " Brian Dolbec
2015-10-31 20:35 [gentoo-commits] proj/catalyst:master " Brian Dolbec
2015-11-21 1:33 ` [gentoo-commits] proj/catalyst:pending " Brian Dolbec
2015-11-09 4:47 [gentoo-commits] proj/catalyst:master " Brian Dolbec
2015-11-21 1:33 ` [gentoo-commits] proj/catalyst:pending " Brian Dolbec
2015-11-20 21:26 [gentoo-commits] proj/catalyst:master " Brian Dolbec
2015-11-21 1:33 ` [gentoo-commits] proj/catalyst:pending " Brian Dolbec
2015-11-21 1:33 Brian Dolbec
2015-11-21 1:33 Brian Dolbec
2015-11-21 1:33 Brian Dolbec
2015-11-21 1:33 Brian Dolbec
2017-03-09 9:39 Brian Dolbec
2017-03-09 9:39 Brian Dolbec
2017-03-09 10:02 Brian Dolbec
2017-03-09 10:02 Brian Dolbec
2017-03-11 7:07 Brian Dolbec
2017-03-11 7:07 Brian Dolbec
2017-03-11 9:35 Brian Dolbec
2017-03-16 22:57 Brian Dolbec
2017-03-16 22:57 Brian Dolbec
2017-03-16 22:57 Brian Dolbec
2017-11-22 15:52 Brian Dolbec
2017-11-29 17:20 [gentoo-commits] proj/catalyst:master " Brian Dolbec
2017-11-22 15:52 ` [gentoo-commits] proj/catalyst:pending " Brian Dolbec
2017-11-29 17:20 [gentoo-commits] proj/catalyst:master " Brian Dolbec
2017-11-22 15:52 ` [gentoo-commits] proj/catalyst:pending " 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=1420091887.80493d8d32cb21d622bb2f514da68ac3106b7c35.dolsen@gentoo \
--to=dolsen@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