fetch_tasks.py 1.0 KB

1234567891011121314151617181920212223
  1. import requests
  2. import urllib3
  3. urllib3.disable_warnings()
  4. auth = requests.post(
  5. 'https://192.168.130.161/taiga/api/v1/auth',
  6. json={'type': 'normal', 'username': 'FrancoisLange', 'password': 'BTSai123'},
  7. verify=False
  8. ).json()
  9. headers = {'Authorization': f'Bearer {auth["auth_token"]}'}
  10. for pid in [18, 21]:
  11. try:
  12. tasks = requests.get(f'https://192.168.130.161/taiga/api/v1/tasks?project={pid}', headers=headers, verify=False).json()
  13. if isinstance(tasks, list):
  14. for t in tasks:
  15. if str(t.get('ref')) in ['15', '16', '17', '18', '20', '21', '22']:
  16. status_id = t.get('status')
  17. status_info = requests.get(f'https://192.168.130.161/taiga/api/v1/task-statuses/{status_id}', headers=headers, verify=False).json() if status_id else {}
  18. print(f'Ref: TG-{t.get("ref")}, Status: {status_info.get("name", "Unknown")}, Subject: {t.get("subject")}')
  19. except Exception as e:
  20. print(f"Error fetching project {pid}: {e}")