Exemple #1
0
 def get_by_name(self, name):
     access_token = AuthConfigManager.get_access_token()
     try:
         response = self.request(
             'GET', '%s/%s/%s' % (self.url, access_token.username, name))
         return Project.from_dict(response.json())
     except NotFoundException:
         return None
Exemple #2
0
 def get_by_name(self, name, namespace=None):
     """
     name: can be either <namespace>/<project_name> or just <project_name>
     namespace: if specified, will skip name parsing, defaults to current user's username
     """
     if not namespace:
         namespace, name = get_namespace_from_name(name)
     if not namespace:
         namespace = AuthConfigManager.get_access_token().username
     try:
         response = self.request('GET',
                                 '%s/%s/%s' % (self.url, namespace, name))
         return Project.from_dict(response.json())
     except NotFoundException:
         return None
Exemple #3
0
 def get_projects(self):
     try:
         response = self.request("GET", self.url)
         projects_dict = response.json()
         return [
             Project.from_dict(project)
             for project in projects_dict.get("projects", [])
         ]
     except FloydException as e:
         floyd_logger.info("Error while retrieving projects: {}".format(
             e.message))
         if isinstance(e, AuthenticationException):
             # exit now since there is nothing we can do without login
             sys.exit(1)
         return []