def _new_resource(self, *path): """ Return a new resource for accessing a couch database. :return: A resource for accessing a couch database. :rtype: couchdb.http.Resource """ # Workaround for: https://leap.se/code/issues/5448 url = couch_urljoin(self._database.resource.url, *path) resource = Resource(url, Session(timeout=COUCH_TIMEOUT)) resource.credentials = self._database.resource.credentials resource.headers = self._database.resource.headers.copy() return resource
def _get_server(url): resource = Resource(url.geturl(), Session(retry_delays=[1, 2, 4, 8], timeout=10)) return Server(url=resource)
max_threads = 20 semaphore_pool = threading.BoundedSemaphore(value=max_threads) threads = [] # get couch url cp = ConfigParser() cp.read('/etc/leap/soledad-server.conf') url = urlparse(cp.get('soledad-server', 'couch_url')) # get admin password netloc = re.sub('^.*@', '', url.netloc) url = url._replace(netloc=netloc) password = getpass("Admin password for %s: " % url.geturl()) url = url._replace(netloc='admin:%s@%s' % (password, netloc)) resource = Resource(url.geturl(), Session(retry_delays=[1,2,4,8], timeout=10)) server = Server(url=resource) hidden_url = re.sub( 'http://(.*):.*@', 'http://\\1:xxxxx@', url.geturl()) print """ ========== ATTENTION! ========== This script will modify Soledad's shared and user databases in: %s