Exclude repositories from ftp browser
authorMagnus Hagander <magnus@hagander.net>
Fri, 18 Oct 2013 15:58:49 +0000 (17:58 +0200)
committerMagnus Hagander <magnus@hagander.net>
Fri, 18 Oct 2013 15:59:52 +0000 (17:59 +0200)
There is no need to browse into the repositories on the main website.
It's still possible to browse there directly on the ftp servers of course,
for those that need to debug a repository install and things like that.

tools/ftp/spider_ftp.py

index a1a1f05630622ecd51161c366926170a71b22a64..c9e50e9a0437a27c0467e5cea272cc29b2fef2ce 100755 (executable)
@@ -13,6 +13,10 @@ import cPickle as pickle
 import codecs
 import urllib2
 
+# Directories, specified from the root of the ftp tree and down, that
+# will be recursively excluded from the pickle.
+exclude_roots = ['/repos', ]
+
 allnodes = {}
 
 def read_file(fn):
@@ -37,11 +41,13 @@ def parse_directory(dirname, rootlen):
                                        'd': os.readlink(fn),
                                        }
                        else:
-                               # This is a subdirectory, recurse into it
-                               parse_directory(fn, rootlen)
-                               mynode[f] = {
-                                       't': 'd',
-                               }
+                               # This is a subdirectory, recurse into it, unless it happens
+                               # to be on our exclude list.
+                               if not fn[rootlen:] in exclude_roots:
+                                       parse_directory(fn, rootlen)
+                                       mynode[f] = {
+                                               't': 'd',
+                                       }
                else:
                        # This a file
                        stat = os.stat(fn)