def setup(self, url, token, parent_project = None): timer = Timer() timer.start("Setup") self.parent_project = parent_project rest = RestRequests(url) self.auth = Auth(rest) if not self.auth.authorize(token): # Try one more time, since often the error is a session expired error and # seems to work fine on the second try. print("Encountered error, retrying authorization") if not self.auth.authorize(token): timer.stop() return False self.rest = AuthorizingRestProxy(rest, self.auth.get_token()) self.projects = Projects(self.rest) self.batches = Batches(self.rest) self.groups = Groups(self.rest) self.permissions = Permissions(self.rest) # Also sets up a project to work in. self.project = self.projects.new_project(parent_project, None, "Test project created at " + str(datetime.datetime.now())) print("Set up project with uuid " + self.project.get_uuid()) timer.stop() return True
def setup(self): timer = Timer() timer.start("Setup") rest = RetryingRestProxy(RestRequests(self.config.get_url())) auth = Auth(rest) if not auth.authenticate(self.config.get_token()): print("Could not authenticate.") return False self.rest = AuthenticatingRestProxy(rest, self.config.get_token()) self.projects = Projects(self.rest) self.batches = Batches(self.rest) self.groups = Groups(self.rest) self.permissions = Permissions(self.rest) timer.stop() return True
def setup(self): timer = Timer() timer.start("Setup") rest = RetryingRestProxy(RestRequests(self.url)) auth = Auth(rest) if not auth.authenticate(self.token): print("Could not authenticate.") return False self.rest = AuthenticatingRestProxy(rest, self.token) self.projects = Projects(self.rest) self.batches = Batches(self.rest) self.groups = Groups(self.rest) self.permissions = Permissions(self.rest) self.processing_service = AdamProcessingService(self.rest) timer.stop() return True
def setup(self): """Sets up the API client and modules for issuing requests to the ADAM API.""" timer = Timer() timer.start("Setup") retrying_rest = RetryingRestProxy(RestRequests()) self.rest = AuthenticatingRestProxy(retrying_rest) auth = Auth(self.rest) if not auth.authenticate(): print("Could not authenticate.") return False self.projects = ProjectsClient(self.rest) self.batches = Batches(self.rest) self.groups = Groups(self.rest) self.permissions = Permissions(self.rest) self.processing_service = AdamProcessingService(self.rest) timer.stop() return True