From c8be185f5030b7371f263a9a1d20dfba6dc016e6 Mon Sep 17 00:00:00 2001 From: Manas Date: Jun 26 2019 15:56:35 +0000 Subject: added forgottone accept in commit --- diff --git a/accept.py b/accept.py new file mode 100644 index 0000000..e875d34 --- /dev/null +++ b/accept.py @@ -0,0 +1,141 @@ +import os +import requests +import json +import keyring +import configparser +import editor +from tga import epics as tgaepic +from tga import issues as tgaissue +from tga import userstory as tgauserstory +from tga import convert +from pgure import issues as pgaissues +from bz import bugs as bzbugz +from bz import pgba + + +""" +def accept(value, configpath): + config = configparser.ConfigParser() + config.read(configpath) + service_id = config['TAIGA']['SERVICE_ID'] # service id + service_token = config['TAIGA']['SERVICE_TOKEN'] + project_id = config['TAIGA']['PROJECT_ID'] + for x in value: # iteratingover name space object + try: + r = tgaissue.get_issue(x, config) # x is user story refrence id + if r.status_code == 200: + data = json.loads(r.content) + print(data, "this is user story data") + details = data['description'] + subject = data['subject'] + taiga_issue_id = data['id'] + taiga_isssue_ref = data['ref'] + taiga_issue_version = data['version'] + #fedora_version = data['epics'] + owner = data['owner_extra_info']['username'] + try: + r = tgaissue.caget_issue(taiga_issue_id, config) + if r.status_code == 200: + data = json.loads(r.content) + summary = data['attributes_values']['11372'] + bugzilla_id = data['attributes_values']['11373'] + approval_required = data['attributes_values']['11374'] + owners = data['attributes_values']['11375'] + contingency_deadline = data['attributes_values']['11376'] + mass_rebuild = data['attributes_values']['11377'] + policy_change = data['attributes_values']['11378'] + modifies_deliverables = data['attributes_values']['11379'] + system_wide_change = data['attributes_values']['11370'] + relengticket = data['attributes_values']['11371'] + fedora_version = data['attributes_values']['11383'] + print(bugzilla_id) + print("this step") + bzid = list(bugzilla_id.split(', ')) + print(bzid) + print(bugzilla_id, " This is bugzilla_id") + try: + taiga_issue_link = str(config['TAIGA']['TAIGA_SITE_ISSUE_URL']) + str(taiga_isssue_ref) + maillist_link = "random" + maillist_dsc_list = "random" + owner = "@" + str(owner) + with open("bugzilla_bug.txt", "w+") as b_txt: + b_txt.write("{}\n\n*{}\n*{}\n*{}\n*{}\n".format(taiga_issue_link, summary)) + editor.edit(filename="bugzilla_bug.txt") + try: + with open ("bugzilla_bug.txt", "r") as b_txt: + bug_text = b_txt.read() + payload = { + 'product': 'Fedora', + 'component': 'Changes Tracking', # temporary only + 'version': 'rawhide', + 'summary': subject, + 'description': bug_text, + 'assigned_to': bzid[0], + 'cc': bz_id[1:] + } + r = bzbugs.post_bug(payload, config) + print(r.content, r.status_code) # Development only + if r.status_code == 200: + owner = "@" + str(owner) + with open("rnotes_issue.txt", "w+") as rnotes_txt: + p_txt.write("{}\n\n*{}\n".format("standard text here", taiga_issue_link)) + editor.edit(filename="rnotes_issue.txt") + try: + with open("rnotes_issue.txt", "r") as rnotes_txt: + issue_text = rnotes_txt.read() + if system_wide_change == True: + syschange = "System-Wide Change" + elif system_wide_change == False: + syschange = "Change" + title = "F" + str(fedora_version) + ' ' + str(syschange) + ':' + str(subject) + payload = { + 'title' = title, + 'issue_content': issue_text + } + print(title, payload) + repo = ['PAGURE']['RELEASE_NOTES_REPO'] + r = pgaissues.post_issue(payload, repo, config) + print(r) +""" + + +def accept(args): + configpath = args.config + config = configparser.ConfigParser() + config.read(configpath) + service_id = config['TAIGA']['SERVICE_ID'] # service id + service_token = config['TAIGA']['SERVICE_TOKEN'] + project_id = config['TAIGA']['PROJECT_ID'] + value = args.accept + for x in value: # iteratingover name space object + try: + print(x) + """ + The conversion of X to string below + is because to maintin indivual convert + functionality.The Convert Functuion + needs something it can iterate over + to maintain multiple conversion functionality + int is not iterable so we convert it to string + since with the interation logic in both it only sees + it as a single int and we endup + """ + issuel = [] + issuel.append(x) + print(issuel) + conversion = convert.convert(issuel, configpath) + if conversion == True: + print("Sucessfully Converted Issue to User story") + bz = pgba.pgtobz(issuel, configpath) + if bz == True: + print("""Sucessfully Created Bugzilla Bug + and issue in release notes """) + else: + print("Error in Bug creation") + else: + print("Error in conversion to user story") + issuel = False + print(issuel) + except Exception as e: + print(e, "Unable to accept the Change Proposal") +