[mirrorbrain-commits] r8233 - in /trunk/mb: mb.py mb/files.py

From: <poeml_at_mirrorbrain.org>
Date: Wed, 29 Dec 2010 19:00:17 -0000
Author: poeml
Date: Wed Dec 29 20:00:15 2010
New Revision: 8233

URL: http://svn.mirrorbrain.org/viewvc/mirrorbrain?rev=8233&view=rev
Log:
mb dirs:
- add --missing DIR option to list all mirrors which don't have the given
  directory DIR

Modified:
    trunk/mb/mb.py
    trunk/mb/mb/files.py

Modified: trunk/mb/mb.py
URL: http://svn.mirrorbrain.org/viewvc/mirrorbrain/trunk/mb/mb.py?rev=8233&r1=8232&r2=8233&view=diff
==============================================================================
--- trunk/mb/mb.py (original)
+++ trunk/mb/mb.py Wed Dec 29 20:00:15 2010
_at_@ -1383,6 +1383,10 @@
                   help='show up to N distinct path segments.')
     _at_cmdln.option('-d', dest='dirpath', metavar='DIR',
                   help='list mirrors on which DIR was found.')
+    _at_cmdln.option('--missing', dest='missingdirpath', metavar='DIR',
+                  help='list mirrors on which DIR was *not* found.')
+    _at_cmdln.option('--sql-debug', action='store_true',
+                  help='Show SQL statements for debugging purposes.')
     def do_dirs(self, subcmd, opts, *args):
         """${cmd_name}: show directories that are in the database
 
_at_@ -1416,6 +1420,9 @@
 
         if opts.dirpath:
             for i in mb.files.dir_show_mirrors(self.conn, opts.dirpath):
+                print i[0]
+        elif opts.missingdirpath:
+            for i in mb.files.dir_show_mirrors(self.conn, opts.missingdirpath, missing=True):
                 print i[0]
         else:
             for i in mb.files.dir_ls(self.conn, segments=opts.segments, mirror=mirror):

Modified: trunk/mb/mb/files.py
URL: http://svn.mirrorbrain.org/viewvc/mirrorbrain/trunk/mb/mb/files.py?rev=8233&r1=8232&r2=8233&view=diff
==============================================================================
--- trunk/mb/mb/files.py (original)
+++ trunk/mb/mb/files.py Wed Dec 29 20:00:15 2010
_at_@ -120,14 +120,18 @@
     result = conn.Server._connection.queryAll(query)
     return result
 
-def dir_show_mirrors(conn, path):
+def dir_show_mirrors(conn, path, missing=False):
     """Show mirrors on which a certain directory path was found.
     The path could actually also be a file, it doesn't matter, but 
     directory is what we are looking for in the context that this function was
     written for.
     """
 
-    query = """select distinct(mirrors) from filearr where path like '%s%%'""" % path
+    if missing:
+        query = """select distinct(mirrors) from filearr where path not like '%s%%'""" % path
+    else:
+        query = """select distinct(mirrors) from filearr where path like '%s%%'""" % path
+
     result = conn.Server._connection.queryAll(query)
 
     mirror_ids = []




_______________________________________________
mirrorbrain-commits mailing list
Archive: http://mirrorbrain.org/archive/mirrorbrain-commits/

Note: To remove yourself from this list, send a mail with the content
 	unsubscribe
to the address mirrorbrain-commits-request_at_mirrorbrain.org
Received on Wed Dec 29 2010 - 19:00:21 GMT

This archive was generated by hypermail 2.3.0 : Mon Feb 20 2012 - 23:47:04 GMT