Ejemplo n.º 1
0
    if _DEBUG:
        print("Loading %s from %s" % (key, v))
    return os.path.normpath(os.path.expanduser(v))


CCNET_CONF_PATH = _load_path_from_env('CCNET_CONF_DIR')
SEAFILE_CONF_DIR = _load_path_from_env('SEAFILE_CONF_DIR')
SEAFILE_CENTRAL_CONF_DIR = _load_path_from_env('SEAFILE_CENTRAL_CONF_DIR',
                                               check=False)
SEAFILE_RPC_PIPE_PATH = _load_path_from_env("SEAFILE_RPC_PIPE_PATH",
                                            check=False)

seafile_pipe_path = os.path.join(
    SEAFILE_RPC_PIPE_PATH if SEAFILE_RPC_PIPE_PATH else SEAFILE_CONF_DIR,
    'seafile.sock')
seafserv_threaded_rpc = seafile.ServerThreadedRpcClient(seafile_pipe_path)
ccnet_threaded_rpc = seafserv_threaded_rpc

# load ccnet server addr and port from ccnet.conf.
# 'addr:port' is used when downloading a repo
config = configparser.ConfigParser()
config.read(
    os.path.join(
        SEAFILE_CENTRAL_CONF_DIR
        if SEAFILE_CENTRAL_CONF_DIR else CCNET_CONF_PATH, 'ccnet.conf'))

if config.has_option('General', 'SERVICE_URL'):
    service_url = config.get('General', 'SERVICE_URL')
    hostname = urlparse(service_url).hostname

    SERVICE_URL = service_url
Ejemplo n.º 2
0
        raise KeyError
except KeyError:
    raise ImportError(
        "Seaserv cannot be imported, because environment variable %s is undefined."
        % ENVIRONMENT_VARIABLES[0])
else:
    print "Loading ccnet config from " + CCNET_CONF_PATH

CCNET_CONF_PATH = os.path.normpath(os.path.expanduser(CCNET_CONF_PATH))

pool = ccnet.ClientPool(CCNET_CONF_PATH)
ccnet_rpc = ccnet.CcnetRpcClient(pool, req_pool=True)
ccnet_threaded_rpc = ccnet.CcnetThreadedRpcClient(pool, req_pool=True)
monitor_rpc = seafile.MonitorRpcClient(pool)
seafserv_rpc = seafile.ServerRpcClient(pool, req_pool=True)
seafserv_threaded_rpc = seafile.ServerThreadedRpcClient(pool, req_pool=True)

# load ccnet server addr and port from ccnet.conf.
# 'addr:port' is used when downloading a repo
config = ConfigParser.ConfigParser()
config.read(os.path.join(CCNET_CONF_PATH, 'ccnet.conf'))

if config.has_option('General', 'SERVICE_URL') and \
   config.has_option('Network', 'PORT'):
    service_url = config.get('General', 'SERVICE_URL')
    hostname = urlparse(service_url).hostname

    SERVICE_URL = service_url
    CCNET_SERVER_ADDR = hostname
    CCNET_SERVER_PORT = config.get('Network', 'PORT')
else: