conn = pymongo.MongoClient("192.168.3.237", 27017) db = conn.tcs col = db.id_pw pw_data = col.find({}) id_pw = {'os_username': pw_data[1]['id'], 'os_password': pw_data[1]['pw']} confluence = Confluence(url='https://wiki.telechips.com:8443', username=id_pw['os_username'], password=id_pw['os_password']) #레이블로 Wiki 페이지를 검색 cql = 'label="oss_result"' page_list = [] page_list1 = confluence.cql(cql, start=0, limit=1000, expand=None, include_archived_spaces=None, excerpt=None) page_list = page_list1['results'] #검색한 Wiki 페이지의 ID들을 저장할 변수 pageid = [] for i in range(0, len(page_list)): pageid.append(page_list[i]['content']['id']) #전체 테스트 결과를 저장할 변수 test_result = [] for i in range(0, len(pageid)): page_info_body1 = confluence.get_page_by_id(pageid[i],
page_limit = 500 #Establish confluence connection session confluence = Confluence( url='https://hub.internal.couchbase.com/confluence', username=params.userid, password=params.password) #filter out pages are not necessary to be backed up #7242630 is the page ID of "archived". #"Production Build Status" does not return, results in socket timeout cql = 'space.key=' + '"' + spacekey + '"' + ' and type="page" \ and title !~ "Build Team Status" and title !~ "buildbot" \ and title !~ "Production Build Status" and ancestor != 7242630' response = confluence.cql(cql, limit=page_limit, expand='ancestors') if response.get('totalSize') > page_limit: #If total page number is higher than the set limit, #rerun the cql with higher limit response = confluence.cql(cql, limit=response.get('totalSize'), expand='ancestors') for page in response.get('results'): print("Getting content of ", page['title'].replace('/', '')) response = confluence.get_page_as_pdf(page['content']['id']) #Remove "/" if it exist in page title before saving the file #else it will cause issue during page creation save_file(content=response, title=page['title'].replace('/', ''))