/
ilya.petrash
/
SimplePyScripts
Обзор
Документация
Войти
/
ilya.petrash
/
SimplePyScripts
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
job_compassplus/mysite_compassplus_com/common.py
63 строки
2 KB
gil9red
Updated. job_compassplus/mysite_compassplus_com/
23 июн 2025, 16:14
23 июн 2025, 16:14
e32fa1e
Код
Авторство
О чём код?
#!/usr/bin/env python3 # -*- coding: utf-8 -*- __author__ = "ipetrash" import sys from pathlib import Path from typing import Any from bs4 import Tag DIR = Path(__file__).resolve().parent ROOT_DIR = DIR.parent sys.path.append(str(ROOT_DIR)) from site_common import do_get, do_post from root_config import JIRA_HOST URL_BASE = "https://mysite.compassplus.com" URL = f"{URL_BASE}/Person.aspx?accountname={{}}" def get_profile_organization(full_username: str) -> dict[str, Any]: url = f"{URL_BASE}/_vti_bin/SilverlightProfileService.json/GetUserSLProfileData" rs = do_post(url, json={"AccountNames": [full_username]}) return rs.json() def is_active_profile(full_username: str) -> bool: organization = get_profile_organization(full_username) data = organization["d"][0] # Если хотя бы один из них имеет значение, отличное от [] или None return bool(data["Parent"] or data["Siblings"] or data["Children"]) def get_jira_user_active(username: str) -> bool: url = f"{JIRA_HOST}/rest/api/latest/user?username={username}" return do_get(url).json()["active"] def get_text(el: Tag) -> str: return el.get_text(strip=True) if __name__ == "__main__": full_username = r"CP\ipetrash" rs = do_get(URL.format(full_username)) print(rs) organization = get_profile_organization(full_username) print(organization) data = organization["d"][0] print("Parent:", data["Parent"]) print("Siblings:", data["Siblings"]) print("Children:", data["Children"]) print() print("Is active (mysite):", is_active_profile(full_username)) print("Is active (jira):", get_jira_user_active(full_username.rsplit("\\")[-1]))