

def get_running_apps(self):
    try:
        proxy_loc = ((MainSettings.KUBE_PROXY_HOST + ':') + MainSettings.KUBE_PROXY_PORT)
        url = urljoin(proxy_loc, '/api/v1/pods')
        r = requests.get(url)
        if (r.status_code != 200):
            error_log(self.TAG, 'could not get list of running pods')
            return None
        json = r.json()
        if ('items' not in json):
            error_log(self.TAG, 'pods api endpoint returning malformed JSON')
            return None
        pod_specs = json['items']
        pods = []
        for pod_spec in pod_specs:
            meta = pod_spec['metadata']
            if ((meta['namespace'] == 'kube-system') or (meta['namespace'] == 'default')):
                continue
            if (meta['name'] == 'notebook-server'):
                full_image = pod_spec['spec']['containers'][0]['image']
                image_name = full_image.split('/')[(- 1)]
                pods.append((meta['namespace'], image_name))
        return pods
    except ConnectionError as e:
        error_log(self.TAG, e)
        return None

dataset/ETHPy150Open binder-project/binder/binder/cluster.py KubernetesManager.get_running_apps/original