def get_lp_server( user_id, codehosting_endpoint_url=None, branch_url=None, seen_new_branch_hook=None, branch_transport=None ): """Create a Launchpad server. :param user_id: A unique database ID of the user whose branches are being served. :param codehosting_endpoint_url: URL for the branch file system end-point. :param hosted_directory: Where the branches are uploaded to. :param mirror_directory: Where all Launchpad branches are mirrored. :param seen_new_branch_hook: :return: A `LaunchpadServer`. """ # Get the defaults from the config. if codehosting_endpoint_url is None: codehosting_endpoint_url = config.codehosting.codehosting_endpoint if branch_url is None: if branch_transport is None: branch_url = config.codehosting.mirrored_branches_root branch_transport = get_chrooted_transport(branch_url) else: if branch_transport is None: branch_transport = get_chrooted_transport(branch_url) else: raise AssertionError("can't supply both branch_url and branch_transport!") codehosting_client = xmlrpclib.ServerProxy(codehosting_endpoint_url) lp_server = LaunchpadServer( DeferredBlockingProxy(codehosting_client), user_id, branch_transport, seen_new_branch_hook ) return lp_server
def get_lp_server(user_id, codehosting_endpoint_url=None, branch_url=None, seen_new_branch_hook=None, branch_transport=None): """Create a Launchpad server. :param user_id: A unique database ID of the user whose branches are being served. :param codehosting_endpoint_url: URL for the branch file system end-point. :param hosted_directory: Where the branches are uploaded to. :param mirror_directory: Where all Launchpad branches are mirrored. :param seen_new_branch_hook: :return: A `LaunchpadServer`. """ # Get the defaults from the config. if codehosting_endpoint_url is None: codehosting_endpoint_url = config.codehosting.codehosting_endpoint if branch_url is None: if branch_transport is None: branch_url = config.codehosting.mirrored_branches_root branch_transport = get_chrooted_transport(branch_url) else: if branch_transport is None: branch_transport = get_chrooted_transport(branch_url) else: raise AssertionError( "can't supply both branch_url and branch_transport!") codehosting_client = xmlrpclib.ServerProxy(codehosting_endpoint_url) lp_server = LaunchpadServer(DeferredBlockingProxy(codehosting_client), user_id, branch_transport, seen_new_branch_hook) return lp_server
def get_rw_server(direct_database=False): """Get a server that can write to the Launchpad branch vfs. You can only call this usefully on the codehost -- the transport this server provides are backed onto file:/// URLs. :param direct_database: if True, use a server implementation that talks directly to the database. If False, the default, use a server implementation that talks to the internal XML-RPC server. """ transport = get_chrooted_transport(config.codehosting.mirrored_branches_root, mkdir=True) if direct_database: return DirectDatabaseLaunchpadServer("lp-internal:///", transport) else: proxy = xmlrpclib.ServerProxy(config.codehosting.codehosting_endpoint) codehosting_endpoint = DeferredBlockingProxy(proxy) return LaunchpadInternalServer("lp-internal:///", codehosting_endpoint, transport)
def get_rw_server(direct_database=False): """Get a server that can write to the Launchpad branch vfs. You can only call this usefully on the codehost -- the transport this server provides are backed onto file:/// URLs. :param direct_database: if True, use a server implementation that talks directly to the database. If False, the default, use a server implementation that talks to the internal XML-RPC server. """ transport = get_chrooted_transport( config.codehosting.mirrored_branches_root, mkdir=True) if direct_database: return DirectDatabaseLaunchpadServer('lp-internal:///', transport) else: proxy = xmlrpclib.ServerProxy(config.codehosting.codehosting_endpoint) codehosting_endpoint = DeferredBlockingProxy(proxy) return LaunchpadInternalServer('lp-internal:///', codehosting_endpoint, transport)