Skip to content
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

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open

Conversation

jikamens
Copy link

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.

Jonathan Kamens added 6 commits May 24, 2017 08:40
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.
@jikamens
Copy link
Author

I am also contemplating modifying have_AFS in libdelete.py to only warn about AFS support being unavailable if the directory /afs exists, because otherwise presumably AFS isn't even running on the machine so there's no need to warn about Python support for it being unavailable. However, I'm not sure how common it is to mount AFS somewhere other than /afs, so I'm not sure this change is a great idea. Any thoughts?

Jonathan Kamens added 3 commits May 24, 2017 09:18
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.
@jikamens
Copy link
Author

jikamens commented Feb 4, 2020

Knock knock, anybody here?

@@ -156,6 +139,7 @@ def main():
rv = 1
return rv


Copy link
Member

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.)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flake8 compliance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants