From: Brian Warner Date: Fri, 8 Jun 2007 00:55:49 +0000 (-0700) Subject: client.py: allow operation without vdrive.furl, for storage-only no-UI nodes X-Git-Tag: allmydata-tahoe-0.3.0~17 X-Git-Url: https://git.rkrishnan.org/components/%22news.html/...?a=commitdiff_plain;h=8907e04ef542f0143e1d2010bd38bef792985432;p=tahoe-lafs%2Ftahoe-lafs.git client.py: allow operation without vdrive.furl, for storage-only no-UI nodes --- diff --git a/src/allmydata/client.py b/src/allmydata/client.py index c81910f0..f25ed962 100644 --- a/src/allmydata/client.py +++ b/src/allmydata/client.py @@ -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() diff --git a/src/allmydata/test/test_client.py b/src/allmydata/test/test_client.py index 3366dea6..2f424689 100644 --- a/src/allmydata/test/test_client.py +++ b/src/allmydata/test/test_client.py @@ -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)