[Calypso] [PATCH] Don't throw error messages when subdirectories are scanned

chrysn chrysn at fsfe.org
Sun Feb 28 10:14:18 PST 2016


Access to the root directory or any other non-leaf directory raises a

IOError: [Errno 21] Is a directory: '.../.config/calypso/calendars/...'

which is caught and logged as an exception, but still shows even though
just a file-oriented function is called in scan_dir with a subdirectory.
Instead, now, a debug-level log message is emitted on directories that
they are ignored for the purpose of scan_dir.
---
seeing tracebacks in the log is distracting during development,
especially when there is not really an error.

 calypso/webdav.py | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/calypso/webdav.py b/calypso/webdav.py
index 12a9817..4d67db4 100644
--- a/calypso/webdav.py
+++ b/calypso/webdav.py
@@ -287,9 +287,12 @@ class Collection(object):
                         self.scan_file(filename)
                     break
             else:
-                self.log.debug("New %s", filename)
-                newfiles.append(Pathtime(filename))
-                self.insert_file(filename)
+                if os.path.isdir(filename):
+                    self.log.debug("Ignoring directory %s in scan_dir", filename)
+                else:
+                    self.log.debug("New %s", filename)
+                    newfiles.append(Pathtime(filename))
+                    self.insert_file(filename)
         for file in self.files:
             if not file.path in filenames:
                 self.log.debug("Removed %s", file.path)
-- 
2.7.0
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://keithp.com/pipermail/calypso/attachments/20160228/99ea9a9f/attachment.sig>


More information about the Calypso mailing list