]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
client.py: allow operation without vdrive.furl, for storage-only no-UI nodes
authorBrian Warner <warner@allmydata.com>
Fri, 8 Jun 2007 00:55:49 +0000 (17:55 -0700)
committerBrian Warner <warner@allmydata.com>
Fri, 8 Jun 2007 00:55:49 +0000 (17:55 -0700)
src/allmydata/client.py
src/allmydata/test/test_client.py

index c81910f0558df81799290cc012ca2deba7dbdf9a..f25ed962a40795ae4b3a833bce698a0ada87c9f5 100644 (file)
@@ -40,7 +40,6 @@ class Client(node.Node, Referenceable):
         self.add_service(StorageServer(os.path.join(basedir, self.STOREDIR)))
         self.add_service(Uploader())
         self.add_service(Downloader())
-        self.add_service(VDrive())
         WEBPORTFILE = os.path.join(self.basedir, self.WEBPORTFILE)
         if os.path.exists(WEBPORTFILE):
             f = open(WEBPORTFILE, "r")
@@ -54,11 +53,14 @@ class Client(node.Node, Referenceable):
         self.introducer_furl = f.read().strip()
         f.close()
 
+        self.global_vdrive_furl = None
         GLOBAL_VDRIVE_FURL_FILE = os.path.join(self.basedir,
                                                self.GLOBAL_VDRIVE_FURL_FILE)
-        f = open(GLOBAL_VDRIVE_FURL_FILE, "r")
-        self.global_vdrive_furl = f.read().strip()
-        f.close()
+        if os.path.exists(GLOBAL_VDRIVE_FURL_FILE):
+            f = open(GLOBAL_VDRIVE_FURL_FILE, "r")
+            self.global_vdrive_furl = f.read().strip()
+            f.close()
+            self.add_service(VDrive())
 
         hotline_file = os.path.join(self.basedir,
                                     self.SUICIDE_PREVENTION_HOTLINE_FILE)
@@ -95,8 +97,9 @@ class Client(node.Node, Referenceable):
 
         self.register_control()
 
-        self.vdrive_connector = self.tub.connectTo(self.global_vdrive_furl,
-                                                   self._got_vdrive)
+        if self.global_vdrive_furl:
+            self.vdrive_connector = self.tub.connectTo(self.global_vdrive_furl,
+                                                       self._got_vdrive)
 
     def register_control(self):
         c = ControlServer()
index 3366dea6321fc9f9464dc7b0ac3a790419c1cc59..2f42468972bda1b8b0e9af1d6b3a7768ed251eba 100644 (file)
@@ -21,6 +21,12 @@ class Basic(unittest.TestCase):
         open(os.path.join(basedir, "vdrive.furl"), "w").write("")
         c = client.Client(basedir)
 
+    def test_loadable_without_vdrive(self):
+        basedir = "test_client.Basic.test_loadable_without_vdrive"
+        os.mkdir(basedir)
+        open(os.path.join(basedir, "introducer.furl"), "w").write("")
+        c = client.Client(basedir)
+
     def test_permute(self):
         basedir = "test_client.Basic.test_permute"
         os.mkdir(basedir)