-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Code cleanup, fix two bugs #4
base: master
Are you sure you want to change the base?
Conversation
If the afs python modue isn't installed, then when libdelete is imported, this was getting displayed instead of the intended warning about afs not being available: >`No handlers could be found for logger "libdelete"` This is because libdelete was attempting to import afs to check for its availability at module scope, before the main script importing libdelete had configured logging. Fix this by changing `have_AFS` from a module-scope variable to a memoized function so that the check occurs after logging is configured.
`delete` doesn't ever use `afs.fs` so it doesn't need to import it.
I am also contemplating modifying |
The code in `debug_callback` checking if the specified loggers were valid was using a set equals operator when it should have been using a subset operator.
When lsdel and expunge list files they shouldn't output a blank line when there are no files to list.
This change is intended to fix the following: ``` $ touch foo $ delete foo $ touch foo $ expunge Traceback (most recent call last): File "/usr/local/bin/expunge", line 183, in <module> sys.exit(main()) File "/usr/local/bin/expunge", line 176, in main rv += expunge(deleted_files, options) File "/usr/local/bin/expunge", line 90, in expunge os.unlink(f) OSError: [Errno 2] No such file or directory: './.#foo' $ ``` The problem was that "./.#foo" was getting added to the deleted file list twice, because it glob-matched twice, once in its undeleted form and again in its deleted form. To avoid this issue we use a uniquifying list class so that we don't add the same path to our list of deleted files twice. We use a uniquifying list rather than a set to preserve order.
Knock knock, anybody here? |
@@ -156,6 +139,7 @@ def main(): | |||
rv = 1 | |||
return rv | |||
|
|||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why so many extra blank lines?
(Sorry for the super sparse review; I'm on vacation this week and just skimming.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Flake8 compliance.
Clean up handling of presence/absence of PyAFS. Fix a missing import and a typo in a variable reference. Make all the code flake8-clean.