forked from atlassian-api/atlassian-python-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfluence_check_unknown_attachment_error.py
47 lines (36 loc) · 1.26 KB
/
confluence_check_unknown_attachment_error.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# coding=utf-8
from atlassian import Confluence
"""This example how to detect unknown-attachments errors"""
confluence = Confluence(url="http://localhost:8090", username="admin", password="admin", timeout=185)
def get_all_pages_ids(space_key):
page_ids = []
limit = 50
flag = True
step = 0
while flag:
values = confluence.get_all_pages_from_space(space=space_key, start=step * limit, limit=limit)
step += 1
if len(values) == 0:
flag = False
print("Extracted all pages excluding restricts")
else:
for value in values:
page_ids.append(value.get("id"))
return page_ids
def check_unknown_attachment_in_space(space_key):
"""
Detect errors in space
:param space_key:
:return:
"""
page_ids = get_all_pages_ids(space_key)
print("Start review pages {} in {}".format(len(page_ids), space_key))
for page_id in page_ids:
link = confluence.has_unknown_attachment_error(page_id)
if len(link) > 0:
print(link)
if __name__ == "__main__":
space_list = confluence.get_all_spaces()
for space in space_list:
print("Start review {} space".format(space["key"]))
check_unknown_attachment_in_space(space["key"])