self._init_rootdir()
def _init_url(self):
- f = open(os.path.join(self.confdir, 'webport'), 'r')
- contents = f.read()
- f.close()
-
- fields = contents.split(':')
- proto, port = fields[:2]
- assert proto == 'tcp'
- port = int(port)
- self.url = 'http://localhost:%d' % (port,)
+ if os.path.exists(os.path.join(self.confdir, 'node.url')):
+ self.url = file(os.path.join(self.confdir, 'node.url'), 'rb').read().strip()
+ if not self.url.endswith('/'):
+ self.url += '/'
+ else:
+ f = open(os.path.join(self.confdir, 'webport'), 'r')
+ contents = f.read()
+ f.close()
+ fields = contents.split(':')
+ proto, port = fields[:2]
+ assert proto == 'tcp'
+ port = int(port)
+ self.url = 'http://localhost:%d' % (port,)
def _init_rootdir(self):
# For now we just use the same default as the CLI:
return TahoeFile(baseurl, uri)
def __init__(self, baseurl, uri):
+ if not baseurl.endswith('/'):
+ baseurl += '/'
self.burl = baseurl
self.uri = uri
- self.fullurl = '%s/uri/%s' % (self.burl, self.uri)
+ self.fullurl = '%suri/%s' % (self.burl, self.uri)
self.inode = TahoeNode.NextInode
TahoeNode.NextInode += 1
self._init_url()
def _init_url(self):
- f = open(os.path.join(self.confdir, 'webport'), 'r')
- contents = f.read()
- f.close()
-
- fields = contents.split(':')
- proto, port = fields[:2]
- assert proto == 'tcp'
- port = int(port)
- self.url = 'http://localhost:%d' % (port,)
+ if os.path.exists(os.path.join(self.confdir, 'node.url')):
+ self.url = file(os.path.join(self.confdir, 'node.url'), 'rb').read().strip()
+ if not self.url.endswith('/'):
+ self.url += '/'
+ else:
+ f = open(os.path.join(self.confdir, 'webport'), 'r')
+ contents = f.read()
+ f.close()
+ fields = contents.split(':')
+ proto, port = fields[:2]
+ assert proto == 'tcp'
+ port = int(port)
+ self.url = 'http://localhost:%d/' % (port,)
def get_root(self):
# For now we just use the same default as the CLI:
return simplejson.loads(json)
def _open(self, postfix=''):
- url = '%s/uri/%s%s' % (self.conn.url, self.uri, postfix)
+ url = '%suri/%s%s' % (self.conn.url, self.uri, postfix)
log('*** Fetching: %r', url)
return urllib.urlopen(url)