def regenerate_vlans_wiki(): wp_url = "http://%s/xmlrpc.php" % quads_config["wp_wiki"] wp_username = quads_config["wp_username"] wp_password = quads_config["wp_password"] page_title = quads_config["wp_wiki_vlans_title"] page_id = quads_config["wp_wiki_vlans_page_id"] with NamedTemporaryFile(mode="w+t") as _markdown: render_header(_markdown) render_vlans(_markdown) _markdown.seek(0) update_wiki(wp_url, wp_username, wp_password, page_title, page_id, _markdown.name)
try: repo = Repo(wp_wiki_git_repo_path) except InvalidGitRepositoryError: repo = Repo.init(wp_wiki_git_repo_path) if repo.git.diff(): repo.index.add(main_md) repo.index.commit( "%s content update" % datetime.now().strftime("%a %b %d %T %Y") ) repo.remotes.origin.push() try: racks_wiki.update_wiki( url="http://%s/xmlrpc.php" % wp_wiki, username=wp_username, password=wp_password, _page_title=wp_wiki_main_title, _page_id=wp_wiki_main_page_id, _markdown=main_md, ) except ProtocolError as ex: logger.error(ex.errmsg) create_input_assignments.main() assignments_md = os.path.join(wp_wiki_git_repo_path, "assignments.md") if wp_wiki_git_manage: if os.path.exists(wp_wiki_git_repo_path): try: repo = Repo(wp_wiki_git_repo_path) except InvalidGitRepositoryError: repo = Repo.init(wp_wiki_git_repo_path, bare=True)