def update_page(cell, content): """ update method """ cipher = Security('ec2cli') server, user, passwd, parent_id, page_id, title, response, region, product = config( cell) confluence = Confluence(url=server, username=user, password=cipher.decrypt(passwd)) confluence.update_page(parent_id=parent_id, page_id=page_id, title=title, body=content) return response
output_project="" body+='<tr>' body+='<td>' + output_name + '</td>' body+='<td>' + output_address_space + '</td>' body+='<td>' + output_subnets + '</td>' body+='<td>' + output_peerings + '</td>' body+='<td>' + output_resource_group + '</td>' body+='<td>' + output_location.capitalize() + '</td>' body+='</tr>' body+='</tbody></table>' body+='<p></p>' if vnet_count == 0: print("No Vnets in subscription:" + subscription_name) else: post_body+=body post_body+='<p>Azure Automated Inventory - Virtual Networks </p>' post_body+='<p>Last discovery execution date :' + str(today) + '</p>' #print (body) #status = confluence.create_page(space='DCS',parent_id=1463911167,title="Azure Virtual Machines",body=body) status = confluence.update_page(page_id=1465024702,title="Azure Virtual Networks",body=post_body) print(status)
for i in range(0, len(project_issue_data)): row = '<tr><td class="confluenceTd">' + str( project_issue_data[i][0]) + '</td><td class="confluenceTd">' + str( project_issue_data[i][1]) + '</td><td class="confluenceTd">' + str( project_issue_data[i] [2]) + '</td><td class="confluenceTd">' + str( project_issue_data[i] [3]) + '</td><td class="confluenceTd">' + str( project_issue_data[i][4]) + '</td></tr>' wiki_data_middle += row wiki = wiki_data_top + wiki_data_middle + wiki_data_bottom wiki = wiki.replace("&", "<p>&</p>") #특수문자 & 치환 confluence = Confluence(url='https://wiki.telechips.com:8443', username=user_info[0][0], password=user_info[0][1]) ''' con = sqlite3.connect('C:/Users/B180093/database/tcs.db') data.to_sql('RND_worklog_' + str(month_1) + '_draft_ttt', con, if_exists='replace', index = False) con.close() ''' confluence.update_page(parent_id=95455710, page_id=175327739, title='Project issue status', body=wiki, type='page', representation='storage')
if elem.tag == "logentry": revision = elem.attrib['revision'] myDict['revision'] = revision elif elem.tag == "date": date = elem.text datetime_object = datetime.strptime(date, "%Y-%m-%dT%H:%M:%S.%fZ") myDict['date'] = str(datetime_object) elif elem.tag == "msg": msg = elem.text myDict['msg'] = msg if len(myDict.values()) == 3: mylist = list(myDict.values()) final.append(mylist) myDict = dict() add = tabulate(final, tablefmt='html') print("Trying to update page...") status = confluence.update_page( parent_id=66945868, page_id=pageid, title=env, body=add, ) if status: print("Completed") else: print("Error")
# coding=utf-8 from atlassian import Confluence confluence = Confluence(url="http://localhost:8090", username="******", password="******") status = confluence.update_page( parent_id=None, page_id=123456, title="This is the new title", body="This is the new body", ) print(status)
#Wiki 페이지에 Data 생성 wiki_data_top = '<ac:structured-macro ac:name="table-excerpt" ac:schema-version="1" ac:macro-id="161913ea-7275-49ec-89af-a4e8e775825c">\ <ac:parameter ac:name="name">SIT_test_backdata2</ac:parameter><ac:rich-text-body>\ <p><br /></p><table><colgroup><col /><col /><col /><col /><col /><col /><col /><col /><col /><col /><col /><col /><col /></colgroup>\ <tbody><tr><th>test_date</th><th>SDK_Name</th><th>Subtitle</th><th>Version</th><th>Test_Type</th>\ <th>Pass</th><th>Fail</th><th>N/A</th><th>N/T</th><th>Total</th><th>Req_Cnt</th><th>Req_Coverage(%)</th></tr>' wiki_data_middle = '' wiki_data_bottom = '</tbody></table><p class="auto-cursor-target"><br /></p></ac:rich-text-body></ac:structured-macro><p class="auto-cursor-target"><br /></p>' for i in range(0, len(test_result_list)): data_row = '<tr>' for j in range(0, len(test_result_list[i]) - 1): if j == 0: data_row += '<td><a href="' + test_result_list[i][ 12] + '">' + test_result_list[i][j] + '</a></td>' else: data_row += '<td>' + test_result_list[i][j] + '</td>' data_row += '</tr>' wiki_data_middle += data_row confluence.update_page(parent_id=95455710, page_id=99891658, title='SIT_test_backdata2', body=wiki_data_top + wiki_data_middle + wiki_data_bottom, type='page', representation='storage')
resp = requests.get(art_url + '/api/repositories/' + vname, verify=False) # TODO ssl verify resp.raise_for_status() remotes = list() for irep in resp.json()['repositories']: if irep in remote_repos.keys(): remotes.append(remote_repos[irep]['url']) del remote_repos[irep] all_repos.setdefault(vrep['packageType'], {})[vrep['url']] = remotes # get all remained remote repos for _, rrep in remote_repos.items(): all_repos.setdefault(rrep['packageType'], {})[art_url + '/' + rrep['key']] = [rrep['url']] # generate page from template if template_file in [None, '']: template_file = 'page_template.html' BASE_DIR = os.path.dirname(os.path.abspath(__file__)) else: BASE_DIR = os.path.dirname(os.path.abspath(template_file)) jinja2_env = Environment(loader=FileSystemLoader(BASE_DIR), trim_blocks=True) new_content = jinja2_env.get_template( os.path.basename(template_file)).render(all_repos=all_repos) # post page on Confluence confluence.update_page(confluence_page_id, confluence_page['title'], new_content) logging.info('Finished')
# coding: utf8 from atlassian import Confluence confluence = Confluence( url='http://localhost:8090', username='******', password='******') status = confluence.update_page( parent_id=None, page_id=123456, title='This is the new title', body='This is the new body') print(status)
print("Getting page by ID: " + str(pageID)) contents = confluence.get_page_by_id(pageID, expand="body.storage,version", status="current") print("ID : " + str(contents["id"])) print("Status : " + contents["status"]) print("Title : " + contents["title"]) print("Version : " + str(contents["version"]["number"])) print("Last Updated : " + str(contents["version"]["when"])) print("Body : " + contents["body"]["storage"]["value"]) #print("Full Contents:") #print(contents) print( "########################################################################") print("Update page: " + str(pageID)) newBody = "<p>Hello World " + str(random.randint(0, 100)) + "</p>" try: status = confluence.update_page(pageID, confluencePage, newBody, parent_id=None, type='page', representation='storage', minor_edit=False) #print (status) except Exception as e: print("Uh oh, can't update pageID " + str(pageID)) print("Makesure page exists") traceback.print_exc()
class ConfluencePublisher(): def __init__( self, url, username, apiToken, pageTitlePrefix, markdownDir, dbPath, space, parentPageId, forceUpdate=False, forceDelete=False, skipUpdate=False, ): self.api = Confluence(url=url, username=username, password=apiToken) self.pageTitlePrefix = pageTitlePrefix self.markdownDir = markdownDir self.kv = KeyValue(dbPath) self.space = space self.parentPageId = parentPageId self.forceUpdate = forceUpdate self.forceDelete = forceDelete self.skipUpdate = skipUpdate self.confluenceRenderer = ConfluenceRenderer(url) self.metadataPlugin = MetadataPlugin() self.renderer = mistune.create_markdown( renderer=self.confluenceRenderer, plugins=[ 'strikethrough', 'footnotes', 'table', 'url', self.metadataPlugin.plugin_metadata ]) # Hack to allow metadata plugin to work (See mistune/block_parser.py) self.renderer.block.rules.remove('thematic_break') def __getFileContent(self, filepath): file = open(filepath, mode='r') content = file.read() file.close() return content def __updatePage(self, space, parentId, filepath, autoindex=False): if autoindex: markdown = '' else: markdown = self.__getFileContent(filepath) metadata = self.kv.load(filepath) currentTitle = metadata['title'] currentHash = metadata['sha256'] hash = self.kv.sha256(markdown) # --- Render (BEGIN) self.metadataPlugin.stack['title'] = None if autoindex: body = self.confluenceRenderer.generate_autoindex() else: body = self.renderer(markdown) if self.metadataPlugin.stack['title'] is None: if autoindex: title = 'Folder ' + os.path.basename(os.path.dirname(filepath)) else: title = os.path.basename(filepath) else: title = self.metadataPlugin.stack['title'] title = self.pageTitlePrefix + title # >>> Removed: + " [" + self.kv.sha256(filepath)[-6:] + "]" # --- Render (END) if currentTitle and currentTitle != title: print('REN => Title: ' + title) pageId = self.api.get_page_id(space, currentTitle) self.api.update_page(pageId, title, body) if currentHash != hash or self.forceUpdate: if autoindex: print('IDX => Title: ' + title) else: print('UPD => Title: ' + title) if self.api.update_or_create(parent_id=parentId, title=title, body=body, representation='storage'): id = self.api.get_page_id(space, title) self.kv.save(filepath, { 'id': id, 'title': title, 'sha256': hash }) return id else: return None else: print('SKP => Title: ' + title) return self.api.get_page_id(space, title) def __deleteAttachment(self, filepath): metadata = self.kv.load(filepath) filename = os.path.basename(filepath) if metadata['id']: try: print('DEL Att. => Title: ' + filename) # https://confluence.atlassian.com/confkb/confluence-rest-api-lacks-delete-method-for-attachments-715361922.html # self.api.delete_attachment_by_id(metadata['id'], 1) self.api.remove_content(metadata['id']) except (HTTPError, ApiError): pass def __updateAttachment(self, space, pageId, filepath): filename = os.path.basename(filepath) print('UPD Att. => Title: ' + filename) results = self.api.attach_file(filepath, name=filename, page_id=pageId, space=space) id = results['id'] if 'id' in results else results['results'][0]['id'] self.kv.save(filepath, {'id': id, 'title': filename, 'sha256': None}) return id def __publishRecursive(self, space, parentId, path): # File: _index.md indexParentId = parentId indexPath = path + os.sep + '_index.md' if os.path.isfile(indexPath): # Use local _index.md file indexParentId = self.__updatePage(space, parentId, indexPath) else: # Autoindex simulate _index.md in Confluence if missing locally # Except for (root) parentPageId because missing in markdownDir! if parentId != self.parentPageId: indexParentId = self.__updatePage(space, parentId, indexPath, True) # Directories: */ for f in os.scandir(path): if f.is_dir(): self.__publishRecursive(space, indexParentId, f.path) # Files: *.* (Except _index.md) for f in os.scandir(path): if f.is_file(): if f.path.endswith(".md"): if not f.path.endswith(os.sep + '_index.md'): self.__updatePage(space, indexParentId, f.path) else: self.__deleteAttachment(f.path) self.__updateAttachment(space, indexParentId, f.path) def delete(self): for filepath in sorted(self.kv.keys()): metadata = self.kv.load(filepath) # Page has Sub-pages (Childs)? indexWithChilds = False if filepath.endswith('_index.md'): childs = 0 if os.path.isdir(os.path.dirname(filepath)): for f in os.scandir(os.path.dirname(filepath)): if f.path.endswith(".md") and \ not f.path.endswith('_index.md'): childs = childs + 1 indexWithChilds = childs > 0 if self.forceDelete \ or (not os.path.isfile(filepath) and not indexWithChilds): print('DEL => Id: ' + metadata['id'] + ', Title: ' + metadata['title']) if filepath.endswith(".md"): try: if self.api.get_page_by_id(metadata['id']): self.api.remove_page(metadata['id']) except HTTPError as ex: code = ex.response.status_code if code != 404: print("DEL Pag. (Error):" + str(code)) else: pass else: self.__deleteAttachment(filepath) self.kv.remove(filepath) def publish(self): self.__publishRecursive(self.space, self.parentPageId, self.markdownDir)
# body+='<tr>' # body+='<td>' + subscription_name + '</td>' # body+='<td>'+ resource.name +'</td>' # body+='<td>' + resource.type +'</td>' # body+='<td>' + resource.location +'</td>' # body+='</tr>' # if resource.type=='Microsoft.Compute/disks': # print(subscription_name + '|' + resource.name + '|' + resource.type + '|' + resource.location + '|' ) # body+='<tr>' # body+='<td>' + subscription_name + '</td>' # body+='<td>'+ resource.name +'</td>' # body+='<td>' + resource.type +'</td>' # body+='<td>' + resource.location +'</td>' # body+='</tr>' # if resource.type=='Microsoft.Web/sites': # print(subscription_name + '|' + resource.name + '|' + resource.type + '|' + resource.location + '|' ) # body+='<tr>' # body+='<td>' + subscription_name + '</td>' # body+='<td>'+ resource.name +'</td>' # body+='<td>' + resource.type +'</td>' # body+='<td>' + resource.location +'</td>' # body+='</tr>' #status = confluence.create_page(space='DCS',parent_id=1463911167,title="Azure Virtual Machines",body=body) status = confluence.update_page(page_id=1464009749, title="Azure Virtual Machines", body=post_body) print(status)
class Readme2Confluence: """ Main class that will create the Confluence page from Markdown """ def __init__(self, url, username, password, space): self.confluence = Confluence(url, username=username, password=password) spaces = self.confluence.get_all_spaces(start=0, limit=500) if any(s for s in spaces if s["name"] == space): self.space = space else: raise ValueError("{} is not valid Confluence Space".format(space)) def get_page_id(self, title): """ Retrieve the ID of a page using it's title This is basically a small wrapper around confluence.get_page_id(). The main reason for the wrapper is to better handle pages that aren't found by raising an exception """ page_id = self.confluence.get_page_id(self.space, title) if page_id is None: raise ValueError("{} is not a valid page title in {}".format( title, self.space)) return page_id def get_page_html(self, title): """ Retrieve a confluence page and return it as a HTML (string) """ page_id = self.get_page_id(title) return self.confluence.get_page_by_id(page_id) def send2confluence(self, title, parent_title=None, md_file=None, md_text=""): """ Method that creates the confluence page. Page will either be created or updated depending on what is required. """ if md_file is None: body = md2html(md_text) else: body = md2html(get_md_text(md_file)) parent_id = None if parent_title is None else self.get_page_id( parent_title) page_id = self.confluence.get_page_id(self.space, title) if page_id is None: ret = self.confluence.create_page(self.space, title, body, parent_id=parent_id, type='page', representation='storage') else: ret = self.confluence.update_page(page_id, title, body, parent_id=parent_id, type='page', representation='storage') return ret
class ConfluencePage: dre = re.compile(r'(\d+)') def __init__(self, config_file, timestamp): self.timestamp = timestamp self.page = None config = configparser.ConfigParser() config.read(config_file) if "confluence" not in config.sections(): print("No section 'confluence' found") exit(1) self.url = config.get("confluence", "url") self.username = config.get("confluence", "username") self.password = config.get("confluence", "password") self.page_id = config.get("confluence", "pageId") self.templateFile = config.get("confluence", "templateFile") title = config.get("confluence", "title") space = config.get("confluence", "space") if self.url is None or self.username is None or self.password is None: print("Config file missing configurations") exit(1) if self.page_id is None and (title is None or space is None): print("pageId or title and space missing") exit(1) self.confluence = Confluence(url=self.url, username=self.username, password=self.password) if self.page_id is None: if not self.confluence.page_exists(space, title): print(("Page Space: '%s' Title: '%s' does not exist" % (space, title))) exit(1) self.page_id = self.confluence.get_page_id(space, title) def generate_page(self, library, projects): # Generate page - latest version on develop project_versions_body = self.confluence_generate_last_versions( projects, library) # Generate page - which project depends on each library version lib_versions_body = self.confluence_generate_library_versions(library) template = open(self.templateFile, "r").read() self.page = template.format(timestamp=self.timestamp, lib_versions_body=lib_versions_body, app_versions_body=project_versions_body) def confluence_generate_last_versions(self, projects, library): app_versions_body = "" for project in projects: project_versions_sorted = sorted( project.versions, key=lambda version: [ int(s) if s.isdigit() else s.lower() for s in re.split(self.dre, version.name) ], reverse=True) if len(project_versions_sorted) <= 0: project_version = "Unknown" library_version = "Not using %s" % library.name else: latest_version = project_versions_sorted[0] project_version = latest_version.name library_version = latest_version.library_version if latest_version.library_version is not None else "Not using %s" % library.name app_versions_body += "<tr><td>{project_name}</td><td style=\"text-align: center;\"><strong>{project_version}</strong></td><td style=\"text-align: center;\"><strong>{library_version}</strong></td></tr>" \ .format(project_name=project.name, project_version=project_version, library_version=library_version) return app_versions_body def confluence_generate_library_versions(self, library): sorted_versions = sorted(library.versions, key=lambda version: [ int(s) if s.isdigit() else s.lower() for s in re.split(self.dre, version.name) ], reverse=True) # TODO add links to release notes versions_body = "" for version in sorted_versions: if len(version.dependency_in) == 0: versions_body += "<tr><th><strong>{lib_name}</strong></th><td><strong>Not in use</strong></td><td></td></tr>\n" \ .format(lib_name=version.name) else: versions_body += "<tr><th rowspan=\"{num_of_dep}\"><strong>{lib_name}</strong></th><td>{dep_name}</td><td colspan=\"1\" style=\"text-align: center;\">{dep_rev}</td></tr>\n" \ .format(lib_name=version.name, num_of_dep=len(version.dependency_in), dep_name=version.dependency_in[0][0], dep_rev=version.dependency_in[0][1].name) for dep in version.dependency_in[1:]: versions_body += "<tr><td>{dep_name}</td><td colspan=\"1\" style=\"text-align: center;\">{dep_rev}</td></tr>" \ .format(dep_name=dep[0], dep_rev=dep[1].name) return versions_body def publish_page(self): if self.page is not None: print((self.confluence.update_page(self.page_id, "Test", self.page, type='page', representation='storage')))
class ConfluencePublisher(): def __init__( self, url, username, api_token, page_title_prefix, markdown_dir, db_path, space, parent_pageid, force_update=False, force_delete=False, skip_update=False, verbose=False): self.api = Confluence(url=url, username=username, password=api_token) self.page_title_prefix = page_title_prefix self.markdown_dir = markdown_dir self.kv = KeyValue(db_path) self.space = space self.parent_pageid = parent_pageid self.force_update = force_update self.force_delete = force_delete self.skip_update = skip_update self.confluence_renderer = ConfluenceRenderer(verbose) self.renderer = mistune.create_markdown( renderer=self.confluence_renderer, plugins=[ plugin_front_matter, DirectiveInclude(), HugoRefLinkPlugin(self.markdown_dir), 'strikethrough', 'footnotes', 'table', 'url', Admonition(), plugin_html_comment, ] ) def __update_page(self, space, parentid, filepath, autoindex=False): metadata = self.kv.load(filepath) current_title = metadata['title'] current_hash = metadata['sha256'] sha_hash = get_file_sha256(filepath) # --- Render (BEGIN) body = '' state = {'front_matter': {}} if autoindex: body = generate_autoindex() state['front_matter']['title'] = \ os.path.basename(os.path.dirname(filepath)).title() else: if filepath.endswith("_index.md"): body = generate_autoindex() body += self.renderer.read(filepath, state) title = '{}{}'.format(self.page_title_prefix, state['front_matter']['title']) # --- Render (END) if current_title and current_title != title: print('REN => Title: ' + title) confluence_page_id = self.api.get_page_id(space, current_title) self.api.update_page(confluence_page_id, title, body) if current_hash != sha_hash or self.force_update: if autoindex: print('IDX => Title: ' + title) else: print('UPD => Title: ' + title) if self.api.update_or_create( parent_id=parentid, title=title, body=body, representation='storage' ): confluence_page_id = self.api.get_page_id(space, title) self.kv.save(filepath, {'id': confluence_page_id, 'title': title, 'sha256': sha_hash}) return confluence_page_id return None else: print('SKP => Title: ' + title) return self.api.get_page_id(space, title) def __delete_attachment(self, filepath): metadata = self.kv.load(filepath) filename = os.path.basename(filepath) if metadata['id']: try: print('DEL Att. => Title: ' + filename) # https://confluence.atlassian.com/confkb/confluence-rest-api-lacks-delete-method-for-attachments-715361922.html # self.api.delete_attachment_by_id(metadata['id'], 1) self.api.remove_content(metadata['id']) except (HTTPError, ApiError): pass def __update_attachment(self, space, pageid, filepath): filename = os.path.basename(filepath) print('UPD Att. => Title: ' + filename) results = self.api.attach_file(filepath, name=filename, page_id=pageid, space=space) confluence_page_id = results['id'] if 'id' in results else results['results'][0]['id'] self.kv.save(filepath, {'id': confluence_page_id, 'title': filename, 'sha256': None}) return confluence_page_id def __publish_recursive(self, space, parentid, path, root=False): # File: _index.md index_parentid = parentid index_path = path + os.sep + '_index.md' if not root: if os.path.isfile(index_path): # Use local _index.md file index_parentid = self.__update_page( space, parentid, index_path) else: # Autoindex simulate _index.md in Confluence if missing locally index_parentid = self.__update_page( space, parentid, index_path, True) # Directories: */ for f in os.scandir(path): if f.is_dir(): self.__publish_recursive(space, index_parentid, f.path) # Files: *.* (Except _index.md) for f in os.scandir(path): if f.is_file(): if f.path.endswith(".md"): if not f.path.endswith(os.sep + '_index.md'): self.__update_page(space, index_parentid, f.path) else: self.__delete_attachment(f.path) self.__update_attachment(space, index_parentid, f.path) def delete(self): for filepath in sorted(self.kv.keys()): metadata = self.kv.load(filepath) # Page has Sub-pages (Childs)? index_with_childs = False if filepath.endswith('_index.md'): childs = 0 if os.path.isdir(os.path.dirname(filepath)): for f in os.scandir(os.path.dirname(filepath)): if f.path.endswith(".md") and \ not f.path.endswith('_index.md'): childs = childs + 1 index_with_childs = childs > 0 if self.force_delete \ or (not os.path.isfile(filepath) and not index_with_childs): print('DEL => Id: ' + metadata['id'] + ', Title: ' + metadata['title']) if filepath.endswith(".md"): try: if self.api.get_page_by_id(metadata['id']): self.api.remove_page(metadata['id']) except HTTPError as ex: code = ex.response.status_code if code != 404: print("DEL Pag. (Error):" + str(code)) else: pass else: self.__delete_attachment(filepath) self.kv.remove(filepath) def publish(self): self.__publish_recursive( self.space, self.parent_pageid, self.markdown_dir, root=True)
from pprint import pprint from atlassian import Confluence confluence = Confluence(url='http://localhost:8090', username='******', password='******') status = confluence.update_page(page_id=123456, title='This is the new title', body='This is the new body') pprint(status)
]) Wiki_body_top = '<ac:layout><ac:layout-section ac:type="two_equal"><ac:layout-cell><p class="auto-cursor-target"><br /></p><ac:structured-macro ac:name="table-excerpt" \ ac:schema-version="1" ac:macro-id="0cd61a8e-0ee3-41f5-b485-5e0fc926eece"><ac:parameter ac:name="name">' + SDK + '_unit</ac:parameter>\ <ac:rich-text-body><p class="auto-cursor-target"><br /></p><table><colgroup><col /><col /><col /><col /></colgroup><tbody><tr><th>Module_Name</th><th>Group</th><th>Fail</th><th>test_date</th></tr>' Wiki_body_bottom = '</tbody></table><p class="auto-cursor-target"><br /></p></ac:rich-text-body></ac:structured-macro><p class="auto-cursor-target"><br /></p>\ </ac:layout-cell><ac:layout-cell><p><ac:structured-macro ac:name="table-excerpt-include" ac:schema-version="1" ac:macro-id="76e65e76-4bc4-4e0d-8551-f26273acd239">\ <ac:parameter ac:name="name">' + SDK + '</ac:parameter><ac:parameter ac:name="page"><ac:link><ri:page ri:content-title="주요 SDK 모듈 구성 현황" />\ </ac:link></ac:parameter><ac:parameter ac:name="type">page</ac:parameter></ac:structured-macro></p></ac:layout-cell></ac:layout-section></ac:layout>' Wiki_body_middle = '' for i in range(0, len(test_result)): if test_result[Module_list[i][0]][0] == 'N/T': Wiki_body_middle += '<tr><td>' + Module_list[i][ 0] + '</td><td>' + Module_list[i][1] + '</td><td>' + test_result[ Module_list[i][0]][0] + '</td><td></td></tr>' else: Wiki_body_middle += '<tr><td>' + Module_list[i][0] + '</td><td>' + Module_list[i][1] + '</td><td>' + test_result[Module_list[i][0]][0] +\ '</td><td><a href="' + test_result[Module_list[i][0]][2] + '">' + test_result[Module_list[i][0]][1] + '</a></td></tr>' Wiki_body_top + Wiki_body_middle + Wiki_body_bottom confluence.update_page(parent_id=105541245, page_id=wiki_page, title=SDK, body=Wiki_body_top + Wiki_body_middle + Wiki_body_bottom, type='page', representation='storage')
# 将escdesk和cse列表合并成一个 def get_data(): l = [] for i in escdesk_data: cse = i['cse'] for j in cse_data: cse_nu = j['cse'] if cse_nu == cse: data = dict(i, **j) l.append(data) return l # title_fy20_data_source = "test" confluence.update_page( #page_id=get_pageid(title_month), page_id=904986625, title="2021-1-16", body=get_body(ecsdesk_issue_month, tag='month')) # title_all = "问题展示 - 问题解决时间统计(按月)" # ecsdesk_issue_all = search_all_issue(jc, "project = ECSDESK AND \ # issuetype in (Incident, problem, 'Service Request') AND \ # created >= 2020-03-01 AND resolutiondate >= 2020-03-01") # confluence.update_page( # page_id=get_pageid(title_all), # title=title_all.decode('utf-8'), # body=get_body(ecsdesk_issue_all, tag='all'))
logging.basicConfig(level=logging.DEBUG, format="[%(asctime).19s] [%(levelname)s] %(message)s") logging.getLogger("requests").setLevel(logging.WARNING) log = logging.getLogger("jira-projects-administrators") jira = Jira( url="http://localhost:8000/", username="******", password="******") html = "<table><tr><th>Project Key</th><th>Project Name</th><th>Leader</th><th>Email</th></tr>" for data in jira.project_leaders(): log.info("{project_key} leader is {lead_name} <{lead_email}>".format(**data)) html += "<tr><td>{project_key}</td><td>{project_name}<td></td>{lead_name}<td></td><a href='mailto:{lead_email}'>{lead_email}</a></td></tr>".format(**data) html += "</table><p></p><p></p>" html += "<p>Autogenerated with <a href='http://localhost:7999/projects/AGILE/repos/devops-utils-jira/browse/bin/jira-projects-administrators.py'>this script</a></p>" confluence = Confluence( url="http://localhost:8090/", username="******", password="******") confluence.update_page( page_id=13207798, parent_id=7471197, title="Administratorzy JIRA", body=html) log.info("Confluence Page Created with JRIA Administrators at: http://localhost:8095/pages/viewpage.action?pageId=13207798")
wiki_data_bottom = '</tbody></table><p class="auto-cursor-target"><br /></p></ac:rich-text-body></ac:structured-macro><p class="auto-cursor-target"><br /></p>' for i in range(0, len(test_result_list)): data_row = '<tr>' for j in range(0, len(test_result_list[i])-1): if j==0: data_row += '<td><a href="' + test_result_list[i][17] + '">' + test_result_list[i][j] + '</a></td>' else: data_row += '<td>' + test_result_list[i][j] + '</td>' data_row += '</tr>' wiki_data_middle += data_row confluence.update_page( parent_id = 99890426, page_id = 120296661, title = 'module_name_test_result', body = wiki_data_top + wiki_data_middle + wiki_data_bottom, type='page', representation='storage' ) conn.close() except: conn = pymongo.MongoClient("192.168.3.237", 27017) db = conn.tcs col = db.bot_oauth headers = { 'Content-Type': 'application/json; charset=UTF-8', 'consumerKey': col.find({})[0]['consumerKey'], 'Authorization': col.find({})[0]['Authorization'] } conn.close()
from pprint import pprint from atlassian import Confluence confluence = Confluence(url="http://localhost:8090", username="******", password="******") status = confluence.update_page(page_id=123456, title="This is the new title", body="This is the new body") pprint(status)
for j in range(0, len(test_result[i])): if j == 10: data_row += test_result[i][j] if j == 11: data_row += '<td><a href="https://wiki.telechips.com:8443/pages/viewpage.action?pageId=' + test_result[ i][j] + '">' + test_result[i][j] + '</a></td>' if j != 10 and j != 11: data_row += '<td>' + test_result[i][j] + '</td>' data_row += '</tr>' wiki_data_middle += data_row #Unit_test_backdata2 페이지 업데이트 r = confluence.update_page(parent_id=95455710, page_id=190659495, title='oss_test_backdata', body=wiki_data_top + wiki_data_middle + wiki_data_bottom, type='page', representation='storage') conn.close() except: conn = pymongo.MongoClient("192.168.3.237", 27017) db = conn.tcs col = db.bot_oauth headers = { 'Content-Type': 'application/json; charset=UTF-8', 'consumerKey': col.find({})[0]['consumerKey'], 'Authorization': col.find({})[0]['Authorization'] }
else: #나머지 항목은 값만 입력 data_row += '<td>' + str(list( version_data[i].values())[j]) + '</td>' data_row += '</tr>' wiki_data_middle += data_row wiki = wiki_data_top + wiki_data_middle + wiki_data_bottom wiki = wiki.replace("&", "<p>&</p>") #특수문자 & 치환 confluence = Confluence(url='https://wiki.telechips.com:8443', username=pw_data[0]['id'], password=pw_data[0]['pw']) confluence.update_page(parent_id=95455710, page_id=121733850, title='version_data', body=wiki, type='page', representation='storage') except: conn = pymongo.MongoClient("192.168.3.237", 27017) db = conn.tcs col = db.bot_oauth headers = { 'Content-Type': 'application/json; charset=UTF-8', 'consumerKey': col.find({})[0]['consumerKey'], 'Authorization': col.find({})[0]['Authorization'] } conn.close() url = 'https://apis.worksmobile.com/r/kr1llsnPeSqSR/message/v1/bot/1809717/message/push' #1:1 메시지 Request URL
<br /></p></ac:rich-text-body></ac:structured-macro><p class="auto-cursor-target"><br /></p>\ <ac:structured-macro ac:name="column" ac:schema-version="1" ac:macro-id="c6fb20bf-e840-4bf0-81a5-d0d866e63e64"><ac:parameter ac:name="width">33%</ac:parameter><ac:rich-text-body><p>\ <strong>CTG</strong></p><table class="fixed-table"><colgroup><col style="width: 150.0px;" /><col style="width: 80.0px;" /><col style="width: 80.0px;" /><col style="width: 80.0px;" /></colgroup><tbody>\ <tr><th style="text-align: center;">Team</th><th style="text-align: center;">개발</th><th style="text-align: center;">지원</th><th style="text-align: center;">경상</th></tr>\ <tr><td><a href="https://tcs.telechips.com:8443/secure/Dashboard.jspa?selectPageId=10800">' + team_resource[13][0] + '</a></td><td style="text-align: center;">' + team_resource[13][1] + '</td><td style="text-align: center;">' + team_resource[ 13][2] + '</td><td style="text-align: center;">' + team_resource[ 13][3] + '</td></tr>\ <tr><td><a href="https://tcs.telechips.com:8443/secure/Dashboard.jspa?selectPageId=10798">' + team_resource[14][0] + '</a></td><td style="text-align: center;">' + team_resource[14][1] + '</td><td style="text-align: center;">' + team_resource[ 14][2] + '</td><td style="text-align: center;">' + team_resource[ 14][3] + '</td></tr>\ <tr><td><a href="https://tcs.telechips.com:8443/secure/Dashboard.jspa?selectPageId=10797">' + team_resource[15][0] + '</a></td><td style="text-align: center;">' + team_resource[15][1] + '</td><td style="text-align: center;">' + team_resource[ 15][2] + '</td><td style="text-align: center;">' + team_resource[ 15][3] + '</td></tr>\ </tbody></table><p><strong><br /></strong></p></ac:rich-text-body></ac:structured-macro><p class="auto-cursor-target"><br /></p><ac:structured-macro ac:name="column" ac:schema-version="1" ac:macro-id="4cfc10a1-68c3-4ba3-ad63-ed91f2d9d700"><ac:parameter ac:name="width">33%</ac:parameter><ac:rich-text-body><p>\ <strong>HWG</strong></p><table class="fixed-table"><colgroup><col style="width: 150.0px;" /><col style="width: 80.0px;" /><col style="width: 80.0px;" /><col style="width: 80.0px;" /></colgroup><tbody>\ <tr><th style="text-align: center;">Team</th><th style="text-align: center;">개발</th><th style="text-align: center;">지원</th><th style="text-align: center;">경상</th></tr>\ <tr><td><a href="https://tcs.telechips.com:8443/secure/Dashboard.jspa?selectPageId=11130">' + team_resource[5][0] + '</a></td><td style="text-align: center;">' + team_resource[5][1] + '</td><td style="text-align: center;">' + team_resource[5][ 2] + '</td><td style="text-align: center;">' + team_resource[ 5][3] + '</td></tr>\ <tr><td><a href="https://tcs.telechips.com:8443/secure/Dashboard.jspa?selectPageId=11131">' + team_resource[6][0] + '</a></td><td style="text-align: center;">' + team_resource[6][1] + '</td><td style="text-align: center;">' + team_resource[6][2] + '</td><td style="text-align: center;">' + team_resource[ 6][3] + '</td></tr>\ </tbody></table><p><strong><br /></strong></p></ac:rich-text-body></ac:structured-macro><p class="auto-cursor-target"><br /></p></ac:rich-text-body></ac:structured-macro><p class="auto-cursor-target"><br /></p>' #Wiki 페이지 생성 confluence.update_page(parent_id=95455710, page_id=93389637, title='Resource_backdata', body=wiki_body, type='page', representation='storage')
logging.basicConfig(level=logging.DEBUG, format="[%(asctime).19s] [%(levelname)s] %(message)s") logging.getLogger("requests").setLevel(logging.WARNING) log = logging.getLogger("jira-projects-administrators") jira = Jira(url="http://localhost:8000/", username="******", password="******") html = "<table><tr><th>Project Key</th><th>Project Name</th><th>Leader</th><th>Email</th></tr>" for data in jira.project_leaders(): log.info( "{project_key} leader is {lead_name} <{lead_email}>".format(**data)) html += "<tr><td>{project_key}</td><td>{project_name}<td></td>{lead_name}<td></td><a href='mailto:{lead_email}'>{lead_email}</a></td></tr>".format( **data) html += "</table><p></p><p></p>" html += "<p>Autogenerated with <a href='http://localhost:7999/projects/AGILE/repos/devops-utils-jira/browse/bin/jira-projects-administrators.py'>this script</a></p>" confluence = Confluence(url="http://localhost:8090/", username="******", password="******") confluence.update_page(page_id=13207798, parent_id=7471197, title="Administratorzy JIRA", body=html) log.info( "Confluence Page Created with JRIA Administrators at: http://localhost:8095/pages/viewpage.action?pageId=13207798" )
data_row += '<td><a href="https://tcs.telechips.com:8443/projects/' + project_data[i][1] + '/summary/statistics">' + project_data[i][j] + '</a></td>' elif j == 2 and project_data[i][j] != '': #PL 이름 입력 data_row += '<td>' + project_data[i][j] + '</td>' elif j == 4 and project_data[i][j] != '': #종료보고에 link data_row += '<td><a href="' + project_data[i][j] + '">' + project_data[i][1] + '</a></td>' elif j == 8 and project_data[i][j] != '': #kick_off에 link data_row += '<td><a href="' + project_data[i][j] + '">' + project_data[i][1] + '</a></td>' elif j == 13 and project_data[i][j] != '': #Wiki에 link data_row += '<td><a href="' + project_data[i][j] + '">' + project_data[i][0] + '</a></td>' elif (j == 14 or 15) and project_data[i][j] != '': #role 입력 temp = '' for k in range(0, len(project_data[i][j])): temp += project_data[i][j][k] data_row += '<td>' + temp + '</td>' temp = '' else: #나머지 항목은 값만 입력 data_row += '<td>' + project_data[i][j] + '</td>' data_row += '</tr>' wiki_data_middle += data_row wiki = wiki_data_top + wiki_data_middle + wiki_data_bottom wiki = wiki.replace("&","<p>&</p>") #특수문자 & 치환 confluence.update_page( parent_id = 95455710, page_id = 120297594, title = 'project_data', body = wiki, type='page', representation='storage' )
for i in range(0, len(rnd_user)): if worklog[worklog['worklog_author']== rnd_user.loc[i, 'name']]['worklog_timespent'].sum() < 158.4: data.append([rnd_user.loc[i, 'team'], rnd_user.loc[i, 'name'], round(worklog[worklog['worklog_author']== rnd_user.loc[i, 'name']]['worklog_timespent'].sum(),2)]) #Wiki 페이지에 Data table 생성 wiki_data_top = '<p class="auto-cursor-target"><br /></p><ac:structured-macro ac:name="table-excerpt" ac:schema-version="1" ac:macro-id="70b8954e-f54e-46e7-8b34-a176d7c406ee">\ <ac:parameter ac:name="name">worklog_minor</ac:parameter><ac:rich-text-body><p class="auto-cursor-target"><br /></p><table><colgroup><col /><col /><col />\ </colgroup><tbody><tr><th>Team</th><th>name</th><th>worklog</th></tr>' wiki_data_middle = '' wiki_data_bottom = '</tbody></table><p class="auto-cursor-target"><br /></p></ac:rich-text-body></ac:structured-macro><p><br /></p>' #data 돌면서 table 생성 for i in range(0, len(data)): data_row = '<tr>' for j in range(0, len(data[i])): data_row += '<td>' + str(data[i][j]) + '</td>' data_row += '</tr>' wiki_data_middle += data_row wiki = wiki_data_top + wiki_data_middle + wiki_data_bottom wiki = wiki.replace("&","<p>&</p>") #특수문자 & 치환 confluence.update_page( parent_id = 42675555, page_id = 122586911, title = 'worklog 평균 이하 입력', body = wiki, type='page', representation='storage' )