]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
Allows check and deep-check to take multiple arguments (ticket #740)
authorMark Berger <mark.berger.j@gmail.com>
Mon, 22 Apr 2013 06:37:39 +0000 (23:37 -0700)
committerMark Berger <mark.berger.j@gmail.com>
Fri, 26 Jul 2013 17:01:50 +0000 (13:01 -0400)
src/allmydata/scripts/cli.py
src/allmydata/scripts/tahoe_check.py

index 6fb2e04889215a6bf1804d7d76301636e37e0c2c..b0e4e6dec70834496eab7739654ed29ad717b0ff 100644 (file)
@@ -451,8 +451,8 @@ class CheckOptions(FilesystemOptions):
         ("repair", None, "Automatically repair any problems found."),
         ("add-lease", None, "Add/renew lease on all shares."),
         ]
-    def parseArgs(self, where=''):
-        self.where = argv_to_unicode(where)
+    def parseArgs(self, *locations):
+        self.locations = map(argv_to_unicode, locations)
 
     def getSynopsis(self):
         return "Usage:  %s [global-opts] check [options] [ALIAS:PATH]" % (self.command_name,)
@@ -470,8 +470,8 @@ class DeepCheckOptions(FilesystemOptions):
         ("add-lease", None, "Add/renew lease on all shares."),
         ("verbose", "v", "Be noisy about what is happening."),
         ]
-    def parseArgs(self, where=''):
-        self.where = argv_to_unicode(where)
+    def parseArgs(self, *locations):
+        self.locations = map(argv_to_unicode, locations)
 
     def getSynopsis(self):
         return "Usage:  %s [global-opts] deep-check [options] [ALIAS:PATH]" % (self.command_name,)
index 23064359d9b16987721157a0a59b1e46be82ab63..4ac669215b24e1b58824a9c1874b3d5c6c93ef0e 100644 (file)
@@ -15,13 +15,12 @@ def _quote_serverid_index_share(serverid, storage_index, sharenum):
                                            quote_output(storage_index, quotemarks=False),
                                            sharenum)
 
-def check(options):
+def check_location(options, where):
     stdout = options.stdout
     stderr = options.stderr
     nodeurl = options['node-url']
     if not nodeurl.endswith("/"):
         nodeurl += "/"
-    where = options.where
     try:
         rootcap, path = get_alias(options.aliases, where, DEFAULT_ALIAS)
     except UnknownAliasError, e:
@@ -96,10 +95,21 @@ def check(options):
             stdout.write(" corrupt shares:\n")
             for (serverid, storage_index, sharenum) in corrupt:
                 stdout.write("  %s\n" % _quote_serverid_index_share(serverid, storage_index, sharenum))
+                
+    return 0;
 
+def check(options):
+    if len(options.locations) == 0:
+        errno = check_location(options, unicode())
+        if errno != 0:
+            return errno
+        return 0
+    for location in options.locations:
+        errno = check_location(options, location)
+        if errno != 0: 
+            return errno
     return 0
 
-
 class FakeTransport:
     disconnecting = False
 
@@ -262,7 +272,7 @@ class DeepCheckAndRepairOutput(LineOnlyReceiver):
 
 class DeepCheckStreamer(LineOnlyReceiver):
 
-    def run(self, options):
+    def deepcheck_location(self, options, where):
         stdout = options.stdout
         stderr = options.stderr
         self.rc = 0
@@ -271,7 +281,7 @@ class DeepCheckStreamer(LineOnlyReceiver):
         if not nodeurl.endswith("/"):
             nodeurl += "/"
         self.nodeurl = nodeurl
-        where = options.where
+
         try:
             rootcap, path = get_alias(options.aliases, where, DEFAULT_ALIAS)
         except UnknownAliasError, e:
@@ -309,6 +319,19 @@ class DeepCheckStreamer(LineOnlyReceiver):
                 output.dataReceived(chunk)
         if not self.options["raw"]:
             output.done()
+        return 0
+        
+
+    def run(self, options):
+        if len(options.locations) == 0:
+            errno = self.deepcheck_location(options, unicode())
+            if errno != 0:
+                return errno
+            return 0
+        for location in options.locations:
+            errno = self.deepcheck_location(options, location)
+            if errno != 0:
+                return errno 
         return self.rc
 
 def deepcheck(options):