bitkeeper revision 1.1108.35.7 (410a0b93obztTzgYAKS6IcEBh3xJcQ)

Use environment variables XEND and XEND_ROOT to set the location
of the xend server and its root path.
This commit is contained in:
mjw@wray-m-3.hpl.hp.com committed 2004-07-30 08:49:23 +00:00
1 parent 48434773af
commit 8a90781bf8
1 file changed
+19 -2
+19 -2
View File
@@ -9,6 +9,7 @@ The 'data-plane' is done separately. For example, consoles
are accessed via sockets on xend, but the list of consoles
is accessible via this API.
"""
import os
import sys
import httplib
import types
@@ -331,9 +332,15 @@ class Xend:
"""Default location of the xend server."""
SRV_DEFAULT = "localhost:8000"
"""Environment variable to set the location of xend."""
SRV_VAR = "XEND"
"""Default path to the xend root on the server."""
ROOT_DEFAULT = "/xend/"
"""Environment variable to set the xend root path."""
ROOT_VAR = "XEND_ROOT"
def __init__(self, client=None, srv=None, root=None):
"""Create a xend client interface.
If the client protocol is not specified, the default
@@ -348,14 +355,24 @@ class Xend:
self.client = client
self.bind(srv, root)
def default_server(self):
"""Get the default location of the xend server.
"""
return os.getenv(self.SRV_VAR, self.SRV_DEFAULT)
def default_root(self):
"""Get the default root path on the xend server.
"""
return os.getenv(self.ROOT_VAR, self.ROOT_DEFAULT)
def bind(self, srv=None, root=None):
"""Bind to a given server.
@param srv: server location (host:port)
@param root: xend root path on the server
"""
if srv is None: srv = self.SRV_DEFAULT
if root is None: root = self.ROOT_DEFAULT
if srv is None: srv = self.default_server()
if root is None: root = self.default_root()
if not root.endswith('/'): root += '/'
(host, port) = srv.split(':', 1)
self.url = URL(host=host, port=port, path=root)
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.