client.py: allow operation without vdrive.furl, for storage-only no-UI nodes

This commit is contained in:
Brian Warner 2007-06-07 17:55:49 -07:00
parent 59f4a5abe8
commit 8907e04ef5
2 changed files with 15 additions and 6 deletions

View File

@ -40,7 +40,6 @@ class Client(node.Node, Referenceable):
self.add_service(StorageServer(os.path.join(basedir, self.STOREDIR))) self.add_service(StorageServer(os.path.join(basedir, self.STOREDIR)))
self.add_service(Uploader()) self.add_service(Uploader())
self.add_service(Downloader()) self.add_service(Downloader())
self.add_service(VDrive())
WEBPORTFILE = os.path.join(self.basedir, self.WEBPORTFILE) WEBPORTFILE = os.path.join(self.basedir, self.WEBPORTFILE)
if os.path.exists(WEBPORTFILE): if os.path.exists(WEBPORTFILE):
f = open(WEBPORTFILE, "r") f = open(WEBPORTFILE, "r")
@ -54,11 +53,14 @@ class Client(node.Node, Referenceable):
self.introducer_furl = f.read().strip() self.introducer_furl = f.read().strip()
f.close() f.close()
self.global_vdrive_furl = None
GLOBAL_VDRIVE_FURL_FILE = os.path.join(self.basedir, GLOBAL_VDRIVE_FURL_FILE = os.path.join(self.basedir,
self.GLOBAL_VDRIVE_FURL_FILE) self.GLOBAL_VDRIVE_FURL_FILE)
f = open(GLOBAL_VDRIVE_FURL_FILE, "r") if os.path.exists(GLOBAL_VDRIVE_FURL_FILE):
self.global_vdrive_furl = f.read().strip() f = open(GLOBAL_VDRIVE_FURL_FILE, "r")
f.close() self.global_vdrive_furl = f.read().strip()
f.close()
self.add_service(VDrive())
hotline_file = os.path.join(self.basedir, hotline_file = os.path.join(self.basedir,
self.SUICIDE_PREVENTION_HOTLINE_FILE) self.SUICIDE_PREVENTION_HOTLINE_FILE)
@ -95,8 +97,9 @@ class Client(node.Node, Referenceable):
self.register_control() self.register_control()
self.vdrive_connector = self.tub.connectTo(self.global_vdrive_furl, if self.global_vdrive_furl:
self._got_vdrive) self.vdrive_connector = self.tub.connectTo(self.global_vdrive_furl,
self._got_vdrive)
def register_control(self): def register_control(self):
c = ControlServer() c = ControlServer()

View File

@ -21,6 +21,12 @@ class Basic(unittest.TestCase):
open(os.path.join(basedir, "vdrive.furl"), "w").write("") open(os.path.join(basedir, "vdrive.furl"), "w").write("")
c = client.Client(basedir) 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): def test_permute(self):
basedir = "test_client.Basic.test_permute" basedir = "test_client.Basic.test_permute"
os.mkdir(basedir) os.mkdir(basedir)