|
@@ -72,10 +72,8 @@ def start_jupyter(db: Session, item: schemas.ProgrammeId):
|
|
|
if not j_data:
|
|
|
# send_util.stop_jupyter({'namespace': namespace,'release_name': db_item.release_name})
|
|
|
raise Exception("启动结构化编码失败")
|
|
|
- get_programme_status(namespace,db_item.release_name)
|
|
|
url = f"http://{j_data['host']}{j_data['base_url']}/lab"
|
|
|
- time.sleep(10)
|
|
|
- db_item.status = 1
|
|
|
+ db_item.status = 0
|
|
|
db.commit()
|
|
|
db.flush()
|
|
|
db.refresh(db_item)
|
|
@@ -111,19 +109,21 @@ def get_programme(db: Session):
|
|
|
db_items: List[models.Programme] = db.query(models.Programme).filter(models.Programme.project_id == g.project_id).all()
|
|
|
res = []
|
|
|
for item in db_items:
|
|
|
+ complete_url =f'http://{host}{item.base_url}/lab'
|
|
|
+ jupyter_status = get_programme_status(complete_url)
|
|
|
+ item.status = jupyter_status
|
|
|
+ db.commit()
|
|
|
+ db.flush()
|
|
|
+ db.refresh(item)
|
|
|
i_dict = item.to_dict()
|
|
|
- i_dict.update({"complete_url": f"http://{host}{i_dict['base_url']}/lab"})
|
|
|
- # send_util.get_jupyter_html(i_dict['complete_url'])
|
|
|
+ i_dict.update({'complete_url': complete_url})
|
|
|
res.append(i_dict)
|
|
|
return res
|
|
|
|
|
|
|
|
|
-def get_programme_status(namespace: str, release_name: str):
|
|
|
- for i in range(0,11):
|
|
|
- res = send_util.get_jupyter_status({"namespace":namespace, "filter":release_name})
|
|
|
- d_list = res['data']
|
|
|
- if len(d_list) > 0:
|
|
|
- return True
|
|
|
- if i >= 10:
|
|
|
- raise Exception(f"jupyter启动失败")
|
|
|
- time.sleep(2)
|
|
|
+def get_programme_status(url: str):
|
|
|
+ res_header= send_util.get_jupyter_html(url)
|
|
|
+ # 若为启动状态,则Server中包含Tornado,否则没有启动
|
|
|
+ print(res_header)
|
|
|
+ jupyter_status = 0 if res_header['Server'].find('Tornado') < 0 else 1
|
|
|
+ return jupyter_status
|