From 3e715f3677c86d06d77fb303da190d18f270f7e2 Mon Sep 17 00:00:00 2001 From: Manas Date: Jun 15 2019 07:19:23 +0000 Subject: pagure fesco annoucne --- diff --git a/config.ini b/config.ini index 2180224..2380e9c 100644 --- a/config.ini +++ b/config.ini @@ -4,6 +4,7 @@ SERVICE_TOKEN = taiga_auth PID = 325363 # for test only DEFAULT_TAIGA_URL = https://teams-api.fedoraproject.org CUSTOM_TAIGA_URL = https://api.taiga.io +TAIGA_SITE_ISSUE_URL = https://tree.taiga.io/project/pac_23-test-changes-tracker-kanban/issue/ STATUS_ANNOUNCED = 29 STATUS_R_FESCO = 30 STATUS_ACCEPTED = 31 diff --git a/fesco.py b/fesco.py new file mode 100644 index 0000000..bb94f93 --- /dev/null +++ b/fesco.py @@ -0,0 +1,69 @@ +import os +import requests +import json +import keyring +import configparser +from tga import epics as tgaepic +from tga import issues as tgaissue +from tga import userstory as tgauserstory +from pgure import issues as pgaissues + +config = configparser.ConfigParser() +config.read('config.ini') + +service_id = config['TAIGA']['SERVICE_ID'] # service id +service_token = config['TAIGA']['SERVICE_TOKEN'] +project_id = config['TAIGA']['PROJECT_ID'] +if config['TAIGA']['TEST'] == 'yes': + taiga_url = config['TAIGA']['CUSTOM_TAIGA_URL'] +elif config['TAIGA']['TEST'] == 'no': + taiga_url = config['TAIGA']['DEFAULT_TAIGA_URL'] +else: + print("please set test status in config") + + +def announce(args): + for _, value in args._get_kwargs(): # iteratingover name space object + for x in value: + try: + r = tgaissue.get_issue(x)# 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'] + fedora-version = data['epics'] + owner = data['owner_extra_info']['username'] + try: + r = tgaissue.getca_issue(issue_id) + 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'] + 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("pagure_issue.txt", "w+") as p_txt: + p_txt("{}\n\n*{}\n*{}\n*{}\n*{}\n".format(summary, taiga_issue_link, maillist_link, maillist_dsc_list, owner)) + editor.edit(filename="pagure_issue.txt") + try: + r = pgaissues.post_issue(config) + payload = { + 'title': subject, + 'issue_content': details, + '': + } + \ No newline at end of file diff --git a/mail/climail.py b/mail/climail.py index a823a8e..d1fd906 100644 --- a/mail/climail.py +++ b/mail/climail.py @@ -62,6 +62,7 @@ def mails(args): ra = issues.issue_caget(data['id']) if ra.status_code == 200: cadata = json.loads(ra.content) + """ body = '''\ == Summary == {} @@ -69,6 +70,7 @@ def mails(args): {} == Detailed Description == \ '''.format(cadata['attributes_values']['11372'], cadata['attributes_values']['11375'], data['description']) + """ with open("mail.txt", "w+") as m_txt: m_txt.write("== Summary == \n{}\n\n== owner == \n{}\n\n== Detailed Description == \n{}".format(cadata['attributes_values']['11372'], cadata['attributes_values']['11375'], data['description'])) #m_txt.write("{}".format(body)) diff --git a/mail/maillist.py b/mail/maillist.py index 7ebebbe..6162f80 100644 --- a/mail/maillist.py +++ b/mail/maillist.py @@ -17,6 +17,7 @@ config.read('config.ini') service_id = config['EMAIL']['SERVICE_ID'] # service id # service_token = config['']['SERVICE_TOKEN'] # pid = config['TAIGA']['PID'] +""" if config['EMAIL']['TEST'] == 'yes': sender = config['EMAIL']['CUSTOM_EMAIL_ID'] reciver = config['EMAIL']['TEST_LIST'] @@ -25,7 +26,7 @@ elif config['EMAIL']['TEST'] == 'no': reciver = config['EMAIL']['LIST'] else: print("please set proper test status in config") - +""" def email_send(subject): port = config['EMAIL']['PORT'] # For SSL diff --git a/notes/notes.txt b/notes/notes.txt index 9d24996..d98bbea 100644 --- a/notes/notes.txt +++ b/notes/notes.txt @@ -35,4 +35,70 @@ curl -X GET \ Get List of Multiple ready for wrangler changes. curl -X GET -H "Content-Type: application/json" -H "Authorizion: Bearer ${AUTH_TOKEN}" -s https://teams-api.fedoraproject.org/api/v1/userstories?project=5\&status=30 -push to commit issues, \ No newline at end of file +curl -X GET \ +-H "Content-Type: application/json" \ +-H "Authorization: Bearer ${eyJ1c2VyX2F1dGhlbnRpY2F0aW9uX2lkIjozNTY4MDR9:1hI6pm:4d4mA-gUXC2S0FxaladX0Fd_3gA}" \ +-s https://api.taiga.io/api/v1/issues/custom-attributes-values/{26} + +curl -X GET \ +-H "Content-Type: application/json" \ +-H "Authorization: Bearer ${eyJ1c2VyX2F1dGhlbnRpY2F0aW9uX2lkIjozNTY4MDR9:1hI6pm:4d4mA-gUXC2S0FxaladX0Fd_3gA}" \ +-s http://localhost:8000/api/v1/issue-statuses?project=325667 + +curl -X GET \ +-H "Content-Type: application/json" \ +-H "Authorization: Bearer ${eyJ1c2VyX2F1dGhlbnRpY2F0aW9uX2lkIjozNTY4MDR9:1hI6pm:4d4mA-gUXC2S0FxaladX0Fd_3gA}" \ +-s http://api.taiga.io/api/v1/userstory-statuses?project=325667 + +curl -X GET \ +-H "Content-Type: application/json" \ +-H "Authorization: Bearer ${eyJ1c2VyX2F1dGhlbnRpY2F0aW9uX2lkIjozNTY4MDR9:1hI6pm:4d4mA-gUXC2S0FxaladX0Fd_3gA}" \ +-s https://api.taiga.io/api/v1/userstory-custom-attributes?project=325667 + +curl -X GET \ +-H "Content-Type: application/json" \ +-H "Authorization: Bearer ${eyJ1c2VyX2F1dGhlbnRpY2F0aW9uX2lkIjozNTY4MDR9:1hI6pm:4d4mA-gUXC2S0FxaladX0Fd_3gA}" \ +-s https://api.taiga.io/api/v1/api/v1/issue-custom-attributes?project=325667 + + +curl -X POST \ +-H "Content-Type: application/json" \ +-d '{ + "subject": "test change", + "description": "test new change" + }' \ +-s http://api.taiga.io/api/v1/userstories + +"auth_token": "eyJ1c2VyX2F1dGhlbnRpY2F0aW9uX2lkIjozNTY4MDR9:1hY9LV:FaxXO5XP09sQHyLm7xjGFMa6UmE + +push to commit issues, + +curl -X POST \ +-H "Content-Type: application/json" \ +-H "Authorization: Bearer ${eyJ1c2VyX2F1dGhlbnRpY2F0aW9uX2lkIjozNTY4MDR9:1hX0Sw:X9sKb5jHiUDE0Hayfx9YziCDuPw}" \ +-d '{ + "project": 1, + "subject": "Customer personal data" + }' \ +-s http://localhost:8000/api/v1/userstories + +curl -X GET \ +-H "Content-Type: application/json" \ +-H "Authorization: Bearer ${eyJ1c2VyX2F1dGhlbnRpY2F0aW9uX2lkIjozNTY4MDR9:1hI6pm:4d4mA-gUXC2S0FxaladX0Fd_3gA}" \ +-s http://localhost:8000/api/v1/issues/custom-attributes-values/1232291 + +curl -X GET \ +-H "Content-Type: application/json" \ +-H "Authorization: Bearer ${eyJ1c2VyX2F1dGhlbnRpY2F0aW9uX2lkIjozNTY4MDR9:1hI6pm:4d4mA-gUXC2S0FxaladX0Fd_3gA}" \ +-s http://api.taiga.io/api/v1/issues/1232291 + +curl -X GET \ +-H "Content-Type: application/json" \ +-H "Authorization: Bearer ${eyJ1c2VyX2F1dGhlbnRpY2F0aW9uX2lkIjozNTY4MDR9:1hI6pm:4d4mA-gUXC2S0FxaladX0Fd_3gA}" \ +-s http://api.taiga.io/api/v1/issues/by_ref?ref=4\&project=1232291 + + +curl -X GET \ +-H "Content-Type: application/json" \ +-H "Authorization: Bearer ${eyJ1c2VyX2F1dGhlbnRpY2F0aW9uX2lkIjozNTY4MDR9:1hI6pm:4d4mA-gUXC2S0FxaladX0Fd_3gA}" \ +-s https://api.taiga.io/api/v1/epics?project=325667 \ No newline at end of file diff --git a/pgure/issues.py b/pgure/issues.py new file mode 100644 index 0000000..e10ae62 --- /dev/null +++ b/pgure/issues.py @@ -0,0 +1,23 @@ +import requets +import config + +headers = { + 'Content-Type': 'application/json', + 'Authorization': token {}.format(keyring.get_password(service_token, "repo_name")) +} + +def list_issue(): + """kusts ussyes""" + + +def get_issue(): + """gets issue from pagure""" + + +def post_issue(config): + """ Posts issue to pagure """ + try: + + print() + +