Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 539448 Details for
Bug 661084
dev-util/catalyst-3.0.1 - not handling wildcards in livecd/rm properly
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
proposed clear_files function
file_661084.txt (text/plain), 1.65 KB, created by
Michael 'veremitz' Everitt
on 2018-07-13 22:24:48 UTC
(
hide
)
Description:
proposed clear_files function
Filename:
MIME Type:
Creator:
Michael 'veremitz' Everitt
Created:
2018-07-13 22:24:48 UTC
Size:
1.65 KB
patch
obsolete
>diff --git a/catalyst/fileops.py b/catalyst/fileops.py >index ab6a0c9f..256d7b02 100644 >--- a/catalyst/fileops.py >+++ b/catalyst/fileops.py >@@ -70,6 +70,7 @@ def clear_dir(target, mode=0o755, chg_flags=False, remove=False, > return False > > mystat = None >+ myglob = glob.glob(target) > if os.path.isdir(target) and not os.path.islink(target): > log.notice('Emptying directory: %s', target) > # stat the dir, delete the dir, recreate the dir and set >@@ -92,11 +93,14 @@ def clear_dir(target, mode=0o755, chg_flags=False, remove=False, > else: > log.info('clear_dir failed: %s: is not a directory', target) > return False >+ elif myglob: >+ return clear_files(myglob) > else: > log.debug("Condidtions not met to clear: %s", target) > log.debug(" isdir: %s", os.path.isdir(target)) > log.debug(" islink: %s", os.path.islink(target)) > log.debug(" exists: %s", os.path.exists(target)) >+ log.debug(" glob: %d", len(myglob)) > > if not remove: > log.debug('ensure_dirs()') >@@ -109,6 +113,24 @@ def clear_dir(target, mode=0o755, chg_flags=False, remove=False, > return True > > >+def clear_files(targets): >+ '''Universal file clearing function >+ >+ @targets: list of files to remove >+ @return boolean >+ ''' >+ for myfile in targets: >+ try: >+ log.debug("os.remove()") >+ os.remove(myfile) >+ except Exception >+ log.error('clear_files failed', exc_info=True) >+ return False >+ >+ log.debug('DONE, returning True') >+ return True >+ >+ > def clear_path(target): > """Nuke |target| regardless of it being a dir or file.""" > clear_dir(target, remove=True)
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 661084
:
539448
|
539960