From 0204ffe7507c89f0c66255b2241ff250c3d25579 Mon Sep 17 00:00:00 2001 From: Manas Date: Jun 04 2019 16:38:30 +0000 Subject: convert to user story re factored as per module divide --- diff --git a/convert.py b/convert.py index 0be6a24..b15f928 100644 --- a/convert.py +++ b/convert.py @@ -49,12 +49,15 @@ def convert(args): ('project', str(pid)), ) """ + r = tga.is_get(x) # gets the issue + """ r = requests.get( url, # debugurl, headers=headers, # params=params ) + """ # print("get object",r.json()) # Debug/Dev env only if r.status_code == 200: data = json.loads(r.content) @@ -62,70 +65,110 @@ def convert(args): details = data['description'] subject = data['subject'] id = data['id'] # fetch the id as well + """ try: - """ Because issue id is required to get custom attributes issues cannot be fetched via refrance id so fetching the issue by refrence first and then using the id returned in json to fetch the custom-attributes via issue id. Since only refrence is taken via command line - and issue id is difficult to find in taiga - """ - print(headers) # Debug only - id_url = str(taiga_url) + "/api/v1/issues/custom-attributes-values" + "/{" + id + "}" - print(id_url) # debug only + and issue id is difficult to find in taiga + # print(headers) # Debug only + # id_url = str(taiga_url) + "/api/v1/issues/custom-attributes-values" + "/{" + id + "}" + # print(id_url) # debug only issue_customattr = requests.get( id_url, headers=headers, ) - if issue_customattr.status_code == 200: - data = json.loads(issue_customattr.content) - system_wide_change = data['attributes_values']['1'] - # rel-eng-ticket = data['attributes_values']['7'] # bug in taiga thus the later no - summary = data['attributes_values']['2'] - bugzilla_id = data['attributes_values']['3'] - approval_required = data['attributes_values']['5'] - owners = data['attributes_values']['6'] - contingency_deadline = data['attributes_values']['11'] - mass_rebuild = data['attributes_values']['12'] - poliicy_change = data['attributes_values']['13'] - modifies_deliverables = data['attributes_values']['14'] - print(bugzilla_id) - """ - Taiga api returns no's instead of the actual names/description - The below no's stand for changes tracker fesco,change-wrangler - 1 = System-wide change - 2 = Summary - 3 = Bugzilla id - 4 = Missing - 5 = Trademark approval required - 6 = Owners - 7 = Rel-eng ticket/Rel-end impact ticket - 11 = Contingencry deadline - 12 = Mass rebuild required - 13 = Policy change required - 14 = Modifies deliverables - """ - except Exception as e: + """ + try: + r = issuecaget(id) + data = json.loads(r.content) + system_wide_change = data['attributes_values']['1'] + # rel-eng-ticket = data['attributes_values']['7'] # bug in taiga thus the later no + 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'] + + print(bugzilla_id) + print("Fetched Custom Attributes") + """ + Taiga api returns no's instead of the actual names/description + The below no's stand for changes tracker fesco,change-wrangler + 1 = System-wide change + 2 = Summary + 3 = Bugzilla id + 4 = Missing + 5 = Trademark approval required + 6 = Owners + 7 = Rel-eng ticket/Rel-end impact ticket + 11 = Contingencry deadline + 12 = Mass rebuild required + 13 = Policy change required + 14 = Modifies deliverables + """ + try: + payload = { + 'project': pid, + 'description': details, + 'subject': subject + } + r = tga.post_us(payload) + if r.status_code = 200: + data = json.loads(r.content) + id = data['id'] + payload = { + ['TAIGA']['TEST_US_CA_SYSTEM_WIDE_CHANGE']:system_wide_change + ['TAIGA']['TEST_US_CA_SUMMARY']:summary + ['TAIGA']['TEST_US_CA_RELENG_TICKET']:relengticket + ['TAIGA']['TEST_US_CA_TRADEMARK_APPROVAL']:approval_required + ['TAIGA']['TEST_US_CA_OWNERS']:owners + ['TAIGA']['TEST_US_CA_FESCO_TICKET']:'random' + ['TAIGA']['TEST_US_CA_BUGZILLA_TRACKER']:'random' + ['TAIGA']['TEST_US_CA_BUGZILLA_CONTACT']:bugzilla_id + ['TAIGA']['TEST_US_CA_RELEASE_NOTES']:'random' + ['TAIGA']['TEST_US_CA_CONTINGENCY']:contingency_deadline + ['TAIGA']['TEST_US_CA_MASS_REBUILD']:mass_rebuild + ['TAIGA']['TEST_US_CA_POLICY_CHANGE']:policy_change + ['TAIGA']['TEST_US_CA_MODIFIES_DELIVERABLES']:modifies_deliverables + } + r = tga.post_us_ca(payload, id) + if r.status_code == 200: + print("Sucessfully converted issue to user story") + else: + print("Unsuccesful conversion") + except requests.exceptions.RequestException at e: + print(e) + except requests.exceptions.RequestException as e: print("Failed to fetch attributes of the issue") print(e) - + """ payload = { 'project': pid, 'description': details, 'subject': subject } - print("post object") - print(payload) + """ + # print(payload) + + # print("post object") + + """ r = requests.post( 'https://api.taiga.io/api/v1/userstories', data=json.dumps(payload), headers=headers ) - if r.status_code == 200: - print("Sucessfully converted issue: {}".format(x)) - elif r.status_code == 401: - print("Authorization issues try reauthenticating") + """ except Exception as e: print(e) + except requests.exceptions.RequestException at e: + print(e)