From 602260b3d4b18d5b1ee466555485e72d93b28023 Mon Sep 17 00:00:00 2001 From: Manas Date: May 24 2019 17:43:15 +0000 Subject: [PATCH 1/71] test ini and keyring support --- diff --git a/auth/__pycache__/__init__.cpython-36.pyc b/auth/__pycache__/__init__.cpython-36.pyc new file mode 100644 index 0000000..e54dd9f Binary files /dev/null and b/auth/__pycache__/__init__.cpython-36.pyc differ diff --git a/auth/__pycache__/taiga.cpython-36.pyc b/auth/__pycache__/taiga.cpython-36.pyc new file mode 100644 index 0000000..e800c43 Binary files /dev/null and b/auth/__pycache__/taiga.cpython-36.pyc differ diff --git a/auth/__pycache__/tauth.cpython-36.pyc b/auth/__pycache__/tauth.cpython-36.pyc new file mode 100644 index 0000000..c7f18ab Binary files /dev/null and b/auth/__pycache__/tauth.cpython-36.pyc differ diff --git a/auth/pauth.py b/auth/pauth.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/auth/pauth.py diff --git a/auth/tauth.py b/auth/tauth.py new file mode 100644 index 0000000..99f156d --- /dev/null +++ b/auth/tauth.py @@ -0,0 +1,73 @@ +import requests +import json +import keyring +import random +import os +import binascii +import getpass +import configparser + +config = configparser.ConfigParser() +confi.read('config.ini') + +service_id = config['TAIGA']['SERVICE_ID'] # service id +service_token = config['TAIGA']['SERVICE_TOKEN'] # service d for auth + + +def refresh_token(): + headers = { + 'Content-Type': 'application/json' + } + """ + Used only for testing and Demo + Encrypted Config file/Application token + used in production. + Doing the follwoing in prod is security risk. + """ + username = keyring.get_password(service_id, "username") + print(username) + payload = { + 'type': 'normal', + 'username': username, + 'password': keyring.get_password(service_id, username) + } + # print(payload) # only for debugging + + try: + r = requests.post( + "https://api.taiga.io/api/v1/auth", + data=json.dumps(payload), + headers=headers) + print(r.status_code) + if r.status_code == 200: + """ + with open('auth.txt', 'w') as a_file: + a_file.write(r.json()['auth_token']) + """ + try: + keyring.set_password(service_token, "username", r.json()['auth_token']) + print("succesful authentication") + except (keyring.errors.PasswordSetError, Exception) as e: + print("Failed to set auth token") + elif r.status_code == 400: + print("auth error") + except Exception as e: + print(e) + + +def reset(): + print("You User Id and password will be securly store in the Keyring") + username = input("Enter your user id for taiga: ") + password = getpass.getpass("Enter your password for taiga: ") + try: + # keyring.set_password("taiga", username) + keyring.set_password(service_id, "username", username) + keyring.set_password(service_id, username, str(password)) + username = binascii.hexlify(os.urandom(20)) # randomising username to avoid sneak memory attacks + password = binascii.hexlify(os.urandom(20)) # ranomising pass to avoid sneak memory attacks + # username = random.choices(string.ascii_uppercase + string.digits, k=random.randint(1,10)) + # passwd = random.choices(string.ascii_uppercase + string.digits, k=random.randint(1,10)) + print("Password reset succesfully") + except (keyring.errors.PasswordSetError, Exception) as e: + print("Failed to reset password") + # print(e + "Contact the developers asap") diff --git a/config.ini b/config.ini new file mode 100644 index 0000000..b3e5d51 --- /dev/null +++ b/config.ini @@ -0,0 +1,10 @@ +[TAIGA] +SERVICE_ID = taiga +SERVICE_TOKEN = taiga_auth +PID = 315827 # for test only + + +[PAGURE] +SERVICE_ID = pagure + +[BUGZILLA] \ No newline at end of file diff --git a/convert.py b/convert.py new file mode 100644 index 0000000..517e29a --- /dev/null +++ b/convert.py @@ -0,0 +1,78 @@ +import os +import requests +import json +import keyring +import configparser + +config = configparser.ConfigParser() +confi.read('config.ini') + +service_id = config['TAIGA']['SERVICE_ID'] # service id +service_token = config['TAIGA']['SERVICE_TOKEN'] +pid = config['TAIGA']['PID'] + +""" +with open('auth.txt', 'r') as a_file: + token = + # auth_t = token.encode("ascii", "ignore") + # print(token) # debug only +""" +keyring.get_password(service_id, username) +headers = { + 'Content-Type': 'application/json', + 'Authorization': 'Bearer {0}'.format(keyring.get_password(service_id, username)) +} + + +def convert(args): + for _, value in args._get_kwargs(): # iteratingover name space object + for x in value: + try: + print(headers) # Debug only + url = "https://api.taiga.io/api/v1/issues/by_ref?ref=" + str(x) + "&project=" + str(pid) + # debugurl = "https://api.taiga.io/api/v1/issues/by_ref" + print(url) # debug/dev env only + # print(debugurl) # Debug only + # ino = str(x) + '/' + """ + params = ( + ('ref', ino), + ('project', str(pid)), + ) + """ + 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) + # print(data) + details = data['description'] + subject = data['subject'] + payload = { + 'project': pid, + 'description': details, + 'subject': subject + } + 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) + +""" +curl -X GET \ +-H "Content-Type: application/json" \ +-H "Authorization: Bearer ${eyJ1c2VyX2F1dGhlbnRpY2F0aW9uX2lkIjozNTY4MDR9:1hI6pm:4d4mA-gUXC2S0FxaladX0Fd_3gA}" \ +-s https://api.taiga.io/api/v1/issues/by_ref?ref=1\&project=315827 +""" \ No newline at end of file From 56ad1bd77cd656f7f50cc4535aef168c1eb67959 Mon Sep 17 00:00:00 2001 From: Manas Date: May 24 2019 17:45:44 +0000 Subject: [PATCH 2/71] Revert "test ini and keyring support" This reverts commit 602260b3d4b18d5b1ee466555485e72d93b28023. --- diff --git a/auth/__pycache__/__init__.cpython-36.pyc b/auth/__pycache__/__init__.cpython-36.pyc deleted file mode 100644 index e54dd9f..0000000 Binary files a/auth/__pycache__/__init__.cpython-36.pyc and /dev/null differ diff --git a/auth/__pycache__/taiga.cpython-36.pyc b/auth/__pycache__/taiga.cpython-36.pyc deleted file mode 100644 index e800c43..0000000 Binary files a/auth/__pycache__/taiga.cpython-36.pyc and /dev/null differ diff --git a/auth/__pycache__/tauth.cpython-36.pyc b/auth/__pycache__/tauth.cpython-36.pyc deleted file mode 100644 index c7f18ab..0000000 Binary files a/auth/__pycache__/tauth.cpython-36.pyc and /dev/null differ diff --git a/auth/pauth.py b/auth/pauth.py deleted file mode 100644 index e69de29..0000000 --- a/auth/pauth.py +++ /dev/null diff --git a/auth/tauth.py b/auth/tauth.py deleted file mode 100644 index 99f156d..0000000 --- a/auth/tauth.py +++ /dev/null @@ -1,73 +0,0 @@ -import requests -import json -import keyring -import random -import os -import binascii -import getpass -import configparser - -config = configparser.ConfigParser() -confi.read('config.ini') - -service_id = config['TAIGA']['SERVICE_ID'] # service id -service_token = config['TAIGA']['SERVICE_TOKEN'] # service d for auth - - -def refresh_token(): - headers = { - 'Content-Type': 'application/json' - } - """ - Used only for testing and Demo - Encrypted Config file/Application token - used in production. - Doing the follwoing in prod is security risk. - """ - username = keyring.get_password(service_id, "username") - print(username) - payload = { - 'type': 'normal', - 'username': username, - 'password': keyring.get_password(service_id, username) - } - # print(payload) # only for debugging - - try: - r = requests.post( - "https://api.taiga.io/api/v1/auth", - data=json.dumps(payload), - headers=headers) - print(r.status_code) - if r.status_code == 200: - """ - with open('auth.txt', 'w') as a_file: - a_file.write(r.json()['auth_token']) - """ - try: - keyring.set_password(service_token, "username", r.json()['auth_token']) - print("succesful authentication") - except (keyring.errors.PasswordSetError, Exception) as e: - print("Failed to set auth token") - elif r.status_code == 400: - print("auth error") - except Exception as e: - print(e) - - -def reset(): - print("You User Id and password will be securly store in the Keyring") - username = input("Enter your user id for taiga: ") - password = getpass.getpass("Enter your password for taiga: ") - try: - # keyring.set_password("taiga", username) - keyring.set_password(service_id, "username", username) - keyring.set_password(service_id, username, str(password)) - username = binascii.hexlify(os.urandom(20)) # randomising username to avoid sneak memory attacks - password = binascii.hexlify(os.urandom(20)) # ranomising pass to avoid sneak memory attacks - # username = random.choices(string.ascii_uppercase + string.digits, k=random.randint(1,10)) - # passwd = random.choices(string.ascii_uppercase + string.digits, k=random.randint(1,10)) - print("Password reset succesfully") - except (keyring.errors.PasswordSetError, Exception) as e: - print("Failed to reset password") - # print(e + "Contact the developers asap") diff --git a/config.ini b/config.ini deleted file mode 100644 index b3e5d51..0000000 --- a/config.ini +++ /dev/null @@ -1,10 +0,0 @@ -[TAIGA] -SERVICE_ID = taiga -SERVICE_TOKEN = taiga_auth -PID = 315827 # for test only - - -[PAGURE] -SERVICE_ID = pagure - -[BUGZILLA] \ No newline at end of file diff --git a/convert.py b/convert.py deleted file mode 100644 index 517e29a..0000000 --- a/convert.py +++ /dev/null @@ -1,78 +0,0 @@ -import os -import requests -import json -import keyring -import configparser - -config = configparser.ConfigParser() -confi.read('config.ini') - -service_id = config['TAIGA']['SERVICE_ID'] # service id -service_token = config['TAIGA']['SERVICE_TOKEN'] -pid = config['TAIGA']['PID'] - -""" -with open('auth.txt', 'r') as a_file: - token = - # auth_t = token.encode("ascii", "ignore") - # print(token) # debug only -""" -keyring.get_password(service_id, username) -headers = { - 'Content-Type': 'application/json', - 'Authorization': 'Bearer {0}'.format(keyring.get_password(service_id, username)) -} - - -def convert(args): - for _, value in args._get_kwargs(): # iteratingover name space object - for x in value: - try: - print(headers) # Debug only - url = "https://api.taiga.io/api/v1/issues/by_ref?ref=" + str(x) + "&project=" + str(pid) - # debugurl = "https://api.taiga.io/api/v1/issues/by_ref" - print(url) # debug/dev env only - # print(debugurl) # Debug only - # ino = str(x) + '/' - """ - params = ( - ('ref', ino), - ('project', str(pid)), - ) - """ - 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) - # print(data) - details = data['description'] - subject = data['subject'] - payload = { - 'project': pid, - 'description': details, - 'subject': subject - } - 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) - -""" -curl -X GET \ --H "Content-Type: application/json" \ --H "Authorization: Bearer ${eyJ1c2VyX2F1dGhlbnRpY2F0aW9uX2lkIjozNTY4MDR9:1hI6pm:4d4mA-gUXC2S0FxaladX0Fd_3gA}" \ --s https://api.taiga.io/api/v1/issues/by_ref?ref=1\&project=315827 -""" \ No newline at end of file From 495f89c6d1fb2e8a82a676ba05e48b46ffe3ba98 Mon Sep 17 00:00:00 2001 From: Manas Date: May 24 2019 17:46:41 +0000 Subject: [PATCH 3/71] Revert "Revert "test ini and keyring support"" This reverts commit 56ad1bd77cd656f7f50cc4535aef168c1eb67959. --- diff --git a/auth/__pycache__/__init__.cpython-36.pyc b/auth/__pycache__/__init__.cpython-36.pyc new file mode 100644 index 0000000..e54dd9f Binary files /dev/null and b/auth/__pycache__/__init__.cpython-36.pyc differ diff --git a/auth/__pycache__/taiga.cpython-36.pyc b/auth/__pycache__/taiga.cpython-36.pyc new file mode 100644 index 0000000..e800c43 Binary files /dev/null and b/auth/__pycache__/taiga.cpython-36.pyc differ diff --git a/auth/__pycache__/tauth.cpython-36.pyc b/auth/__pycache__/tauth.cpython-36.pyc new file mode 100644 index 0000000..c7f18ab Binary files /dev/null and b/auth/__pycache__/tauth.cpython-36.pyc differ diff --git a/auth/pauth.py b/auth/pauth.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/auth/pauth.py diff --git a/auth/tauth.py b/auth/tauth.py new file mode 100644 index 0000000..99f156d --- /dev/null +++ b/auth/tauth.py @@ -0,0 +1,73 @@ +import requests +import json +import keyring +import random +import os +import binascii +import getpass +import configparser + +config = configparser.ConfigParser() +confi.read('config.ini') + +service_id = config['TAIGA']['SERVICE_ID'] # service id +service_token = config['TAIGA']['SERVICE_TOKEN'] # service d for auth + + +def refresh_token(): + headers = { + 'Content-Type': 'application/json' + } + """ + Used only for testing and Demo + Encrypted Config file/Application token + used in production. + Doing the follwoing in prod is security risk. + """ + username = keyring.get_password(service_id, "username") + print(username) + payload = { + 'type': 'normal', + 'username': username, + 'password': keyring.get_password(service_id, username) + } + # print(payload) # only for debugging + + try: + r = requests.post( + "https://api.taiga.io/api/v1/auth", + data=json.dumps(payload), + headers=headers) + print(r.status_code) + if r.status_code == 200: + """ + with open('auth.txt', 'w') as a_file: + a_file.write(r.json()['auth_token']) + """ + try: + keyring.set_password(service_token, "username", r.json()['auth_token']) + print("succesful authentication") + except (keyring.errors.PasswordSetError, Exception) as e: + print("Failed to set auth token") + elif r.status_code == 400: + print("auth error") + except Exception as e: + print(e) + + +def reset(): + print("You User Id and password will be securly store in the Keyring") + username = input("Enter your user id for taiga: ") + password = getpass.getpass("Enter your password for taiga: ") + try: + # keyring.set_password("taiga", username) + keyring.set_password(service_id, "username", username) + keyring.set_password(service_id, username, str(password)) + username = binascii.hexlify(os.urandom(20)) # randomising username to avoid sneak memory attacks + password = binascii.hexlify(os.urandom(20)) # ranomising pass to avoid sneak memory attacks + # username = random.choices(string.ascii_uppercase + string.digits, k=random.randint(1,10)) + # passwd = random.choices(string.ascii_uppercase + string.digits, k=random.randint(1,10)) + print("Password reset succesfully") + except (keyring.errors.PasswordSetError, Exception) as e: + print("Failed to reset password") + # print(e + "Contact the developers asap") diff --git a/config.ini b/config.ini new file mode 100644 index 0000000..b3e5d51 --- /dev/null +++ b/config.ini @@ -0,0 +1,10 @@ +[TAIGA] +SERVICE_ID = taiga +SERVICE_TOKEN = taiga_auth +PID = 315827 # for test only + + +[PAGURE] +SERVICE_ID = pagure + +[BUGZILLA] \ No newline at end of file diff --git a/convert.py b/convert.py new file mode 100644 index 0000000..517e29a --- /dev/null +++ b/convert.py @@ -0,0 +1,78 @@ +import os +import requests +import json +import keyring +import configparser + +config = configparser.ConfigParser() +confi.read('config.ini') + +service_id = config['TAIGA']['SERVICE_ID'] # service id +service_token = config['TAIGA']['SERVICE_TOKEN'] +pid = config['TAIGA']['PID'] + +""" +with open('auth.txt', 'r') as a_file: + token = + # auth_t = token.encode("ascii", "ignore") + # print(token) # debug only +""" +keyring.get_password(service_id, username) +headers = { + 'Content-Type': 'application/json', + 'Authorization': 'Bearer {0}'.format(keyring.get_password(service_id, username)) +} + + +def convert(args): + for _, value in args._get_kwargs(): # iteratingover name space object + for x in value: + try: + print(headers) # Debug only + url = "https://api.taiga.io/api/v1/issues/by_ref?ref=" + str(x) + "&project=" + str(pid) + # debugurl = "https://api.taiga.io/api/v1/issues/by_ref" + print(url) # debug/dev env only + # print(debugurl) # Debug only + # ino = str(x) + '/' + """ + params = ( + ('ref', ino), + ('project', str(pid)), + ) + """ + 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) + # print(data) + details = data['description'] + subject = data['subject'] + payload = { + 'project': pid, + 'description': details, + 'subject': subject + } + 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) + +""" +curl -X GET \ +-H "Content-Type: application/json" \ +-H "Authorization: Bearer ${eyJ1c2VyX2F1dGhlbnRpY2F0aW9uX2lkIjozNTY4MDR9:1hI6pm:4d4mA-gUXC2S0FxaladX0Fd_3gA}" \ +-s https://api.taiga.io/api/v1/issues/by_ref?ref=1\&project=315827 +""" \ No newline at end of file From 983aae85e2f027ae7b3a237ee997676e901e8aa3 Mon Sep 17 00:00:00 2001 From: Manas Date: May 28 2019 15:47:02 +0000 Subject: [PATCH 4/71] bugzilla and pagure key storage and auth --- diff --git a/auth/bugzilla_auth.py b/auth/bugzilla_auth.py new file mode 100644 index 0000000..6622177 --- /dev/null +++ b/auth/bugzilla_auth.py @@ -0,0 +1,76 @@ +import requests +import json +import keyring +import random +import os +import binascii +import getpass +import configparser + +config = configparser.ConfigParser() +config.read('config.ini') + +service_id = config['BUGZILLA']['SERVICE_ID'] # service id +service_token = config['BUGZILLA']['SERVICE_TOKEN'] # service d for auth +bz_url = config['BUGZILLA']['DEFAULT_BUGZILLA_URL'] # taiga server note +custom_bz = config['BUGZILLA']['CUSTOM_BUGZILLA_URL'] + + +def refresh_token(): + headers = { + 'Content-Type': 'application/json' + } + """ + Used only for testing and Demo + Encrypted Config file/Application token + used in production. + Doing the follwoing in prod is security risk. + """ + username = keyring.get_password(service_id, "username") + # print(username) # debug only + payload = { + 'type': 'normal', + 'username': username, + 'password': keyring.get_password(service_id, username) + } + # print(payload) # only for debugging + + try: + r = requests.post( + str(taiga_url) + "https://api.taiga.io/api/v1/auth", + data=json.dumps(payload), + headers=headers) + print(r.status_code) + if r.status_code == 200: + """ + with open('auth.txt', 'w') as a_file: + a_file.write(r.json()['auth_token']) + """ + try: + keyring.set_password(service_token, "username", r.json()['auth_token']) + print("succesful authentication") + except (keyring.errors.PasswordSetError, Exception) as e: + print("Failed to set auth token") + elif r.status_code == 400: + print("auth error") + except Exception as e: + print(e) + + +def reset(): + print("You User Id and password will be securly store in the Keyring") + username = input("Enter your user id for bugzilla: ") + password = getpass.getpass("Enter your password for bugzilla: ") + api_key = getpass.getpass("Enter your bugzilla api: ") + try: + # keyring.set_password("taiga", username) + # keyring.set_password(service_id, "username", username) + keyring.set_password(service_id, username, str(password)) + keyring.set_password(service_id, username, api_key) + username = binascii.hexlify(os.urandom(20)) # randomising username to avoid sneak memory attacks + password = binascii.hexlify(os.urandom(20)) # ranomising pass to avoid sneak memory attacks + # username = random.choices(string.ascii_uppercase + string.digits, k=random.randint(1,10)) + # passwd = random.choices(string.ascii_uppercase + string.digits, k=random.randint(1,10)) + print("Password and api key reset succesfully") + except (keyring.errors.PasswordSetError, Exception) as e: + print("Failed to reset password & api key") diff --git a/auth/pagure_auth.py b/auth/pagure_auth.py new file mode 100644 index 0000000..0f36322 --- /dev/null +++ b/auth/pagure_auth.py @@ -0,0 +1,34 @@ +import requests +import json +import keyring +import random +import os +import binascii +import getpass +import configparser + +config = configparser.ConfigParser() +config.read('config.ini') + + +""" +def refresh_token(): + headers = { + 'Content-Type': 'application/json' + } +""" + + +def reset(): + print("Your auth token will be securly store in the Keyring") + # username = input("Enter your user id for taiga: ") + api_token = "api_token" + repo_name = input("Enter the repo name you want to set api key for: ") + token = getpass.getpass("Enter your token for" + ' ' + repo_name + ' ' "repository: ") + try: + # keyring.set_password("taiga", username) + keyring.set_password(repo_name, api_token, token) + print("token reset succesfully") + except (keyring.errors.PasswordSetError, Exception) as e: + print("Failed to reset token") + # print(e + "Contact the developers asap") diff --git a/auth/pauth.py b/auth/pauth.py deleted file mode 100644 index e69de29..0000000 --- a/auth/pauth.py +++ /dev/null diff --git a/auth/taiga_auth.py b/auth/taiga_auth.py new file mode 100644 index 0000000..271e0ed --- /dev/null +++ b/auth/taiga_auth.py @@ -0,0 +1,84 @@ +import requests +import json +import keyring +import random +import os +import binascii +import getpass +import configparser + +config = configparser.ConfigParser() +config.read('config.ini') + +service_id = config['TAIGA']['SERVICE_ID'] # service id +service_token = config['TAIGA']['SERVICE_TOKEN'] # service d for auth +taiga_url = config['TAIGA']['DEFAULT_TAIGA_URL'] # taiga server note +custom_taiga = config['TAIGA']['CUSTOM_TAIGA_URL'] + + +def refresh_token(): + headers = { + 'Content-Type': 'application/json' + } + """ + Used only for testing and Demo + Encrypted Config file/Application token + used in production. + Doing the follwoing in prod is security risk. + """ + username = keyring.get_password(service_id, "username") + # print(username) # debug only + payload = { + 'type': 'normal', + 'username': username, + 'password': keyring.get_password(service_id, username) + } + # print(payload) # only for debugging + + try: + r = requests.post( + str(taiga_url) + "https://api.taiga.io/api/v1/auth", + data=json.dumps(payload), + headers=headers) + print(r.status_code) + if r.status_code == 200: + """ + with open('auth.txt', 'w') as a_file: + a_file.write(r.json()['auth_token']) + """ + try: + keyring.set_password(service_token, "username", r.json()['auth_token']) + print("succesful authentication") + except (keyring.errors.PasswordSetError, Exception) as e: + print("Failed to set auth token") + elif r.status_code == 400: + print("auth error") + except Exception as e: + print(e) + + +def reset(): + print("You User Id and password will be securly store in the Keyring") + username = input("Enter your user id for taiga: ") + password = getpass.getpass("Enter your password for taiga: ") + try: + # keyring.set_password("taiga", username) + """ + So a workaround to store username along with pass is being used + the only drawback ofthis work around is in the gui keyring broswer + a seperate username keyring will show,sadly this cannot be avoided + at the point of writing this peice of software + """ + """ + The above comment is not true + """ + #keyring.set_password(service_id, "username", username) refer line 67 + keyring.set_password(service_id, username, str(password)) + username = binascii.hexlify(os.urandom(20)) # randomising username to avoid sneak memory attacks + password = binascii.hexlify(os.urandom(20)) # ranomising pass to avoid sneak memory attacks + # username = random.choices(string.ascii_uppercase + string.digits, k=random.randint(1,10)) + # passwd = random.choices(string.ascii_uppercase + string.digits, k=random.randint(1,10)) + print("Password reset succesfully") + except (keyring.errors.PasswordSetError, Exception) as e: + print("Failed to reset password") + # print(e + "Contact the developers asap") diff --git a/auth/tauth.py b/auth/tauth.py deleted file mode 100644 index 99f156d..0000000 --- a/auth/tauth.py +++ /dev/null @@ -1,73 +0,0 @@ -import requests -import json -import keyring -import random -import os -import binascii -import getpass -import configparser - -config = configparser.ConfigParser() -confi.read('config.ini') - -service_id = config['TAIGA']['SERVICE_ID'] # service id -service_token = config['TAIGA']['SERVICE_TOKEN'] # service d for auth - - -def refresh_token(): - headers = { - 'Content-Type': 'application/json' - } - """ - Used only for testing and Demo - Encrypted Config file/Application token - used in production. - Doing the follwoing in prod is security risk. - """ - username = keyring.get_password(service_id, "username") - print(username) - payload = { - 'type': 'normal', - 'username': username, - 'password': keyring.get_password(service_id, username) - } - # print(payload) # only for debugging - - try: - r = requests.post( - "https://api.taiga.io/api/v1/auth", - data=json.dumps(payload), - headers=headers) - print(r.status_code) - if r.status_code == 200: - """ - with open('auth.txt', 'w') as a_file: - a_file.write(r.json()['auth_token']) - """ - try: - keyring.set_password(service_token, "username", r.json()['auth_token']) - print("succesful authentication") - except (keyring.errors.PasswordSetError, Exception) as e: - print("Failed to set auth token") - elif r.status_code == 400: - print("auth error") - except Exception as e: - print(e) - - -def reset(): - print("You User Id and password will be securly store in the Keyring") - username = input("Enter your user id for taiga: ") - password = getpass.getpass("Enter your password for taiga: ") - try: - # keyring.set_password("taiga", username) - keyring.set_password(service_id, "username", username) - keyring.set_password(service_id, username, str(password)) - username = binascii.hexlify(os.urandom(20)) # randomising username to avoid sneak memory attacks - password = binascii.hexlify(os.urandom(20)) # ranomising pass to avoid sneak memory attacks - # username = random.choices(string.ascii_uppercase + string.digits, k=random.randint(1,10)) - # passwd = random.choices(string.ascii_uppercase + string.digits, k=random.randint(1,10)) - print("Password reset succesfully") - except (keyring.errors.PasswordSetError, Exception) as e: - print("Failed to reset password") - # print(e + "Contact the developers asap") diff --git a/config.ini b/config.ini index b3e5d51..655b93b 100644 --- a/config.ini +++ b/config.ini @@ -2,9 +2,15 @@ SERVICE_ID = taiga SERVICE_TOKEN = taiga_auth PID = 315827 # for test only - +DEFAULT_TAIGA_URL = teams.fedoraproject.org +CUSTOM_TAIGA_URL = https://api.taiga.io/api/v1/auth [PAGURE] SERVICE_ID = pagure -[BUGZILLA] \ No newline at end of file +[BUGZILLA] +SERVICE_ID = bugzilla +SERVICE_TOKEN = bugzilla_auth +PID = 315827 # for test only +DEFAULT_BUGZILLA_URL = https://bugzilla.redhat.com/ +CUSTOM_BUGZILLA_URL = https://bugzilla.redhat.com/ \ No newline at end of file diff --git a/convert.py b/convert.py index 517e29a..21a585b 100644 --- a/convert.py +++ b/convert.py @@ -5,7 +5,7 @@ import keyring import configparser config = configparser.ConfigParser() -confi.read('config.ini') +config.read('config.ini') service_id = config['TAIGA']['SERVICE_ID'] # service id service_token = config['TAIGA']['SERVICE_TOKEN'] @@ -17,10 +17,11 @@ with open('auth.txt', 'r') as a_file: # auth_t = token.encode("ascii", "ignore") # print(token) # debug only """ -keyring.get_password(service_id, username) +#keyring.get_password(service_id, username) headers = { 'Content-Type': 'application/json', - 'Authorization': 'Bearer {0}'.format(keyring.get_password(service_id, username)) + #'Authorization': 'Bearer {0}'.format(keyring.get_password(service_id, username)) + 'Authorization': 'Bearer {0}'.format(str(123)) } @@ -70,9 +71,3 @@ def convert(args): except Exception as e: print(e) -""" -curl -X GET \ --H "Content-Type: application/json" \ --H "Authorization: Bearer ${eyJ1c2VyX2F1dGhlbnRpY2F0aW9uX2lkIjozNTY4MDR9:1hI6pm:4d4mA-gUXC2S0FxaladX0Fd_3gA}" \ --s https://api.taiga.io/api/v1/issues/by_ref?ref=1\&project=315827 -""" \ No newline at end of file diff --git a/main.py b/main.py index cb21ea8..277cbce 100644 --- a/main.py +++ b/main.py @@ -4,7 +4,9 @@ import requests import json import argparse import sys -from auth import tauth +from auth import taiga_auth +from auth import pagure_auth +from auth import bugzilla_auth # import taiga from convert import convert @@ -36,25 +38,42 @@ class Change_Tool(object): # Subparser for taiga taiga = subparsers.add_parser('taiga', help='taiga auth module') taiga.add_argument('--token', action='store_true', help='refreshes the token') - taiga.add_argument('--reset', action='store_true', help='resets the user id and pass') + taiga.add_argument('--reset', action='store_true', help='sets/resets the user id and pass') # subparser for pagure pagure = subparsers.add_parser('pagure', help='pagure auth module') - pagure.add_argument('--token', action='store_true', help='refreshes the token') - pagure.add_argument('--reset', action='store_true', help='resets the user id and pass') + pagure.add_argument('--whoami', action='store_true', help='returns who the user is,for debug/developement only') + pagure.add_argument('--reset', action='store_true', help='resets the pagure token') # subparser for bugzilla bugzilla = subparsers.add_parser('bugzilla', help='bugzilla auth module') - bugzilla.add_argument('--token', action='store_true', help='refreshes the token') - bugzilla.add_argument('--reset', action='store_true', help='resets the user id and pass') + bugzilla.add_argument('--token', action='store_true', help='sets the the token for bugzilla') + bugzilla.add_argument('--reset', action='store_true', help='sets/resets the user id,pass and the api token') args = parser.parse_args(sys.argv[2:]) if args.auth: print("Incomplete command,please specify the auth") if args.command == 'taiga': if args.token: - tauth.refresh_token() + taiga_auth.refresh_token() elif args.reset: - tauth.reset() + taiga_auth.reset() + else: + print("Wrong command") + elif args.command == 'pagure': + if args.reset: + pagure_auth.reset() + else: + print("Wrong command") + elif args.command == 'bugzilla': + if args.token: + bugzilla_auth.refresh_token() + elif args.reset: + bugzilla_auth.reset() + else: + print("Wrong command,please check documentation for the proper command") + else: + print("Please Check the Documentation for the proper command or press --h for help") + # print("Running the auth instance.....") # authenticate() From d05e815673abe4580815db73bc5a2f15f64effe2 Mon Sep 17 00:00:00 2001 From: Ben Cotton Date: May 29 2019 17:30:35 +0000 Subject: [PATCH 5/71] Ignore .pyc files --- diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0d20b64 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.pyc From dce199b1cd68fb00109125b67b194103cf0736e3 Mon Sep 17 00:00:00 2001 From: Ben Cotton Date: May 29 2019 17:31:00 +0000 Subject: [PATCH 6/71] Remove .pyc files --- diff --git a/auth/__pycache__/__init__.cpython-36.pyc b/auth/__pycache__/__init__.cpython-36.pyc deleted file mode 100644 index e54dd9f..0000000 Binary files a/auth/__pycache__/__init__.cpython-36.pyc and /dev/null differ diff --git a/auth/__pycache__/taiga.cpython-36.pyc b/auth/__pycache__/taiga.cpython-36.pyc deleted file mode 100644 index e800c43..0000000 Binary files a/auth/__pycache__/taiga.cpython-36.pyc and /dev/null differ diff --git a/auth/__pycache__/tauth.cpython-36.pyc b/auth/__pycache__/tauth.cpython-36.pyc deleted file mode 100644 index c7f18ab..0000000 Binary files a/auth/__pycache__/tauth.cpython-36.pyc and /dev/null differ From 2c7fe700acf6842c9c4e3c5eea3a8019bacf54cd Mon Sep 17 00:00:00 2001 From: Manas Date: Jun 03 2019 16:17:12 +0000 Subject: [PATCH 7/71] rearranged functionality sample,email auth,email send structure,updated config. --- diff --git a/announce/mailing_list.py b/announce/mailing_list.py new file mode 100644 index 0000000..bbc951c --- /dev/null +++ b/announce/mailing_list.py @@ -0,0 +1,42 @@ +import smtplib +import ssl +import confifparser +import json +import keyring +import tga +import email.minie.multipart + +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'] +elif config['EMAIL']['TEST'] == 'no': + sender = config['EMAIL']['DEFAULT_EMAIL_ID] + receiver = config['EMAIL']['LIST'] +else: + print("please set proper test status in config") + + +def email_send(issueno): + port = config['EMAIL']['PORT'] # For SSL + smtp_server = config['EMAIL']['SMTP_SERVER'] + sender_email = sender # Enter your address + receiver_email = reciver # Enter receiver address + data = tga.userstory.get(issueno) + + try: + msg = email.mime.multipart.MIMEMultipart() + msg['to'] = reciver + msg['from'] = sender + msg['subject'] = data['subject'] + msg.add_header('reply-to', reciver_email[0]) + + msg.attach(MIMEText(body, data['description'])) + # This message is sent from Python.""" + + context = ssl.create_default_context() + with smtplib.SMTP_SSL(smtp_server, port, context=context) as server: + server.login(sender_email, password) + server.sendmail(sender_email, receiver_email, message) \ No newline at end of file diff --git a/auth/bugzilla_auth.py b/auth/bugzilla_auth.py index 6622177..61d1e74 100644 --- a/auth/bugzilla_auth.py +++ b/auth/bugzilla_auth.py @@ -15,17 +15,18 @@ service_token = config['BUGZILLA']['SERVICE_TOKEN'] # service d for auth bz_url = config['BUGZILLA']['DEFAULT_BUGZILLA_URL'] # taiga server note custom_bz = config['BUGZILLA']['CUSTOM_BUGZILLA_URL'] - +""" def refresh_token(): headers = { 'Content-Type': 'application/json' } - """ + + Used only for testing and Demo Encrypted Config file/Application token used in production. Doing the follwoing in prod is security risk. - """ + username = keyring.get_password(service_id, "username") # print(username) # debug only payload = { @@ -42,10 +43,10 @@ def refresh_token(): headers=headers) print(r.status_code) if r.status_code == 200: - """ + with open('auth.txt', 'w') as a_file: a_file.write(r.json()['auth_token']) - """ + try: keyring.set_password(service_token, "username", r.json()['auth_token']) print("succesful authentication") @@ -56,6 +57,8 @@ def refresh_token(): except Exception as e: print(e) +""" + def reset(): print("You User Id and password will be securly store in the Keyring") @@ -73,4 +76,4 @@ def reset(): # passwd = random.choices(string.ascii_uppercase + string.digits, k=random.randint(1,10)) print("Password and api key reset succesfully") except (keyring.errors.PasswordSetError, Exception) as e: - print("Failed to reset password & api key") + print("Failed to reset password & api key", e) diff --git a/auth/email_auth.py b/auth/email_auth.py new file mode 100644 index 0000000..3b4a9a7 --- /dev/null +++ b/auth/email_auth.py @@ -0,0 +1,24 @@ +def reset(): + print("You User Id and password will be securly store in the Keyring") + username = input("Enter your id: ") + password = getpass.getpass("Enter your password for taiga: ") + try: + # keyring.set_password("taiga", username) + """ + So a workaround to store username along with pass is being used + the only drawback ofthis work around is in the gui keyring broswer + a seperate username keyring will show,sadly this cannot be avoided + at the point of writing this peice of software + """ + """ + The above comment is not true + """ + keyring.set_password(service_id, "email_username", username) # refer line 67 + keyring.set_password(service_id, username, str(password)) + username = binascii.hexlify(os.urandom(20)) # randomising username to avoid sneak memory attacks + password = binascii.hexlify(os.urandom(20)) # ranomising pass to avoid sneak memory attacks + # username = random.choices(string.ascii_uppercase + string.digits, k=random.randint(1,10)) + # passwd = random.choices(string.ascii_uppercase + string.digits, k=random.randint(1,10)) + print("Password reset succesfully") + except (keyring.errors.PasswordSetError, Exception) as e: + print("Failed to reset password", e) diff --git a/auth/taiga_auth.py b/auth/taiga_auth.py index 271e0ed..e9ffc7c 100644 --- a/auth/taiga_auth.py +++ b/auth/taiga_auth.py @@ -6,38 +6,48 @@ import os import binascii import getpass import configparser +import keyring config = configparser.ConfigParser() config.read('config.ini') service_id = config['TAIGA']['SERVICE_ID'] # service id service_token = config['TAIGA']['SERVICE_TOKEN'] # service d for auth -taiga_url = config['TAIGA']['DEFAULT_TAIGA_URL'] # taiga server note -custom_taiga = config['TAIGA']['CUSTOM_TAIGA_URL'] +# taiga_url = config['TAIGA']['DEFAULT_TAIGA_URL'] # taiga server note +# custom_taiga = config['TAIGA']['CUSTOM_TAIGA_URL'] +pid = config['TAIGA']['PID'] +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") + + +headers = { + 'Content-Type': 'application/json', +} def refresh_token(): - headers = { - 'Content-Type': 'application/json' - } """ Used only for testing and Demo Encrypted Config file/Application token used in production. Doing the follwoing in prod is security risk. """ - username = keyring.get_password(service_id, "username") - # print(username) # debug only + username = keyring.get_password(service_id, "taiga_username") + print(username) # debug only payload = { 'type': 'normal', 'username': username, 'password': keyring.get_password(service_id, username) } - # print(payload) # only for debugging + print(payload) # only for debugging try: r = requests.post( - str(taiga_url) + "https://api.taiga.io/api/v1/auth", + str(taiga_url) + "/api/v1/auth", data=json.dumps(payload), headers=headers) print(r.status_code) @@ -47,13 +57,13 @@ def refresh_token(): a_file.write(r.json()['auth_token']) """ try: - keyring.set_password(service_token, "username", r.json()['auth_token']) + keyring.set_password(service_token, "taiga_token", r.json()['auth_token']) print("succesful authentication") except (keyring.errors.PasswordSetError, Exception) as e: print("Failed to set auth token") elif r.status_code == 400: print("auth error") - except Exception as e: + except requests.exceptions.RequestException as e: print(e) @@ -72,7 +82,7 @@ def reset(): """ The above comment is not true """ - #keyring.set_password(service_id, "username", username) refer line 67 + keyring.set_password(service_id, "taiga_username", username) # refer line 67 keyring.set_password(service_id, username, str(password)) username = binascii.hexlify(os.urandom(20)) # randomising username to avoid sneak memory attacks password = binascii.hexlify(os.urandom(20)) # ranomising pass to avoid sneak memory attacks diff --git a/config.ini b/config.ini index 655b93b..2180224 100644 --- a/config.ini +++ b/config.ini @@ -1,9 +1,22 @@ [TAIGA] SERVICE_ID = taiga SERVICE_TOKEN = taiga_auth -PID = 315827 # for test only -DEFAULT_TAIGA_URL = teams.fedoraproject.org -CUSTOM_TAIGA_URL = https://api.taiga.io/api/v1/auth +PID = 325363 # for test only +DEFAULT_TAIGA_URL = https://teams-api.fedoraproject.org +CUSTOM_TAIGA_URL = https://api.taiga.io +STATUS_ANNOUNCED = 29 +STATUS_R_FESCO = 30 +STATUS_ACCEPTED = 31 +STATUS_ARCHIVED = 32 +STATUS_CODE_COMPLETE = 33 +STATUS_TESTABLE = 34 +TEST_STATUS_ANNOUNCED = 1892835 +TEST_STATUS_R_FESCO = 1892836 +TEST_STATUS_ACCEPTED = 1892837 +TEST_STATUS_ARCHIVED = 1892838 +TEST_STATUS_CODE_COMPLETE = 1892839 +TEST_STATUS_TESTABLE = 1951329 +TEST = yes [PAGURE] SERVICE_ID = pagure @@ -13,4 +26,16 @@ SERVICE_ID = bugzilla SERVICE_TOKEN = bugzilla_auth PID = 315827 # for test only DEFAULT_BUGZILLA_URL = https://bugzilla.redhat.com/ -CUSTOM_BUGZILLA_URL = https://bugzilla.redhat.com/ \ No newline at end of file +CUSTOM_BUGZILLA_URL = https://bugzilla.redhat.com/ +TEST = no + +[EMAIL] +SERVICE_ID = email +DEFAULT_EMAIL_ID = bcotton@redhat.org +CUSTOM_EMAIL_ID = manasmangaonkar@gmail.com +TEST_LIST: [manas.man95@gmail.com,ttim3886@gmail.com] +LIST: [devel@lists.fedoraproject.org,devel-announce@lists.fedoraproject.org] +PORT = 465 +SMTP_SERVER = smtp.gmail.com +TEST = yes +1892835 \ No newline at end of file diff --git a/convert.py b/convert.py index 21a585b..0be6a24 100644 --- a/convert.py +++ b/convert.py @@ -10,6 +10,12 @@ config.read('config.ini') service_id = config['TAIGA']['SERVICE_ID'] # service id service_token = config['TAIGA']['SERVICE_TOKEN'] pid = config['TAIGA']['PID'] +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") """ with open('auth.txt', 'r') as a_file: @@ -17,12 +23,14 @@ with open('auth.txt', 'r') as a_file: # auth_t = token.encode("ascii", "ignore") # print(token) # debug only """ -#keyring.get_password(service_id, username) + +# username = keyring.get_password(service_id, "username") headers = { 'Content-Type': 'application/json', - #'Authorization': 'Bearer {0}'.format(keyring.get_password(service_id, username)) - 'Authorization': 'Bearer {0}'.format(str(123)) + 'Authorization': 'Bearer {0}'.format(keyring.get_password(service_id, "taiga_token")) + # 'Authorization': 'Bearer {0}'.format(str(123)) } +print(headers) # debug only def convert(args): @@ -30,7 +38,7 @@ def convert(args): for x in value: try: print(headers) # Debug only - url = "https://api.taiga.io/api/v1/issues/by_ref?ref=" + str(x) + "&project=" + str(pid) + url = str(taiga_url) + "/api/v1/issues/by_ref?ref=" + str(x) + "&project=" + str(pid) # debugurl = "https://api.taiga.io/api/v1/issues/by_ref" print(url) # debug/dev env only # print(debugurl) # Debug only @@ -53,12 +61,63 @@ def convert(args): # print(data) 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 + 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: + print("Failed to fetch attributes of the issue") + print(e) + payload = { 'project': pid, 'description': details, 'subject': subject } print("post object") + print(payload) r = requests.post( 'https://api.taiga.io/api/v1/userstories', data=json.dumps(payload), @@ -70,4 +129,3 @@ def convert(args): print("Authorization issues try reauthenticating") except Exception as e: print(e) - diff --git a/main.py b/main.py index 277cbce..3077d20 100644 --- a/main.py +++ b/main.py @@ -88,6 +88,22 @@ class Change_Tool(object): # print(args) # Debug only convert(args) + def announce(self): + parser = argparse.ArgumentParser( + description='announces to mailing list') + parser.add_argument('--ml', + nargs='+', + type=int, + help="Announces to Mailing list") + args = parser.parse_args(sys.argv[2:]) + # print(args) # debug only + mail(args) + """ + def accept(self): + parser = argparse.ArgumentParser( + description='accepts the proposal and pushes to bugzilla') + """ + if __name__ == "__main__": Change_Tool() diff --git a/notes/notes.txt b/notes/notes.txt new file mode 100644 index 0000000..9d24996 --- /dev/null +++ b/notes/notes.txt @@ -0,0 +1,38 @@ +status actual and testinstance +New: , 1892834 +Announced: 29 , 1892835 +Ready for fesco: 30 , 1892836 +Accepted: 31 , 1892837 +Archived: 32, 1892838 +Code Complete: 33 , 1892839 +Testable: 34 , 1951329 + +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 + +curl -X GET \ +-H "Content-Type: application/json" \ +-H "Authorization: Bearer ${eyJ1c2VyX2F1dGhlbnRpY2F0aW9uX2lkIjozNTY4MDR9:1hI6pm:4d4mA-gUXC2S0FxaladX0Fd_3gA}" \ +-s https://teams-api.fedoraproject.org/api/v1/issues/by_ref?ref=5\&project=5 +-s https://teams-api.fedoraproject.org/api/v1/issues/custom-attributes-values/{26} + +curl -X GET \ +-H "Content-Type: application/json" \ +-H "Authorization: Bearer ${eyJ1c2VyX2F1dGhlbnRpY2F0aW9uX2lkIjozNTY4MDR9:1hI6pm:4d4mA-gUXC2S0FxaladX0Fd_3gA}" \ +-s https://teams-api.fedoraproject.org/api/v1/issues/custom-attributes-values/{26} + +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 diff --git a/tga/userstory.py b/tga/userstory.py new file mode 100644 index 0000000..8c1d9ee --- /dev/null +++ b/tga/userstory.py @@ -0,0 +1,54 @@ +import configparser +import json + +config = configparser.ConfigParser() +config.read('config.ini') + + +def list_us(): + service_id = config['TAIGA']['SERVICE_ID'] # service id + service_token = config['TAIGA']['SERVICE_TOKEN'] + pid = config['TAIGA']['PID'] + if config['TAIGA']['TEST'] == 'yes': + taiga_url = config['TAIGA']['CUSTOM_TAIGA_URL'] + status = config['TAIGA']['STATUS_R_FESCO'] + elif config['TAIGA']['TEST'] == 'no': + taiga_url = config['TAIGA']['DEFAULT_TAIGA_URL'] + status = config['TAIGA']['STATUS'] + else: + print("please set test status in config") + + try: + url = str(taiga_url) + "/api/v1/issues/userstories?project=" + str(pid) + "\&status=" + str(status) + # url = str(taiga_url) + "/api/v1/userstories?project=1" + print(url) # Debug only + try: + r = requests.get( + url, + headers=headers, + ) + if r.status_code == 200: + data = json.loads(r.content) + for item in data: + d_list = item['due_date']['tags']['subject'] + for item in data['owner_extra_info']: + owner = item['username'] + print(dlist, owner) + print("Finished Listing") + except requests.exceptions.RequestException at e: + print(e) + + +def get_us(): + service_id = config['TAIGA']['SERVICE_ID'] # service id + service_token = config['TAIGA']['SERVICE_TOKEN'] + pid = config['TAIGA']['PID'] + if config['TAIGA']['TEST'] == 'yes': + taiga_url = config['TAIGA']['CUSTOM_TAIGA_URL'] + status = config['TAIGA']['STATUS_R_FESCO'] + elif config['TAIGA']['TEST'] == 'no': + taiga_url = config['TAIGA']['DEFAULT_TAIGA_URL'] + status = config['TAIGA']['STATUS'] + else: + print("please set test status in config") + \ No newline at end of file From 0204ffe7507c89f0c66255b2241ff250c3d25579 Mon Sep 17 00:00:00 2001 From: Manas Date: Jun 04 2019 16:38:30 +0000 Subject: [PATCH 8/71] 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) From 456147792a6c6d25699f8ebcd8ddd8e8806feac3 Mon Sep 17 00:00:00 2001 From: Manas Date: Jun 04 2019 16:39:10 +0000 Subject: [PATCH 9/71] taiga user story functionality modules created. --- diff --git a/tga/userstory.py b/tga/userstory.py index 8c1d9ee..2ff90df 100644 --- a/tga/userstory.py +++ b/tga/userstory.py @@ -4,8 +4,21 @@ import json config = configparser.ConfigParser() config.read('config.ini') +service_id = config['TAIGA']['SERVICE_ID'] # service id +service_token = config['TAIGA']['SERVICE_TOKEN'] +pid = config['TAIGA']['PID'] +if config['TAIGA']['TEST'] == 'yes': + taiga_url = config['TAIGA']['CUSTOM_TAIGA_URL'] + status = config['TAIGA']['STATUS_R_FESCO'] +elif config['TAIGA']['TEST'] == 'no': + taiga_url = config['TAIGA']['DEFAULT_TAIGA_URL'] + status = config['TAIGA']['STATUS'] +else: + print("please set test status in config") + def list_us(): + """ service_id = config['TAIGA']['SERVICE_ID'] # service id service_token = config['TAIGA']['SERVICE_TOKEN'] pid = config['TAIGA']['PID'] @@ -17,6 +30,7 @@ def list_us(): status = config['TAIGA']['STATUS'] else: print("please set test status in config") + """ try: url = str(taiga_url) + "/api/v1/issues/userstories?project=" + str(pid) + "\&status=" + str(status) @@ -40,6 +54,7 @@ def list_us(): def get_us(): + """ service_id = config['TAIGA']['SERVICE_ID'] # service id service_token = config['TAIGA']['SERVICE_TOKEN'] pid = config['TAIGA']['PID'] @@ -51,4 +66,32 @@ def get_us(): status = config['TAIGA']['STATUS'] else: print("please set test status in config") - \ No newline at end of file + """ + + +def post_us(args): + for _, value in args._get_kwargs(): # iteratingover name space object + for x in value: + try: + r = requests.post( + 'https://api.taiga.io/api/v1/userstories', + data=json.dumps(x), + headers=headers + ) + return r + except requests.exceptions.RequestException at e: + print(e) + + +def post_us_ca(args, id): + or _, value in args._get_kwargs(): # iteratingover name space object + for x in value: + try: + r = requests.post( + 'https://api.taiga.io/api/v1/userstories' + str(id), + data=json.dumps(x), + headers=headers + ) + return r + except requests.exceptions.RequestException at e: + print(e) \ No newline at end of file From 6dbbd811e2ec420cdb7b7ab53b035c956b21eb2d Mon Sep 17 00:00:00 2001 From: Manas Date: Jun 05 2019 13:50:34 +0000 Subject: [PATCH 10/71] taiga to user story conversion working 99% --- diff --git a/convert.py b/convert.py index b15f928..371b572 100644 --- a/convert.py +++ b/convert.py @@ -3,6 +3,8 @@ import requests import json import keyring import configparser +from tga import issues as tgaissue +from tga import userstory as tgauserstory config = configparser.ConfigParser() config.read('config.ini') @@ -25,22 +27,24 @@ with open('auth.txt', 'r') as a_file: """ # username = keyring.get_password(service_id, "username") +""" headers = { 'Content-Type': 'application/json', 'Authorization': 'Bearer {0}'.format(keyring.get_password(service_id, "taiga_token")) # 'Authorization': 'Bearer {0}'.format(str(123)) } print(headers) # debug only +""" def convert(args): for _, value in args._get_kwargs(): # iteratingover name space object for x in value: try: - print(headers) # Debug only - url = str(taiga_url) + "/api/v1/issues/by_ref?ref=" + str(x) + "&project=" + str(pid) + #print(headers) # Debug only + #url = str(taiga_url) + "/api/v1/issues/by_ref?ref=" + str(x) + "&project=" + str(pid) # debugurl = "https://api.taiga.io/api/v1/issues/by_ref" - print(url) # debug/dev env only + #print(url) # debug/dev env only # print(debugurl) # Debug only # ino = str(x) + '/' """ @@ -49,7 +53,7 @@ def convert(args): ('project', str(pid)), ) """ - r = tga.is_get(x) # gets the issue + r = tgaissue.issue_get(x) # gets the issue """ r = requests.get( url, @@ -61,10 +65,12 @@ def convert(args): # print("get object",r.json()) # Debug/Dev env only if r.status_code == 200: data = json.loads(r.content) - # print(data) + print(data) details = data['description'] subject = data['subject'] - id = data['id'] # fetch the id as well + issue_id = data['id'] # fetch the id as well + #print(issue_id) + print("Step 1") """ try: Because issue id is required to get custom attributes @@ -83,70 +89,94 @@ def convert(args): ) """ 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'] + r = tgaissue.issue_caget(issue_id) + if r.status_code == 200: + data = json.loads(r.content) + print(data, "step 2") + #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("summary", summary) + #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 = { - ['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 + 'project': pid, + 'description': details, + 'subject': subject } - r = tga.post_us_ca(payload, id) - if r.status_code == 200: - print("Sucessfully converted issue to user story") + #print(payload) + r = tgauserstory.post_us(payload) + print(json.loads(r.content)) + #print(r.status_code) + if r.status_code == 201: + print("step 3") + data = json.loads(r.content) + id = data['id'] + print(id) + payload = { + "attributes_values": { + config['TAIGA']['TEST_US_CA_SYSTEM_WIDE_CHANGE']: system_wide_change, + config['TAIGA']['TEST_US_CA_SUMMARY']: summary, + config['TAIGA']['TEST_US_CA_RELENG_TICKET']: relengticket, + config['TAIGA']['TEST_US_CA_TRADEMARK_APPROVAL']: approval_required, + #config['TAIGA']['TEST_US_CA_OWNERS']: owners, + config['TAIGA']['TEST_US_CA_FESCO_TICKET']: 'random', + config['TAIGA']['TEST_US_CA_BUGZILLA_TRACKER']: 'random', + config['TAIGA']['TEST_US_CA_BUGZILLA_CONTACT']: bugzilla_id, + config['TAIGA']['TEST_US_CA_RELEASE_NOTES']: 'random', + config['TAIGA']['TEST_US_CA_CONTINGENCY']: contingency_deadline, + config['TAIGA']['TEST_US_CA_MASS_REBUILD']: mass_rebuild, + config['TAIGA']['TEST_US_CA_POLICY_CHANGE']: policy_change, + config['TAIGA']['TEST_US_CA_MODIFIES_DELIVERABLES']: modifies_deliverables + }, + "version": 1 + } + print(payload) + r = tgauserstory.post_usca(payload, id) + print(json.loads(r.content)) + print(r.status_code) + if r.status_code == 200: + print("Sucessfully converted issue to user story") + r = tgaissue.issue_close(issue_id) + print(r.status_code) + #print(json.loads(r.content)) + if r.status_code == 200: + print("Sucessfully closed issue") + else: + print("Unsuccesful at closing issue,check logs") + else: + print("Unsuccesful Conversion") else: print("Unsuccesful conversion") - except requests.exceptions.RequestException at e: - print(e) + except requests.exceptions.RequestException as e: + print(e) + else: + print("Unsuccesful Conversion") except requests.exceptions.RequestException as e: print("Failed to fetch attributes of the issue") print(e) @@ -157,10 +187,8 @@ def convert(args): 'subject': subject } """ - # print(payload) - - # print("post object") - + # print(payload) + # print("post object") """ r = requests.post( 'https://api.taiga.io/api/v1/userstories', @@ -168,7 +196,9 @@ def convert(args): headers=headers ) """ + else: + print("Unable to Convert Issue,Check logs and contact the developer", json.loads(r.content)) except Exception as e: print(e) - except requests.exceptions.RequestException at e: + except requests.exceptions.RequestException as e: print(e) From d3d87e7a0533b4aaf632a2b14c653f2112da2019 Mon Sep 17 00:00:00 2001 From: Manas Date: Jun 05 2019 13:54:28 +0000 Subject: [PATCH 11/71] user story functions typo fixed --- diff --git a/tga/userstory.py b/tga/userstory.py index 2ff90df..7db907f 100644 --- a/tga/userstory.py +++ b/tga/userstory.py @@ -1,5 +1,7 @@ import configparser import json +import keyring +import requests config = configparser.ConfigParser() config.read('config.ini') @@ -9,13 +11,20 @@ service_token = config['TAIGA']['SERVICE_TOKEN'] pid = config['TAIGA']['PID'] if config['TAIGA']['TEST'] == 'yes': taiga_url = config['TAIGA']['CUSTOM_TAIGA_URL'] - status = config['TAIGA']['STATUS_R_FESCO'] + status = config['TAIGA']['TEST_US_STATUS_R_FESCO'] elif config['TAIGA']['TEST'] == 'no': taiga_url = config['TAIGA']['DEFAULT_TAIGA_URL'] status = config['TAIGA']['STATUS'] else: print("please set test status in config") +# username = keyring.get_password(service_id, "username") +headers = { + 'Content-Type': 'application/json', + 'Authorization': 'Bearer {0}'.format(keyring.get_password(service_token, "taiga_token")) + # 'Authorization': 'Bearer {0}'.format(str(123)) +} + def list_us(): """ @@ -39,7 +48,7 @@ def list_us(): try: r = requests.get( url, - headers=headers, + headers=headers ) if r.status_code == 200: data = json.loads(r.content) @@ -49,12 +58,13 @@ def list_us(): owner = item['username'] print(dlist, owner) print("Finished Listing") - except requests.exceptions.RequestException at e: + except requests.exceptions.RequestException as e: print(e) + except Exception as e: + print(e) - +""" def get_us(): - """ service_id = config['TAIGA']['SERVICE_ID'] # service id service_token = config['TAIGA']['SERVICE_TOKEN'] pid = config['TAIGA']['PID'] @@ -66,32 +76,33 @@ def get_us(): status = config['TAIGA']['STATUS'] else: print("please set test status in config") - """ +""" -def post_us(args): - for _, value in args._get_kwargs(): # iteratingover name space object - for x in value: - try: - r = requests.post( - 'https://api.taiga.io/api/v1/userstories', - data=json.dumps(x), - headers=headers - ) - return r - except requests.exceptions.RequestException at e: - print(e) +def post_us(x): + #for _, value in args._get_kwargs(): # iteratingover name space object + #for x in value: + try: + r = requests.post( + 'https://api.taiga.io/api/v1/userstories', + data=json.dumps(x), + headers=headers + ) + return r + except requests.exceptions.RequestException as e: + print(e) -def post_us_ca(args, id): - or _, value in args._get_kwargs(): # iteratingover name space object - for x in value: - try: - r = requests.post( - 'https://api.taiga.io/api/v1/userstories' + str(id), - data=json.dumps(x), - headers=headers - ) - return r - except requests.exceptions.RequestException at e: - print(e) \ No newline at end of file +def post_usca(x, id): + #for _, value in args._get_kwargs(): # iteratingover name space object + #for x in value: + try: + r = requests.patch( + 'https://api.taiga.io/api/v1/userstories/custom-attributes-values/' + str(id), + data=json.dumps(x), + headers=headers + ) + print(json.loads(r.content)) + return r + except requests.exceptions.RequestException as e: + print(e) From 28c85d65245221c406cc09a7adee211835cf7531 Mon Sep 17 00:00:00 2001 From: Manas Date: Jun 05 2019 13:55:58 +0000 Subject: [PATCH 12/71] issues module working,typos fixed --- diff --git a/tga/issues.py b/tga/issues.py new file mode 100644 index 0000000..8cdb08b --- /dev/null +++ b/tga/issues.py @@ -0,0 +1,79 @@ +import json +import configparser +import keyring +import requests + +config = configparser.ConfigParser() +config.read('config.ini') + +service_id = config['TAIGA']['SERVICE_ID'] # service id +service_token = config['TAIGA']['SERVICE_TOKEN'] +pid = config['TAIGA']['PID'] +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") + +headers = { + 'Content-Type': 'application/json', + 'Authorization': 'Bearer {0}'.format(keyring.get_password(service_token, "taiga_token")) + # 'Authorization': 'Bearer {0}'.format(str(123)) +} + + +def issue_get(x): + # iteratingover name space object + try: + print(headers) # Debug only + print(x) + url = str(taiga_url) + "/api/v1/issues/by_ref?ref=" + str(x) + "&project=" + str(pid) + # debugurl = "https://api.taiga.io/api/v1/issues/by_ref" + print(url) # debug/dev env only + r = requests.get( + url, + # debugurl, + headers=headers + # params=params + ) + return r + except requests.exceptions.RequestException as e: + print(e) + + +def issue_caget(x): + """ + Gets custom attributes from taiga for issue + """ + #$for _, value in args._get_kwargs(): # iteratingover name space object + + print(x) + id_url = str(taiga_url) + "/api/v1/issues/custom-attributes-values/" + str(x) # x is id + print(id_url) + try: + r = requests.get( + id_url, + headers=headers + ) + return r + except requests.exceptions.RequestException as e: + print(e) + + +def issue_close(x): + #for _, value in args._get_kwargs(): # iteratingover name space object + id_url = str(taiga_url) + "/api/v1/issues/" + str(x) # x is id + payload = { + 'is_closed': 'true', + 'version': 1 + } + try: + r = requests.patch( + id_url, + data=json.dumps(payload), + headers=headers + ) + return r + except requests.exceptions.RequestException as e: + print(e) From 67c9f81aa1a398800cdbe3486c28b152469daa90 Mon Sep 17 00:00:00 2001 From: Manas Date: Jun 06 2019 11:49:31 +0000 Subject: [PATCH 13/71] Epics in conversion ,working before cleanup --- diff --git a/convert.py b/convert.py index 371b572..ed25789 100644 --- a/convert.py +++ b/convert.py @@ -3,6 +3,7 @@ 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 @@ -11,7 +12,7 @@ config.read('config.ini') service_id = config['TAIGA']['SERVICE_ID'] # service id service_token = config['TAIGA']['SERVICE_TOKEN'] -pid = config['TAIGA']['PID'] +project_id = config['TAIGA']['PROJECT_ID'] if config['TAIGA']['TEST'] == 'yes': taiga_url = config['TAIGA']['CUSTOM_TAIGA_URL'] elif config['TAIGA']['TEST'] == 'no': @@ -42,7 +43,7 @@ def convert(args): for x in value: try: #print(headers) # Debug only - #url = str(taiga_url) + "/api/v1/issues/by_ref?ref=" + str(x) + "&project=" + str(pid) + #url = str(taiga_url) + "/api/v1/issues/by_ref?ref=" + str(x) + "&project=" + str(project_id) # debugurl = "https://api.taiga.io/api/v1/issues/by_ref" #print(url) # debug/dev env only # print(debugurl) # Debug only @@ -50,7 +51,7 @@ def convert(args): """ params = ( ('ref', ino), - ('project', str(pid)), + ('project', str(project_id)), ) """ r = tgaissue.issue_get(x) # gets the issue @@ -65,10 +66,11 @@ def convert(args): # print("get object",r.json()) # Debug/Dev env only if r.status_code == 200: data = json.loads(r.content) - print(data) + print(data, "this is issue data") details = data['description'] subject = data['subject'] - issue_id = data['id'] # fetch the id as well + issue_id = data['id'] + issue_version = data['version'] # fetch the id as well #print(issue_id) print("Step 1") """ @@ -98,13 +100,15 @@ def convert(args): summary = data['attributes_values']['11372'] bugzilla_id = data['attributes_values']['11373'] approval_required = data['attributes_values']['11374'] - #owners = data['attributes_values']['11375'] + 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(fedora_version) #print("summary", summary) #print(bugzilla_id) print("Fetched Custom Attributes") @@ -125,18 +129,19 @@ def convert(args): """ try: payload = { - 'project': pid, + 'project': project_id, 'description': details, 'subject': subject } #print(payload) r = tgauserstory.post_us(payload) - print(json.loads(r.content)) + #print(json.loads(r.content)) + data = json.loads(r.content) #print(r.status_code) if r.status_code == 201: print("step 3") data = json.loads(r.content) - id = data['id'] + us_id = data['id'] print(id) payload = { "attributes_values": { @@ -157,18 +162,36 @@ def convert(args): "version": 1 } print(payload) - r = tgauserstory.post_usca(payload, id) + r = tgauserstory.post_usca(payload, us_id) print(json.loads(r.content)) print(r.status_code) if r.status_code == 200: print("Sucessfully converted issue to user story") - r = tgaissue.issue_close(issue_id) - print(r.status_code) - #print(json.loads(r.content)) - if r.status_code == 200: - print("Sucessfully closed issue") - else: - print("Unsuccesful at closing issue,check logs") + try: + r = tgaepic.list_epic() + data = json.loads(r.content) + if r.status_code == 200: + for i in data: + if i['subject'] == str(fedora_version): + epicid = i['id'] + epicref = i['ref'] + break + + r = tgaepic.post_relatedus(us_id, epicid, epicref) + if r.status_code == 201: + print("Sucessfully mapped epics") + r = tgaissue.issue_close(issue_id, issue_version) + print(r.status_code) + print(r.content) + #print(json.loads(r.content)) + if r.status_code == 200: + print("Sucessfully closed issue") + else: + print("Unsuccesful at closing issue,check logs") + else: + print("Unnsucessful conversion please check logs") + except requests.exceptions.RequestException as e: + print(e) else: print("Unsuccesful Conversion") else: @@ -182,7 +205,7 @@ def convert(args): print(e) """ payload = { - 'project': pid, + 'project': project_id, 'description': details, 'subject': subject } diff --git a/tga/issues.py b/tga/issues.py index 8cdb08b..7fa4444 100644 --- a/tga/issues.py +++ b/tga/issues.py @@ -8,7 +8,7 @@ config.read('config.ini') service_id = config['TAIGA']['SERVICE_ID'] # service id service_token = config['TAIGA']['SERVICE_TOKEN'] -pid = config['TAIGA']['PID'] +project_id = config['TAIGA']['PROJECT_ID'] if config['TAIGA']['TEST'] == 'yes': taiga_url = config['TAIGA']['CUSTOM_TAIGA_URL'] elif config['TAIGA']['TEST'] == 'no': @@ -28,7 +28,7 @@ def issue_get(x): try: print(headers) # Debug only print(x) - url = str(taiga_url) + "/api/v1/issues/by_ref?ref=" + str(x) + "&project=" + str(pid) + url = str(taiga_url) + "/api/v1/issues/by_ref?ref=" + str(x) + "&project=" + str(project_id) # debugurl = "https://api.taiga.io/api/v1/issues/by_ref" print(url) # debug/dev env only r = requests.get( @@ -61,12 +61,12 @@ def issue_caget(x): print(e) -def issue_close(x): +def issue_close(x, issue_version): #for _, value in args._get_kwargs(): # iteratingover name space object id_url = str(taiga_url) + "/api/v1/issues/" + str(x) # x is id payload = { - 'is_closed': 'true', - 'version': 1 + 'status': config['TAIGA']['TEST_IS_STATUS_PROCESSED'], + 'version': issue_version } try: r = requests.patch( diff --git a/tga/userstory.py b/tga/userstory.py index 7db907f..c38e694 100644 --- a/tga/userstory.py +++ b/tga/userstory.py @@ -8,7 +8,7 @@ config.read('config.ini') service_id = config['TAIGA']['SERVICE_ID'] # service id service_token = config['TAIGA']['SERVICE_TOKEN'] -pid = config['TAIGA']['PID'] +project_id = config['TAIGA']['PROJECT_ID'] if config['TAIGA']['TEST'] == 'yes': taiga_url = config['TAIGA']['CUSTOM_TAIGA_URL'] status = config['TAIGA']['TEST_US_STATUS_R_FESCO'] @@ -30,7 +30,7 @@ def list_us(): """ service_id = config['TAIGA']['SERVICE_ID'] # service id service_token = config['TAIGA']['SERVICE_TOKEN'] - pid = config['TAIGA']['PID'] + project_id = config['TAIGA']['project_id'] if config['TAIGA']['TEST'] == 'yes': taiga_url = config['TAIGA']['CUSTOM_TAIGA_URL'] status = config['TAIGA']['STATUS_R_FESCO'] @@ -42,7 +42,7 @@ def list_us(): """ try: - url = str(taiga_url) + "/api/v1/issues/userstories?project=" + str(pid) + "\&status=" + str(status) + url = str(taiga_url) + "/api/v1/issues/userstories?project=" + str(project_id) + "\&status=" + str(status) # url = str(taiga_url) + "/api/v1/userstories?project=1" print(url) # Debug only try: @@ -67,7 +67,7 @@ def list_us(): def get_us(): service_id = config['TAIGA']['SERVICE_ID'] # service id service_token = config['TAIGA']['SERVICE_TOKEN'] - pid = config['TAIGA']['PID'] + project_id = config['TAIGA']['project_id'] if config['TAIGA']['TEST'] == 'yes': taiga_url = config['TAIGA']['CUSTOM_TAIGA_URL'] status = config['TAIGA']['STATUS_R_FESCO'] From 5ed91eaeba14f87faf7ad7467987072ceef5325b Mon Sep 17 00:00:00 2001 From: Manas Date: Jun 06 2019 13:55:16 +0000 Subject: [PATCH 14/71] epics module , list epics and link user story to epics --- diff --git a/tga/epics.py b/tga/epics.py new file mode 100644 index 0000000..7d5837f --- /dev/null +++ b/tga/epics.py @@ -0,0 +1,55 @@ +import json +import configparser +import keyring +import requests + +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'] + status = config['TAIGA']['TEST_US_STATUS_R_FESCO'] +elif config['TAIGA']['TEST'] == 'no': + taiga_url = config['TAIGA']['DEFAULT_TAIGA_URL'] + status = config['TAIGA']['STATUS'] +else: + print("please set test status in config") + +headers = { + 'Content-Type': 'application/json', + 'Authorization': 'Bearer {0}'.format(keyring.get_password(service_token, "taiga_token")) + # 'Authorization': 'Bearer {0}'.format(str(123)) +} + + +def list_epic(): + try: + url = str(taiga_url) + "/api/v1/epics?project=" + str(project_id) + r = requests.get( + url, + headers=headers + ) + return r + except requests.exceptions.RequestException as e: + print(e) + + +def post_relatedus(us_id, epicid, epicref): + #for _, value in args._get_kwargs(): # iteratingover name space object + #for x in value: + try: + payload = { + "epic": epicid, + "user_story": us_id + } + r = requests.post( + 'https://api.taiga.io/api/v1/epics/' + str(epicid) + '/related_userstories', + data=json.dumps(payload), + headers=headers + ) + return r + except requests.exceptions.RequestException as e: + print(e) From 16101f1cea95998a25f758bcbebe4af2ae3a073b Mon Sep 17 00:00:00 2001 From: Manas Date: Jun 06 2019 16:52:12 +0000 Subject: [PATCH 15/71] code cleanup --- diff --git a/convert.py b/convert.py index ed25789..cafe049 100644 --- a/convert.py +++ b/convert.py @@ -20,50 +20,12 @@ elif config['TAIGA']['TEST'] == 'no': else: print("please set test status in config") -""" -with open('auth.txt', 'r') as a_file: - token = - # auth_t = token.encode("ascii", "ignore") - # print(token) # debug only -""" - -# username = keyring.get_password(service_id, "username") -""" -headers = { - 'Content-Type': 'application/json', - 'Authorization': 'Bearer {0}'.format(keyring.get_password(service_id, "taiga_token")) - # 'Authorization': 'Bearer {0}'.format(str(123)) -} -print(headers) # debug only -""" - def convert(args): for _, value in args._get_kwargs(): # iteratingover name space object for x in value: try: - #print(headers) # Debug only - #url = str(taiga_url) + "/api/v1/issues/by_ref?ref=" + str(x) + "&project=" + str(project_id) - # debugurl = "https://api.taiga.io/api/v1/issues/by_ref" - #print(url) # debug/dev env only - # print(debugurl) # Debug only - # ino = str(x) + '/' - """ - params = ( - ('ref', ino), - ('project', str(project_id)), - ) - """ r = tgaissue.issue_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) print(data, "this is issue data") @@ -203,25 +165,10 @@ def convert(args): except requests.exceptions.RequestException as e: print("Failed to fetch attributes of the issue") print(e) - """ - payload = { - 'project': project_id, - 'description': details, - 'subject': subject - } - """ - # print(payload) - # print("post object") - """ - r = requests.post( - 'https://api.taiga.io/api/v1/userstories', - data=json.dumps(payload), - headers=headers - ) - """ else: print("Unable to Convert Issue,Check logs and contact the developer", json.loads(r.content)) except Exception as e: print(e) except requests.exceptions.RequestException as e: print(e) + diff --git a/main.py b/main.py index 3077d20..de2b461 100644 --- a/main.py +++ b/main.py @@ -7,7 +7,6 @@ import sys from auth import taiga_auth from auth import pagure_auth from auth import bugzilla_auth -# import taiga from convert import convert diff --git a/tga/epics.py b/tga/epics.py index 7d5837f..db2582d 100644 --- a/tga/epics.py +++ b/tga/epics.py @@ -21,7 +21,6 @@ else: headers = { 'Content-Type': 'application/json', 'Authorization': 'Bearer {0}'.format(keyring.get_password(service_token, "taiga_token")) - # 'Authorization': 'Bearer {0}'.format(str(123)) } @@ -38,8 +37,6 @@ def list_epic(): def post_relatedus(us_id, epicid, epicref): - #for _, value in args._get_kwargs(): # iteratingover name space object - #for x in value: try: payload = { "epic": epicid, diff --git a/tga/issues.py b/tga/issues.py index 7fa4444..22a7e1f 100644 --- a/tga/issues.py +++ b/tga/issues.py @@ -24,18 +24,13 @@ headers = { def issue_get(x): - # iteratingover name space object try: - print(headers) # Debug only - print(x) url = str(taiga_url) + "/api/v1/issues/by_ref?ref=" + str(x) + "&project=" + str(project_id) - # debugurl = "https://api.taiga.io/api/v1/issues/by_ref" + print(url) # debug/dev env only r = requests.get( url, - # debugurl, headers=headers - # params=params ) return r except requests.exceptions.RequestException as e: @@ -46,8 +41,6 @@ def issue_caget(x): """ Gets custom attributes from taiga for issue """ - #$for _, value in args._get_kwargs(): # iteratingover name space object - print(x) id_url = str(taiga_url) + "/api/v1/issues/custom-attributes-values/" + str(x) # x is id print(id_url) @@ -62,7 +55,6 @@ def issue_caget(x): def issue_close(x, issue_version): - #for _, value in args._get_kwargs(): # iteratingover name space object id_url = str(taiga_url) + "/api/v1/issues/" + str(x) # x is id payload = { 'status': config['TAIGA']['TEST_IS_STATUS_PROCESSED'], diff --git a/tga/userstory.py b/tga/userstory.py index c38e694..cdba0ac 100644 --- a/tga/userstory.py +++ b/tga/userstory.py @@ -18,32 +18,16 @@ elif config['TAIGA']['TEST'] == 'no': else: print("please set test status in config") -# username = keyring.get_password(service_id, "username") + headers = { 'Content-Type': 'application/json', 'Authorization': 'Bearer {0}'.format(keyring.get_password(service_token, "taiga_token")) - # 'Authorization': 'Bearer {0}'.format(str(123)) } def list_us(): - """ - 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'] - status = config['TAIGA']['STATUS_R_FESCO'] - elif config['TAIGA']['TEST'] == 'no': - taiga_url = config['TAIGA']['DEFAULT_TAIGA_URL'] - status = config['TAIGA']['STATUS'] - else: - print("please set test status in config") - """ - try: url = str(taiga_url) + "/api/v1/issues/userstories?project=" + str(project_id) + "\&status=" + str(status) - # url = str(taiga_url) + "/api/v1/userstories?project=1" print(url) # Debug only try: r = requests.get( @@ -63,25 +47,8 @@ def list_us(): except Exception as e: print(e) -""" -def get_us(): - 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'] - status = config['TAIGA']['STATUS_R_FESCO'] - elif config['TAIGA']['TEST'] == 'no': - taiga_url = config['TAIGA']['DEFAULT_TAIGA_URL'] - status = config['TAIGA']['STATUS'] - else: - print("please set test status in config") -""" - def post_us(x): - #for _, value in args._get_kwargs(): # iteratingover name space object - #for x in value: try: r = requests.post( 'https://api.taiga.io/api/v1/userstories', @@ -94,8 +61,6 @@ def post_us(x): def post_usca(x, id): - #for _, value in args._get_kwargs(): # iteratingover name space object - #for x in value: try: r = requests.patch( 'https://api.taiga.io/api/v1/userstories/custom-attributes-values/' + str(id), From 94ab903a5016e1fe8d0dbcce4659c38749522707 Mon Sep 17 00:00:00 2001 From: Manas Date: Jun 06 2019 18:08:49 +0000 Subject: [PATCH 16/71] auth code cleanup --- diff --git a/auth/bugzilla_auth.py b/auth/bugzilla_auth.py index 61d1e74..ae5603c 100644 --- a/auth/bugzilla_auth.py +++ b/auth/bugzilla_auth.py @@ -16,50 +16,12 @@ bz_url = config['BUGZILLA']['DEFAULT_BUGZILLA_URL'] # taiga server note custom_bz = config['BUGZILLA']['CUSTOM_BUGZILLA_URL'] """ -def refresh_token(): - headers = { - 'Content-Type': 'application/json' - } - - - Used only for testing and Demo - Encrypted Config file/Application token - used in production. - Doing the follwoing in prod is security risk. - - username = keyring.get_password(service_id, "username") - # print(username) # debug only - payload = { - 'type': 'normal', - 'username': username, - 'password': keyring.get_password(service_id, username) - } - # print(payload) # only for debugging - - try: - r = requests.post( - str(taiga_url) + "https://api.taiga.io/api/v1/auth", - data=json.dumps(payload), - headers=headers) - print(r.status_code) - if r.status_code == 200: - - with open('auth.txt', 'w') as a_file: - a_file.write(r.json()['auth_token']) - - try: - keyring.set_password(service_token, "username", r.json()['auth_token']) - print("succesful authentication") - except (keyring.errors.PasswordSetError, Exception) as e: - print("Failed to set auth token") - elif r.status_code == 400: - print("auth error") - except Exception as e: - print(e) - +bugzilla uses a api key to enable the api acess +Currently there is a xml-rpc method to acess +That method is going to be deprecated soon +Thus the latest method uses API key to acess +the api token.is sued by the modern rest api """ - - def reset(): print("You User Id and password will be securly store in the Keyring") username = input("Enter your user id for bugzilla: ") diff --git a/auth/email_auth.py b/auth/email_auth.py index 3b4a9a7..edbfa6b 100644 --- a/auth/email_auth.py +++ b/auth/email_auth.py @@ -3,22 +3,10 @@ def reset(): username = input("Enter your id: ") password = getpass.getpass("Enter your password for taiga: ") try: - # keyring.set_password("taiga", username) - """ - So a workaround to store username along with pass is being used - the only drawback ofthis work around is in the gui keyring broswer - a seperate username keyring will show,sadly this cannot be avoided - at the point of writing this peice of software - """ - """ - The above comment is not true - """ keyring.set_password(service_id, "email_username", username) # refer line 67 keyring.set_password(service_id, username, str(password)) username = binascii.hexlify(os.urandom(20)) # randomising username to avoid sneak memory attacks password = binascii.hexlify(os.urandom(20)) # ranomising pass to avoid sneak memory attacks - # username = random.choices(string.ascii_uppercase + string.digits, k=random.randint(1,10)) - # passwd = random.choices(string.ascii_uppercase + string.digits, k=random.randint(1,10)) print("Password reset succesfully") except (keyring.errors.PasswordSetError, Exception) as e: print("Failed to reset password", e) diff --git a/auth/pagure_auth.py b/auth/pagure_auth.py index 0f36322..dfe3ebb 100644 --- a/auth/pagure_auth.py +++ b/auth/pagure_auth.py @@ -11,14 +11,6 @@ config = configparser.ConfigParser() config.read('config.ini') -""" -def refresh_token(): - headers = { - 'Content-Type': 'application/json' - } -""" - - def reset(): print("Your auth token will be securly store in the Keyring") # username = input("Enter your user id for taiga: ") diff --git a/auth/taiga_auth.py b/auth/taiga_auth.py index e9ffc7c..f046771 100644 --- a/auth/taiga_auth.py +++ b/auth/taiga_auth.py @@ -15,7 +15,7 @@ service_id = config['TAIGA']['SERVICE_ID'] # service id service_token = config['TAIGA']['SERVICE_TOKEN'] # service d for auth # taiga_url = config['TAIGA']['DEFAULT_TAIGA_URL'] # taiga server note # custom_taiga = config['TAIGA']['CUSTOM_TAIGA_URL'] -pid = config['TAIGA']['PID'] +project_id = config['TAIGA']['PROJECT_ID'] if config['TAIGA']['TEST'] == 'yes': taiga_url = config['TAIGA']['CUSTOM_TAIGA_URL'] elif config['TAIGA']['TEST'] == 'no': @@ -72,7 +72,6 @@ def reset(): username = input("Enter your user id for taiga: ") password = getpass.getpass("Enter your password for taiga: ") try: - # keyring.set_password("taiga", username) """ So a workaround to store username along with pass is being used the only drawback ofthis work around is in the gui keyring broswer @@ -86,9 +85,7 @@ def reset(): keyring.set_password(service_id, username, str(password)) username = binascii.hexlify(os.urandom(20)) # randomising username to avoid sneak memory attacks password = binascii.hexlify(os.urandom(20)) # ranomising pass to avoid sneak memory attacks - # username = random.choices(string.ascii_uppercase + string.digits, k=random.randint(1,10)) - # passwd = random.choices(string.ascii_uppercase + string.digits, k=random.randint(1,10)) print("Password reset succesfully") except (keyring.errors.PasswordSetError, Exception) as e: print("Failed to reset password") - # print(e + "Contact the developers asap") + From c0912e46022a773f762916735746698be6573480 Mon Sep 17 00:00:00 2001 From: Manas Date: Jun 11 2019 13:37:20 +0000 Subject: [PATCH 17/71] email functionality,debug multiple senders --- diff --git a/mail/climail.py b/mail/climail.py new file mode 100644 index 0000000..f503a25 --- /dev/null +++ b/mail/climail.py @@ -0,0 +1,87 @@ +import smtplib +import ssl +import requests +import configparser +import json +import keyring +import tga +import email.mime.multipart +import editor + +from mail import maillist +from tga import issues + +config = configparser.ConfigParser() +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'] +elif config['EMAIL']['TEST'] == 'no': + sender = config['EMAIL']['DEFAULT_EMAIL_ID] + receiver = config['EMAIL']['LIST'] +else: + print("please set proper test status in config") + + +def email_send(issueno): + port = config['EMAIL']['PORT'] # For SSL + smtp_server = config['EMAIL']['SMTP_SERVER'] + sender_email = sender # Enter your address + receiver_email = reciver # Enter receiver address + data = tga.userstory.get(issueno) + try: + msg = email.mime.multipart.MIMEMultipart() + msg['to'] = reciver + msg['from'] = sender + msg['subject'] = data['subject'] + msg.add_header('reply-to', reciver_email[0]) + msg.attach(MIMEText(body, data['description'])) + # This message is sent from Python.""" +""" + context = ssl.create_default_context() + with smtplib.SMTP_SSL(smtp_server, port, context=context) as server: + server.login(sender_email, password) + server.sendmail(sender_email, receiver_email, message) +""" + + +def mails(args): + for _, value in args._get_kwargs(): + for x in value: + # ref = input("input the issue no you want to announce: ") + try: + r = issues.issue_get(x) + if r.status_code == 200: + data = json.loads(r.content) + print(data) + try: + ra = issues.issue_caget(data['id']) + if ra.status_code == 200: + cadata = json.loads(ra.content) + body = '''\ + == Summary == + {} + == Owners == + {} + == 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)) + editor.edit(filename="mail.txt") + try: + maillist.email_send(data['subject']) + except Exception as e: + print(e) + else: + print("check logs") + except requests.exceptions.RequestException as e: + print(e) + else: + print("unable to send emails check logs") + except requests.exceptions.RequestException as e: + print(e) diff --git a/mail/mailauth.py b/mail/mailauth.py new file mode 100644 index 0000000..a1709b5 --- /dev/null +++ b/mail/mailauth.py @@ -0,0 +1,24 @@ +import keyring +import os +import getpass +import configparser +import binascii + +config = configparser.ConfigParser() +config.read('config.ini') + +service_id = config['EMAIL']['SERVICE_ID'] + + +def reset(): + print("You User Id and password will be securly store in the Keyring") + username = input("Enter your id: ") + password = getpass.getpass("Enter your password for email: ") + try: + keyring.set_password(service_id, "email_username", username) # refer line 67 + keyring.set_password(service_id, username, str(password)) + username = binascii.hexlify(os.urandom(20)) # randomising username to avoid sneak memory attacks + password = binascii.hexlify(os.urandom(20)) # ranomising pass to avoid sneak memory attacks + print("Password reset succesfully") + except (keyring.errors.PasswordSetError, Exception) as e: + print("Failed to reset password", e) diff --git a/mail/maillist.py b/mail/maillist.py new file mode 100644 index 0000000..8423f92 --- /dev/null +++ b/mail/maillist.py @@ -0,0 +1,59 @@ +import smtplib +import ssl +import configparser +import json +import keyring +import tga +import email.mime.multipart + +from email import encoders +from email.mime.base import MIMEBase +from email.mime.multipart import MIMEMultipart +from email.mime.text import MIMEText + +config = configparser.ConfigParser() +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'] +elif config['EMAIL']['TEST'] == 'no': + sender = config['EMAIL']['DEFAULT_EMAIL_ID'] + reciver = config['EMAIL']['LIST'] +else: + print("please set proper test status in config") + + +def email_send(subject): + port = config['EMAIL']['PORT'] # For SSL + smtp_server = config['EMAIL']['SMTP_SERVER'] + sender_email = sender # Enter your address + reciver_email = reciver + print(reciver_email) + #reciver_email = ', '.join(reciver) + #print(reciver_email) # Enter receiver address + username = keyring.get_password(service_id, "email_username") + password = keyring.get_password(service_id, username) + print(password, "this is pass") + try: + msg = MIMEMultipart() + msg['To'] = ', '.join(reciver_email) + msg['From'] = sender + msg['Subject'] = subject + msg.add_header('reply-to', reciver_email[0]) + with open("mail.txt", "r") as m_text: + data = m_text.read()#.replace('\n', '') + print(data) + msg.attach(MIMEText(data, "plain")) + # This message is sent from Python.""" + context = ssl.create_default_context() + with smtplib.SMTP_SSL(smtp_server, port, context=context) as server: + server.login(sender_email, password) + server.sendmail(sender_email, reciver_email, msg.as_string()) + #server.send_message(msg) + print("succesfully sent email") + except Exception as e: + print(e) From 053ca9c42bb2b776a034f9bc94089c3fea1148c7 Mon Sep 17 00:00:00 2001 From: Manas Date: Jun 12 2019 11:44:32 +0000 Subject: [PATCH 18/71] email sending functionality fixed,with json loads Tested working --- diff --git a/mail/climail.py b/mail/climail.py index f503a25..a823a8e 100644 --- a/mail/climail.py +++ b/mail/climail.py @@ -52,7 +52,7 @@ def email_send(issueno): def mails(args): for _, value in args._get_kwargs(): for x in value: - # ref = input("input the issue no you want to announce: ") + #ref = input("input the issue no you want to announce: ") try: r = issues.issue_get(x) if r.status_code == 200: diff --git a/mail/mailauth.py b/mail/mailauth.py index a1709b5..8e0f690 100644 --- a/mail/mailauth.py +++ b/mail/mailauth.py @@ -1,5 +1,5 @@ import keyring -import os +import os import getpass import configparser import binascii diff --git a/mail/maillist.py b/mail/maillist.py index 8423f92..7ebebbe 100644 --- a/mail/maillist.py +++ b/mail/maillist.py @@ -31,19 +31,38 @@ def email_send(subject): port = config['EMAIL']['PORT'] # For SSL smtp_server = config['EMAIL']['SMTP_SERVER'] sender_email = sender # Enter your address - reciver_email = reciver + """ + awesome because it does automatically "cast" values + for no's remove the "" in list + https://stackoverflow.com/questions/335695/lists-in-configparser + The answer below the selected/chosen answer + """ + reciver_emaillist = json.loads(config.get("EMAIL","TEST_LIST")) + print(reciver_emaillist) + #reciver_email = ['manas.man95@gmail.com', 'ttim3886@gmail.com'] + #reciver_email = reciver_email.split(',') + reciver_email = ', '.join(reciver_emaillist) + #reciver_email = reciver + print(type(reciver_email)) print(reciver_email) #reciver_email = ', '.join(reciver) #print(reciver_email) # Enter receiver address + """ + Basically what is being done is we use the list to refer by id + for the header as the converted string if refrenced by id + i.e reciver_email[0] would return the first character of the string + Thus the reciver_emaillist parameter is used below in the reply header + to refer the first one in the string + """ username = keyring.get_password(service_id, "email_username") password = keyring.get_password(service_id, username) print(password, "this is pass") try: msg = MIMEMultipart() - msg['To'] = ', '.join(reciver_email) + msg['To'] = reciver_email msg['From'] = sender msg['Subject'] = subject - msg.add_header('reply-to', reciver_email[0]) + msg.add_header('reply-to', reciver_emaillist[0]) with open("mail.txt", "r") as m_text: data = m_text.read()#.replace('\n', '') print(data) diff --git a/main.py b/main.py index de2b461..a61802a 100644 --- a/main.py +++ b/main.py @@ -4,10 +4,14 @@ import requests import json import argparse import sys -from auth import taiga_auth -from auth import pagure_auth -from auth import bugzilla_auth +from tga import taiga_auth +from pgure import pagure_auth +from bz import bugzilla_auth +from tga import issues as tgaissue +from tga import userstory as tguserstory from convert import convert +from mail import climail +from mail import mailauth class Change_Tool(object): @@ -48,6 +52,10 @@ class Change_Tool(object): bugzilla = subparsers.add_parser('bugzilla', help='bugzilla auth module') bugzilla.add_argument('--token', action='store_true', help='sets the the token for bugzilla') bugzilla.add_argument('--reset', action='store_true', help='sets/resets the user id,pass and the api token') + + email = subparsers.add_parser('email', help='email auth module') + email.add_argument('--reset', action='store_true', help='sets/resets teh email adress') + args = parser.parse_args(sys.argv[2:]) if args.auth: print("Incomplete command,please specify the auth") @@ -70,6 +78,11 @@ class Change_Tool(object): bugzilla_auth.reset() else: print("Wrong command,please check documentation for the proper command") + elif args.command == 'email': + if args.reset: + mailauth.reset() + else: + print("Wrong Command check documentation") else: print("Please Check the Documentation for the proper command or press --h for help") From cfa986fa4e8b91bf635db26a8231401bfd3d4bc1 Mon Sep 17 00:00:00 2001 From: Manas Date: Jun 13 2019 09:06:20 +0000 Subject: [PATCH 19/71] list users story and issues,textable integration --- diff --git a/main.py b/main.py index a61802a..460b68b 100644 --- a/main.py +++ b/main.py @@ -100,6 +100,34 @@ class Change_Tool(object): # print(args) # Debug only convert(args) + def list(self): + parser = argparse.ArgumentParser( + description='announces to mailing list') + parser.add_argument('--list', help='runs the auth instance') + subparsers = parser.add_subparsers(dest='command', help='sub-command help') + + # list issues + issue = subparser.add_parser('issue', help='Lists issues') + issue.add_argument('--pending', action='store_true', help='lists all the pending issues') + + userstory = subparser.add_parser('userstory', help='Lists user stories') + userstory.add_argument('--pending', action='store_true', help='lists pending users stories') + args = parser.parse_args(sys.argv[2:]) + if args.list: + print("Incomplete command,please specify right sub-command") + if args.command == 'issue': + if args.pending: + tguserstory.list_us() + else: + print("wrong command") + elif args.command == 'userstory': + if args.pending: + tgaissue.issue_list() + else: + print("Wrong command") + else: + print("wrong command") + def announce(self): parser = argparse.ArgumentParser( description='announces to mailing list') diff --git a/tga/issues.py b/tga/issues.py index 22a7e1f..5eaf2e3 100644 --- a/tga/issues.py +++ b/tga/issues.py @@ -11,8 +11,10 @@ service_token = config['TAIGA']['SERVICE_TOKEN'] project_id = config['TAIGA']['PROJECT_ID'] if config['TAIGA']['TEST'] == 'yes': taiga_url = config['TAIGA']['CUSTOM_TAIGA_URL'] + status = config['TAIGA']['TEST_IS_STATUS_NEW'] elif config['TAIGA']['TEST'] == 'no': taiga_url = config['TAIGA']['DEFAULT_TAIGA_URL'] + status = config['TAIGA']['IS_STATUS_NEW'] else: print("please set test status in config") @@ -23,6 +25,37 @@ headers = { } +def issue_list(): + try: + url = str(taiga_url) + "/api/v1/issues?project=" + str(project_id) + "\&status=" + str(status) + print(url) # Debug only + try: + r = requests.get( + url, + headers=headers + ) + if r.status_code == 200: + table = BeautifulTable() + table.column_headers = ["refrence no", "subject", "fedora-version", "owner"] + data = json.loads(r.content) + for item in data: + due_date = item['due_date'] + issueid = item['id'] + issuerefrence = item['ref'] + subject = item['subject'] + version = "version" + for item in data['owner_extra_info']: + owner = item['username'] + table.append_row([issueref, subject, version, owner]) + print(table) + else: + print("Unable to fetch list check logs") + except requests.exceptions.RequestException as e: + print(e) + except Exception as e: + print(e) + + def issue_get(x): try: url = str(taiga_url) + "/api/v1/issues/by_ref?ref=" + str(x) + "&project=" + str(project_id) diff --git a/tga/userstory.py b/tga/userstory.py index cdba0ac..7bb8473 100644 --- a/tga/userstory.py +++ b/tga/userstory.py @@ -11,10 +11,10 @@ service_token = config['TAIGA']['SERVICE_TOKEN'] project_id = config['TAIGA']['PROJECT_ID'] if config['TAIGA']['TEST'] == 'yes': taiga_url = config['TAIGA']['CUSTOM_TAIGA_URL'] - status = config['TAIGA']['TEST_US_STATUS_R_FESCO'] + status = config['TAIGA']['TEST_US_STATUS_NEW'] elif config['TAIGA']['TEST'] == 'no': taiga_url = config['TAIGA']['DEFAULT_TAIGA_URL'] - status = config['TAIGA']['STATUS'] + status = config['TAIGA']['US_STATUS_NEW'] else: print("please set test status in config") @@ -25,6 +25,19 @@ headers = { } +def get_us(refusid): + try: + url = str(taiga_url) + "/api/v1/userstories/by_ref?ref=" + str(refusid) + "\&project=" + str(project_id) + print(url) # debug only + r = requests.get( + url, + headers=headers + ) + return r + except requests.exceptions.RequestException as e: + print(e) + + def list_us(): try: url = str(taiga_url) + "/api/v1/issues/userstories?project=" + str(project_id) + "\&status=" + str(status) @@ -35,13 +48,21 @@ def list_us(): headers=headers ) if r.status_code == 200: + table = BeautifulTable() + table.column_headers = ["refrence no", "subject", "fedora-version", "owner"] data = json.loads(r.content) for item in data: - d_list = item['due_date']['tags']['subject'] + subject = item['subject'] + us_id = item['id'] + us_ref = item['ref'] + version = item['epics'] + duedate = item['due_date'] + tags = ['tags'] for item in data['owner_extra_info']: owner = item['username'] - print(dlist, owner) - print("Finished Listing") + table.append_row([us_ref, subject, version, owner]) + #print(us_id, us_ref owner) + print(table) except requests.exceptions.RequestException as e: print(e) except Exception as e: From a957bca46222cff0877cf0999a0d01b3f46c1d22 Mon Sep 17 00:00:00 2001 From: Manas Date: Jun 13 2019 13:50:29 +0000 Subject: [PATCH 20/71] functionality division as per functions/services ,bz,tga,pagure --- diff --git a/bz/bugzilla_auth.py b/bz/bugzilla_auth.py new file mode 100644 index 0000000..ae5603c --- /dev/null +++ b/bz/bugzilla_auth.py @@ -0,0 +1,41 @@ +import requests +import json +import keyring +import random +import os +import binascii +import getpass +import configparser + +config = configparser.ConfigParser() +config.read('config.ini') + +service_id = config['BUGZILLA']['SERVICE_ID'] # service id +service_token = config['BUGZILLA']['SERVICE_TOKEN'] # service d for auth +bz_url = config['BUGZILLA']['DEFAULT_BUGZILLA_URL'] # taiga server note +custom_bz = config['BUGZILLA']['CUSTOM_BUGZILLA_URL'] + +""" +bugzilla uses a api key to enable the api acess +Currently there is a xml-rpc method to acess +That method is going to be deprecated soon +Thus the latest method uses API key to acess +the api token.is sued by the modern rest api +""" +def reset(): + print("You User Id and password will be securly store in the Keyring") + username = input("Enter your user id for bugzilla: ") + password = getpass.getpass("Enter your password for bugzilla: ") + api_key = getpass.getpass("Enter your bugzilla api: ") + try: + # keyring.set_password("taiga", username) + # keyring.set_password(service_id, "username", username) + keyring.set_password(service_id, username, str(password)) + keyring.set_password(service_id, username, api_key) + username = binascii.hexlify(os.urandom(20)) # randomising username to avoid sneak memory attacks + password = binascii.hexlify(os.urandom(20)) # ranomising pass to avoid sneak memory attacks + # username = random.choices(string.ascii_uppercase + string.digits, k=random.randint(1,10)) + # passwd = random.choices(string.ascii_uppercase + string.digits, k=random.randint(1,10)) + print("Password and api key reset succesfully") + except (keyring.errors.PasswordSetError, Exception) as e: + print("Failed to reset password & api key", e) diff --git a/config_load.py b/config_load.py new file mode 100644 index 0000000..b2b55e7 --- /dev/null +++ b/config_load.py @@ -0,0 +1,34 @@ +from configparser import SafeConfigParser +import os + + +class Config: + """Interact with configuration variables.""" + + configParser = SafeConfigParser() + configFilePath = (os.path.join(os.getcwd(), 'config.ini')) + + @classmethod + def initialize(cls, new_config): + """Start config by reading config.ini.""" + cls.configParser.read(cls.configFilePath) + + @classmethod + def taiga(cls, key): + """Get taiga values from config.ini.""" + return cls.configParser.get('TAIGA', key) + + @classmethod + def pagure(cls, key): + """Get pagure values from config.ini.""" + return cls.configParser.get('PAGURE', key) + + @classmethod + def bugzilla(cls, key): + """Get bugzilla values from config.ini""" + return cls.configParser.get('BUGZILLA', key) + + @classmethod + def email(cls, key): + """Get bugzilla values from config.ini""" + return cls.configParser.get('EMAIL', key) diff --git a/pgure/pagure_auth.py b/pgure/pagure_auth.py new file mode 100644 index 0000000..dfe3ebb --- /dev/null +++ b/pgure/pagure_auth.py @@ -0,0 +1,26 @@ +import requests +import json +import keyring +import random +import os +import binascii +import getpass +import configparser + +config = configparser.ConfigParser() +config.read('config.ini') + + +def reset(): + print("Your auth token will be securly store in the Keyring") + # username = input("Enter your user id for taiga: ") + api_token = "api_token" + repo_name = input("Enter the repo name you want to set api key for: ") + token = getpass.getpass("Enter your token for" + ' ' + repo_name + ' ' "repository: ") + try: + # keyring.set_password("taiga", username) + keyring.set_password(repo_name, api_token, token) + print("token reset succesfully") + except (keyring.errors.PasswordSetError, Exception) as e: + print("Failed to reset token") + # print(e + "Contact the developers asap") diff --git a/tga/taiga_auth.py b/tga/taiga_auth.py new file mode 100644 index 0000000..f046771 --- /dev/null +++ b/tga/taiga_auth.py @@ -0,0 +1,91 @@ +import requests +import json +import keyring +import random +import os +import binascii +import getpass +import configparser +import keyring + +config = configparser.ConfigParser() +config.read('config.ini') + +service_id = config['TAIGA']['SERVICE_ID'] # service id +service_token = config['TAIGA']['SERVICE_TOKEN'] # service d for auth +# taiga_url = config['TAIGA']['DEFAULT_TAIGA_URL'] # taiga server note +# custom_taiga = config['TAIGA']['CUSTOM_TAIGA_URL'] +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") + + +headers = { + 'Content-Type': 'application/json', +} + + +def refresh_token(): + """ + Used only for testing and Demo + Encrypted Config file/Application token + used in production. + Doing the follwoing in prod is security risk. + """ + username = keyring.get_password(service_id, "taiga_username") + print(username) # debug only + payload = { + 'type': 'normal', + 'username': username, + 'password': keyring.get_password(service_id, username) + } + print(payload) # only for debugging + + try: + r = requests.post( + str(taiga_url) + "/api/v1/auth", + data=json.dumps(payload), + headers=headers) + print(r.status_code) + if r.status_code == 200: + """ + with open('auth.txt', 'w') as a_file: + a_file.write(r.json()['auth_token']) + """ + try: + keyring.set_password(service_token, "taiga_token", r.json()['auth_token']) + print("succesful authentication") + except (keyring.errors.PasswordSetError, Exception) as e: + print("Failed to set auth token") + elif r.status_code == 400: + print("auth error") + except requests.exceptions.RequestException as e: + print(e) + + +def reset(): + print("You User Id and password will be securly store in the Keyring") + username = input("Enter your user id for taiga: ") + password = getpass.getpass("Enter your password for taiga: ") + try: + """ + So a workaround to store username along with pass is being used + the only drawback ofthis work around is in the gui keyring broswer + a seperate username keyring will show,sadly this cannot be avoided + at the point of writing this peice of software + """ + """ + The above comment is not true + """ + keyring.set_password(service_id, "taiga_username", username) # refer line 67 + keyring.set_password(service_id, username, str(password)) + username = binascii.hexlify(os.urandom(20)) # randomising username to avoid sneak memory attacks + password = binascii.hexlify(os.urandom(20)) # ranomising pass to avoid sneak memory attacks + print("Password reset succesfully") + except (keyring.errors.PasswordSetError, Exception) as e: + print("Failed to reset password") + From 8b753d1bcafe4210dd9e7162ab093dd7c1f909bb Mon Sep 17 00:00:00 2001 From: Manas Date: Jun 14 2019 07:43:20 +0000 Subject: [PATCH 21/71] test commit for user def config --- diff --git a/config.ini b/config.ini index 2180224..b08c32c 100644 --- a/config.ini +++ b/config.ini @@ -1,22 +1,49 @@ [TAIGA] SERVICE_ID = taiga SERVICE_TOKEN = taiga_auth -PID = 325363 # for test only -DEFAULT_TAIGA_URL = https://teams-api.fedoraproject.org -CUSTOM_TAIGA_URL = https://api.taiga.io -STATUS_ANNOUNCED = 29 -STATUS_R_FESCO = 30 -STATUS_ACCEPTED = 31 -STATUS_ARCHIVED = 32 -STATUS_CODE_COMPLETE = 33 -STATUS_TESTABLE = 34 -TEST_STATUS_ANNOUNCED = 1892835 -TEST_STATUS_R_FESCO = 1892836 -TEST_STATUS_ACCEPTED = 1892837 -TEST_STATUS_ARCHIVED = 1892838 -TEST_STATUS_CODE_COMPLETE = 1892839 -TEST_STATUS_TESTABLE = 1951329 -TEST = yes +PROJECT_ID = 325667 +TAIGA_URL = https://api.taiga.io + +IS_STATUS_NEW = 2283176 +IS_STATUS_NEEDS_INFO = 2283180 +IS_STATUS_READY_FOR_WRANGLER = 2283232 +IS_STATUS_PROCESSED = 2283182 +US_STATUS_NEW = 1952887 +US_STATUS_ANNOUNCED = 1952888 +US_STATUS_R_FESCO = 1952889 +US_STATUS_ACCEPTED = 1952891 +US_STATUS_ARCHIVED = 1952890 +US_STATUS_CODE_COMPLETE = 1892839 +US_STATUS_TESTABLE = 1952932 + +IS_CA_SYSTEM_WIDE_CHANGE = 11370 +IS_CA_SUMMARY = 11372 +IS_CA_BUGZILLA_CONTACT = 11373 +IS_CA_RELENG_TICKET = 11371 +IS_CA_TRADEMARK_APPROVAL = 11374 +IS_CA_OWNERS = 11375 +IS_CA_FESCO_TICKET = 534454574 +IS_CA_BUGZILLA_TRACKER = 21930 +IS_CA_RELEASE_NOTES = 21931 +IS_CA_CONTINGENCY = 11376 +IS_CA_MASS_REBUILD = 11377 +IS_CA_POLICY_CHANGE = 11378 +IS_CA_MODIFIES_DELIVERABLES = 11379 +IS_CA_VERSION = 11383 +US_CA_SYSTEM_WIDE_CHANGE = 21923 +US_cA_SUMMARY = 21924 +US_CA_BUGZILLA_CONTACT = 21925 +US_CA_RELENG_TICKET = 21926 +US_CA_TRADEMARK_APPROVAL = 21927 +US_CA_OWNERS = 21928 +US_CA_FESCO_TICKET = 21929 +US_cA_BUGZILLA_TRACKER = 21930 +US_CA_RELEASE_NOTES = 21931 +US_CA_CONTINGENCY = 21932 +US_CA_MASS_REBUILD = 21933 +US_CA_POLICY_CHANGE = 21934 +US_CA_MODIFIES_DELIVERABLES = 21935 + [PAGURE] SERVICE_ID = pagure @@ -24,18 +51,18 @@ SERVICE_ID = pagure [BUGZILLA] SERVICE_ID = bugzilla SERVICE_TOKEN = bugzilla_auth -PID = 315827 # for test only +project_id = 315827 # for test only DEFAULT_BUGZILLA_URL = https://bugzilla.redhat.com/ -CUSTOM_BUGZILLA_URL = https://bugzilla.redhat.com/ -TEST = no +; TEST = no [EMAIL] SERVICE_ID = email DEFAULT_EMAIL_ID = bcotton@redhat.org CUSTOM_EMAIL_ID = manasmangaonkar@gmail.com -TEST_LIST: [manas.man95@gmail.com,ttim3886@gmail.com] -LIST: [devel@lists.fedoraproject.org,devel-announce@lists.fedoraproject.org] +LIST: ["manas.man95@gmail.com","bcotton@redhat.org"] +; LIST: [devel@lists.fedoraproject.org,devel-announce@lists.fedoraproject.org] PORT = 465 SMTP_SERVER = smtp.gmail.com -TEST = yes -1892835 \ No newline at end of file +; TEST = yes +; 1892835 + diff --git a/convert.py b/convert.py index cafe049..566869c 100644 --- a/convert.py +++ b/convert.py @@ -9,23 +9,34 @@ from tga import userstory as tgauserstory config = configparser.ConfigParser() config.read('config.ini') +#config.read('%s' % (configpath)) +#config.read(['userconfig.ini', os.path.expanduser('~/.')]) service_id = config['TAIGA']['SERVICE_ID'] # service id service_token = config['TAIGA']['SERVICE_TOKEN'] project_id = config['TAIGA']['PROJECT_ID'] +taiga_url = config['TAIGA']['CUSTOM_TAIGA_URL'] +""" 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 convert(args): +def convert(args, 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'] + taiga_url = config['TAIGA']['CUSTOM_TAIGA_URL'] for _, value in args._get_kwargs(): # iteratingover name space object for x in value: try: - r = tgaissue.issue_get(x) # gets the issue + r = tgaissue.issue_get(x, config) # gets the issue if r.status_code == 200: data = json.loads(r.content) print(data, "this is issue data") @@ -53,7 +64,7 @@ def convert(args): ) """ try: - r = tgaissue.issue_caget(issue_id) + r = tgaissue.issue_caget(issue_id, config) if r.status_code == 200: data = json.loads(r.content) print(data, "step 2") @@ -96,7 +107,7 @@ def convert(args): 'subject': subject } #print(payload) - r = tgauserstory.post_us(payload) + r = tgauserstory.post_us(payload, config) #print(json.loads(r.content)) data = json.loads(r.content) #print(r.status_code) @@ -107,30 +118,30 @@ def convert(args): print(id) payload = { "attributes_values": { - config['TAIGA']['TEST_US_CA_SYSTEM_WIDE_CHANGE']: system_wide_change, - config['TAIGA']['TEST_US_CA_SUMMARY']: summary, - config['TAIGA']['TEST_US_CA_RELENG_TICKET']: relengticket, - config['TAIGA']['TEST_US_CA_TRADEMARK_APPROVAL']: approval_required, - #config['TAIGA']['TEST_US_CA_OWNERS']: owners, - config['TAIGA']['TEST_US_CA_FESCO_TICKET']: 'random', - config['TAIGA']['TEST_US_CA_BUGZILLA_TRACKER']: 'random', - config['TAIGA']['TEST_US_CA_BUGZILLA_CONTACT']: bugzilla_id, - config['TAIGA']['TEST_US_CA_RELEASE_NOTES']: 'random', - config['TAIGA']['TEST_US_CA_CONTINGENCY']: contingency_deadline, - config['TAIGA']['TEST_US_CA_MASS_REBUILD']: mass_rebuild, - config['TAIGA']['TEST_US_CA_POLICY_CHANGE']: policy_change, - config['TAIGA']['TEST_US_CA_MODIFIES_DELIVERABLES']: modifies_deliverables + config['TAIGA']['US_CA_SYSTEM_WIDE_CHANGE']: system_wide_change, + config['TAIGA']['US_CA_SUMMARY']: summary, + config['TAIGA']['US_CA_RELENG_TICKET']: relengticket, + config['TAIGA']['US_CA_TRADEMARK_APPROVAL']: approval_required, + #config['TAIGA']['US_CA_OWNERS']: owners, + config['TAIGA']['US_CA_FESCO_TICKET']: 'random', + config['TAIGA']['US_CA_BUGZILLA_TRACKER']: 'random', + config['TAIGA']['US_CA_BUGZILLA_CONTACT']: bugzilla_id, + config['TAIGA']['US_CA_RELEASE_NOTES']: 'random', + config['TAIGA']['US_CA_CONTINGENCY']: contingency_deadline, + config['TAIGA']['US_CA_MASS_REBUILD']: mass_rebuild, + config['TAIGA']['US_CA_POLICY_CHANGE']: policy_change, + config['TAIGA']['US_CA_MODIFIES_DELIVERABLES']: modifies_deliverables }, "version": 1 } print(payload) - r = tgauserstory.post_usca(payload, us_id) + r = tgauserstory.post_usca(payload, us_id, config) print(json.loads(r.content)) print(r.status_code) if r.status_code == 200: print("Sucessfully converted issue to user story") try: - r = tgaepic.list_epic() + r = tgaepic.list_epic(config) data = json.loads(r.content) if r.status_code == 200: for i in data: @@ -139,10 +150,10 @@ def convert(args): epicref = i['ref'] break - r = tgaepic.post_relatedus(us_id, epicid, epicref) + r = tgaepic.post_relatedus(us_id, epicid, epicref, config) if r.status_code == 201: print("Sucessfully mapped epics") - r = tgaissue.issue_close(issue_id, issue_version) + r = tgaissue.issue_close(issue_id, issue_version, config) print(r.status_code) print(r.content) #print(json.loads(r.content)) diff --git a/main.py b/main.py index 460b68b..3633b74 100644 --- a/main.py +++ b/main.py @@ -96,9 +96,16 @@ class Change_Tool(object): nargs='+', type=int, help="Converts Issue to User Story") + parser.add_argument('--config', + action='store', + type=string, + dest='configPath', + default='"%s/config.ini" % (expanduser("~))', + required=False, + help='Sets config path') args = parser.parse_args(sys.argv[2:]) # print(args) # Debug only - convert(args) + convert(args,configPath) def list(self): parser = argparse.ArgumentParser( @@ -137,7 +144,20 @@ class Change_Tool(object): help="Announces to Mailing list") args = parser.parse_args(sys.argv[2:]) # print(args) # debug only - mail(args) + climail.mails(args) + + def config(self): + parser = argparse.ArgumentParser( + description='sets the user defined config') + parser.add_argument('--config', + action='store', + type='string', + dest='configPath', + default='"%s/config.ini" % (expanduser("~))', + help='configPath is set') + + args = parser.parse_args(sys.argv[2:]) + """ def accept(self): parser = argparse.ArgumentParser( diff --git a/tga/epics.py b/tga/epics.py index db2582d..7534053 100644 --- a/tga/epics.py +++ b/tga/epics.py @@ -5,10 +5,11 @@ import requests 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'] status = config['TAIGA']['TEST_US_STATUS_R_FESCO'] @@ -17,16 +18,17 @@ elif config['TAIGA']['TEST'] == 'no': status = config['TAIGA']['STATUS'] else: print("please set test status in config") +""" headers = { 'Content-Type': 'application/json', - 'Authorization': 'Bearer {0}'.format(keyring.get_password(service_token, "taiga_token")) + 'Authorization': 'Bearer {0}'.format(keyring.get_password(config['TAIGA']['SERVICE_TOKEN'], "taiga_token")) } -def list_epic(): +def list_epic(config): try: - url = str(taiga_url) + "/api/v1/epics?project=" + str(project_id) + url = str(taiga_url) + "/api/v1/epics?project=" + str(config['TAIGA']['PROJECT_ID']) r = requests.get( url, headers=headers @@ -36,7 +38,7 @@ def list_epic(): print(e) -def post_relatedus(us_id, epicid, epicref): +def post_relatedus(us_id, epicid, epicref, config): try: payload = { "epic": epicid, diff --git a/tga/issues.py b/tga/issues.py index 5eaf2e3..980c67d 100644 --- a/tga/issues.py +++ b/tga/issues.py @@ -3,12 +3,14 @@ import configparser import keyring import requests +""" 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'] status = config['TAIGA']['TEST_IS_STATUS_NEW'] @@ -18,17 +20,24 @@ elif config['TAIGA']['TEST'] == 'no': else: print("please set test status in config") + headers = { 'Content-Type': 'application/json', 'Authorization': 'Bearer {0}'.format(keyring.get_password(service_token, "taiga_token")) # 'Authorization': 'Bearer {0}'.format(str(123)) } +""" -def issue_list(): +def issue_list(config): try: - url = str(taiga_url) + "/api/v1/issues?project=" + str(project_id) + "\&status=" + str(status) + url = str(config['TAIGA']['TAIGA_URL']) + "/api/v1/issues?project=" + str(config['TAIGA']['PROJECT_ID']) + "\&status=" + str(config['TAIGA']['IS_STATUS_NEW']) print(url) # Debug only + headers = { + 'Content-Type': 'application/json', + 'Authorization': 'Bearer {0}'.format(keyring.get_password(config['TAIGA']['SERVICE_TOKEN'], "taiga_token")) + # 'Authorization': 'Bearer {0}'.format(str(123)) + } try: r = requests.get( url, @@ -56,9 +65,9 @@ def issue_list(): print(e) -def issue_get(x): +def issue_get(x, config): try: - url = str(taiga_url) + "/api/v1/issues/by_ref?ref=" + str(x) + "&project=" + str(project_id) + url = str(config['TAIGA']['TAIGA_URL']) + "/api/v1/issues/by_ref?ref=" + str(x) + "&project=" + str(config['TAIGA']['PROJECT_ID']) print(url) # debug/dev env only r = requests.get( @@ -70,12 +79,12 @@ def issue_get(x): print(e) -def issue_caget(x): +def issue_caget(x, config): """ Gets custom attributes from taiga for issue """ print(x) - id_url = str(taiga_url) + "/api/v1/issues/custom-attributes-values/" + str(x) # x is id + id_url = str(config['TAIGA']['TAIGA_URL']) + "/api/v1/issues/custom-attributes-values/" + str(x) # x is id print(id_url) try: r = requests.get( @@ -87,10 +96,10 @@ def issue_caget(x): print(e) -def issue_close(x, issue_version): - id_url = str(taiga_url) + "/api/v1/issues/" + str(x) # x is id +def issue_close(x, issue_version, config): + id_url = str(config['TAIGA']['TAIGA_URL']) + "/api/v1/issues/" + str(x) # x is id payload = { - 'status': config['TAIGA']['TEST_IS_STATUS_PROCESSED'], + 'status': config['TAIGA']['IS_STATUS_PROCESSED'], 'version': issue_version } try: diff --git a/tga/taiga_auth.py b/tga/taiga_auth.py index f046771..e115f2d 100644 --- a/tga/taiga_auth.py +++ b/tga/taiga_auth.py @@ -8,34 +8,41 @@ import getpass import configparser import keyring + config = configparser.ConfigParser() -config.read('config.ini') +config.read(config(filename)) service_id = config['TAIGA']['SERVICE_ID'] # service id service_token = config['TAIGA']['SERVICE_TOKEN'] # service d for auth # taiga_url = config['TAIGA']['DEFAULT_TAIGA_URL'] # taiga server note # custom_taiga = config['TAIGA']['CUSTOM_TAIGA_URL'] project_id = config['TAIGA']['PROJECT_ID'] +taiga_url = config['TAIGA']['TAIGA_URL'] +""" 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") - - +""" headers = { 'Content-Type': 'application/json', } -def refresh_token(): +def refresh_token(filename): """ Used only for testing and Demo Encrypted Config file/Application token used in production. Doing the follwoing in prod is security risk. """ + config = configparser.ConfigParser() + config.read(config(filename)) + service_id = config['TAIGA']['SERVICE_ID'] + project_id = config['TAIGA']['PROJECT_ID'] + taiga_url = config['TAIGA']['TAIGA_URL'] username = keyring.get_password(service_id, "taiga_username") print(username) # debug only payload = { @@ -67,7 +74,10 @@ def refresh_token(): print(e) -def reset(): +def reset(filename): + config = configparser.ConfigParser() + config.read(config(filename)) + service_id = config['TAIGA']['SERVICE_ID'] print("You User Id and password will be securly store in the Keyring") username = input("Enter your user id for taiga: ") password = getpass.getpass("Enter your password for taiga: ") diff --git a/tga/userstory.py b/tga/userstory.py index 7bb8473..1bdeea6 100644 --- a/tga/userstory.py +++ b/tga/userstory.py @@ -9,6 +9,7 @@ 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'] status = config['TAIGA']['TEST_US_STATUS_NEW'] @@ -17,7 +18,7 @@ elif config['TAIGA']['TEST'] == 'no': status = config['TAIGA']['US_STATUS_NEW'] else: print("please set test status in config") - +""" headers = { 'Content-Type': 'application/json', @@ -25,7 +26,7 @@ headers = { } -def get_us(refusid): +def get_us(refusid, config): try: url = str(taiga_url) + "/api/v1/userstories/by_ref?ref=" + str(refusid) + "\&project=" + str(project_id) print(url) # debug only @@ -38,7 +39,7 @@ def get_us(refusid): print(e) -def list_us(): +def list_us(config): try: url = str(taiga_url) + "/api/v1/issues/userstories?project=" + str(project_id) + "\&status=" + str(status) print(url) # Debug only @@ -69,7 +70,7 @@ def list_us(): print(e) -def post_us(x): +def post_us(x, config): try: r = requests.post( 'https://api.taiga.io/api/v1/userstories', @@ -81,7 +82,7 @@ def post_us(x): print(e) -def post_usca(x, id): +def post_usca(x, id, config): try: r = requests.patch( 'https://api.taiga.io/api/v1/userstories/custom-attributes-values/' + str(id), From 3e715f3677c86d06d77fb303da190d18f270f7e2 Mon Sep 17 00:00:00 2001 From: Manas Date: Jun 15 2019 07:19:23 +0000 Subject: [PATCH 22/71] 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() + + From f67c72e86f7603a2b5fe8a00b89cc3f3bab40b8b Mon Sep 17 00:00:00 2001 From: Manas Date: Jun 15 2019 07:22:23 +0000 Subject: [PATCH 23/71] files divided as per functionality --- diff --git a/announce/mailing_list.py b/announce/mailing_list.py deleted file mode 100644 index bbc951c..0000000 --- a/announce/mailing_list.py +++ /dev/null @@ -1,42 +0,0 @@ -import smtplib -import ssl -import confifparser -import json -import keyring -import tga -import email.minie.multipart - -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'] -elif config['EMAIL']['TEST'] == 'no': - sender = config['EMAIL']['DEFAULT_EMAIL_ID] - receiver = config['EMAIL']['LIST'] -else: - print("please set proper test status in config") - - -def email_send(issueno): - port = config['EMAIL']['PORT'] # For SSL - smtp_server = config['EMAIL']['SMTP_SERVER'] - sender_email = sender # Enter your address - receiver_email = reciver # Enter receiver address - data = tga.userstory.get(issueno) - - try: - msg = email.mime.multipart.MIMEMultipart() - msg['to'] = reciver - msg['from'] = sender - msg['subject'] = data['subject'] - msg.add_header('reply-to', reciver_email[0]) - - msg.attach(MIMEText(body, data['description'])) - # This message is sent from Python.""" - - context = ssl.create_default_context() - with smtplib.SMTP_SSL(smtp_server, port, context=context) as server: - server.login(sender_email, password) - server.sendmail(sender_email, receiver_email, message) \ No newline at end of file diff --git a/auth/bugzilla_auth.py b/auth/bugzilla_auth.py deleted file mode 100644 index ae5603c..0000000 --- a/auth/bugzilla_auth.py +++ /dev/null @@ -1,41 +0,0 @@ -import requests -import json -import keyring -import random -import os -import binascii -import getpass -import configparser - -config = configparser.ConfigParser() -config.read('config.ini') - -service_id = config['BUGZILLA']['SERVICE_ID'] # service id -service_token = config['BUGZILLA']['SERVICE_TOKEN'] # service d for auth -bz_url = config['BUGZILLA']['DEFAULT_BUGZILLA_URL'] # taiga server note -custom_bz = config['BUGZILLA']['CUSTOM_BUGZILLA_URL'] - -""" -bugzilla uses a api key to enable the api acess -Currently there is a xml-rpc method to acess -That method is going to be deprecated soon -Thus the latest method uses API key to acess -the api token.is sued by the modern rest api -""" -def reset(): - print("You User Id and password will be securly store in the Keyring") - username = input("Enter your user id for bugzilla: ") - password = getpass.getpass("Enter your password for bugzilla: ") - api_key = getpass.getpass("Enter your bugzilla api: ") - try: - # keyring.set_password("taiga", username) - # keyring.set_password(service_id, "username", username) - keyring.set_password(service_id, username, str(password)) - keyring.set_password(service_id, username, api_key) - username = binascii.hexlify(os.urandom(20)) # randomising username to avoid sneak memory attacks - password = binascii.hexlify(os.urandom(20)) # ranomising pass to avoid sneak memory attacks - # username = random.choices(string.ascii_uppercase + string.digits, k=random.randint(1,10)) - # passwd = random.choices(string.ascii_uppercase + string.digits, k=random.randint(1,10)) - print("Password and api key reset succesfully") - except (keyring.errors.PasswordSetError, Exception) as e: - print("Failed to reset password & api key", e) diff --git a/auth/email_auth.py b/auth/email_auth.py deleted file mode 100644 index edbfa6b..0000000 --- a/auth/email_auth.py +++ /dev/null @@ -1,12 +0,0 @@ -def reset(): - print("You User Id and password will be securly store in the Keyring") - username = input("Enter your id: ") - password = getpass.getpass("Enter your password for taiga: ") - try: - keyring.set_password(service_id, "email_username", username) # refer line 67 - keyring.set_password(service_id, username, str(password)) - username = binascii.hexlify(os.urandom(20)) # randomising username to avoid sneak memory attacks - password = binascii.hexlify(os.urandom(20)) # ranomising pass to avoid sneak memory attacks - print("Password reset succesfully") - except (keyring.errors.PasswordSetError, Exception) as e: - print("Failed to reset password", e) diff --git a/auth/pagure_auth.py b/auth/pagure_auth.py deleted file mode 100644 index dfe3ebb..0000000 --- a/auth/pagure_auth.py +++ /dev/null @@ -1,26 +0,0 @@ -import requests -import json -import keyring -import random -import os -import binascii -import getpass -import configparser - -config = configparser.ConfigParser() -config.read('config.ini') - - -def reset(): - print("Your auth token will be securly store in the Keyring") - # username = input("Enter your user id for taiga: ") - api_token = "api_token" - repo_name = input("Enter the repo name you want to set api key for: ") - token = getpass.getpass("Enter your token for" + ' ' + repo_name + ' ' "repository: ") - try: - # keyring.set_password("taiga", username) - keyring.set_password(repo_name, api_token, token) - print("token reset succesfully") - except (keyring.errors.PasswordSetError, Exception) as e: - print("Failed to reset token") - # print(e + "Contact the developers asap") diff --git a/auth/taiga_auth.py b/auth/taiga_auth.py deleted file mode 100644 index f046771..0000000 --- a/auth/taiga_auth.py +++ /dev/null @@ -1,91 +0,0 @@ -import requests -import json -import keyring -import random -import os -import binascii -import getpass -import configparser -import keyring - -config = configparser.ConfigParser() -config.read('config.ini') - -service_id = config['TAIGA']['SERVICE_ID'] # service id -service_token = config['TAIGA']['SERVICE_TOKEN'] # service d for auth -# taiga_url = config['TAIGA']['DEFAULT_TAIGA_URL'] # taiga server note -# custom_taiga = config['TAIGA']['CUSTOM_TAIGA_URL'] -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") - - -headers = { - 'Content-Type': 'application/json', -} - - -def refresh_token(): - """ - Used only for testing and Demo - Encrypted Config file/Application token - used in production. - Doing the follwoing in prod is security risk. - """ - username = keyring.get_password(service_id, "taiga_username") - print(username) # debug only - payload = { - 'type': 'normal', - 'username': username, - 'password': keyring.get_password(service_id, username) - } - print(payload) # only for debugging - - try: - r = requests.post( - str(taiga_url) + "/api/v1/auth", - data=json.dumps(payload), - headers=headers) - print(r.status_code) - if r.status_code == 200: - """ - with open('auth.txt', 'w') as a_file: - a_file.write(r.json()['auth_token']) - """ - try: - keyring.set_password(service_token, "taiga_token", r.json()['auth_token']) - print("succesful authentication") - except (keyring.errors.PasswordSetError, Exception) as e: - print("Failed to set auth token") - elif r.status_code == 400: - print("auth error") - except requests.exceptions.RequestException as e: - print(e) - - -def reset(): - print("You User Id and password will be securly store in the Keyring") - username = input("Enter your user id for taiga: ") - password = getpass.getpass("Enter your password for taiga: ") - try: - """ - So a workaround to store username along with pass is being used - the only drawback ofthis work around is in the gui keyring broswer - a seperate username keyring will show,sadly this cannot be avoided - at the point of writing this peice of software - """ - """ - The above comment is not true - """ - keyring.set_password(service_id, "taiga_username", username) # refer line 67 - keyring.set_password(service_id, username, str(password)) - username = binascii.hexlify(os.urandom(20)) # randomising username to avoid sneak memory attacks - password = binascii.hexlify(os.urandom(20)) # ranomising pass to avoid sneak memory attacks - print("Password reset succesfully") - except (keyring.errors.PasswordSetError, Exception) as e: - print("Failed to reset password") - From 545f311c2fea51db000ce8863b41cb232cf81c0e Mon Sep 17 00:00:00 2001 From: Manas Date: Jun 15 2019 07:27:12 +0000 Subject: [PATCH 24/71] Merge branch 'development-stable' into development --- diff --git a/config.ini b/config.ini index b08c32c..2d7a47e 100644 --- a/config.ini +++ b/config.ini @@ -3,6 +3,7 @@ SERVICE_ID = taiga SERVICE_TOKEN = taiga_auth PROJECT_ID = 325667 TAIGA_URL = https://api.taiga.io +TAIGA_SITE_ISSUE_URL = https://tree.taiga.io/project/pac_23-test-changes-tracker-kanban/issue/ IS_STATUS_NEW = 2283176 IS_STATUS_NEEDS_INFO = 2283180 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() + + From 7103816a8c3e30d586d8e9f92bde4678fbdcc789 Mon Sep 17 00:00:00 2001 From: Manas Date: Jun 19 2019 17:25:20 +0000 Subject: [PATCH 25/71] changed as per the divide as per functionality policy --- diff --git a/pgure/fesco.py b/pgure/fesco.py new file mode 100644 index 0000000..809c145 --- /dev/null +++ b/pgure/fesco.py @@ -0,0 +1,101 @@ +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 pgure import issues as pgaissues + +""" +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 fesissue(args, 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 args: # 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("this step") + 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.write("{}\n\n*{}\n*{}\n*{}\n*{}\n".format(summary, taiga_issue_link, maillist_link, maillist_dsc_list, owner)) + editor.edit(filename="pagure_issue.txt") + try: + with open("pagure_issue.txt", "r") as pg_txt: + issue_text = pg_txt.read() + if system_wide_change == True: + syschange = "System-Wide Change" + elif system_wide_change == False: + syschange = "Self-Contained Change" + title = str(fedora_version) + ' ' + str(syschange) + ':' + str(subject) + print(issue_text) + payload = { + 'title': title, + 'issue_content': issue_text + } + print(title,payload) + r = pgaissues.post_issue(payload, config) + print(r) + if r.status_code == 200: + payload = { + 'status': config['TAIGA']['IS_STATUS_READY_FOR_FESCO'], + 'version': taiga_issue_version + } + r = chagnestatus_issue(taiga_issue_id, payload, config) + print("Succesfully posted issue") + else: + print("Check logs for errors",json.loads(r.content)) + except requests.exceptions.RequestException as e: + print(e) + except Exception as e: + print(e) + else: + print("Unable to post to fesco") + except requests.exceptions.RequestException as e: + print(e) + else: + print("Unable to fetch details from taiga for issue creation") + except requests.exceptions.RequestException as e: + print(e) diff --git a/tga/convert.py b/tga/convert.py new file mode 100644 index 0000000..4baf8be --- /dev/null +++ b/tga/convert.py @@ -0,0 +1,190 @@ +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 + +""" +config = configparser.ConfigParser() +config.read('config.ini') +#config.read('%s' % (configpath)) +#config.read(['userconfig.ini', os.path.expanduser('~/.')]) + +service_id = config['TAIGA']['SERVICE_ID'] # service id +service_token = config['TAIGA']['SERVICE_TOKEN'] +project_id = config['TAIGA']['PROJECT_ID'] +taiga_url = config['TAIGA']['CUSTOM_TAIGA_URL'] +""" +""" +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 convert(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'] + taiga_url = config['TAIGA']['TAIGA_URL'] + for x in value: + try: + r = tgaissue.get_issue(x, config) # gets the issue + if r.status_code == 200: + data = json.loads(r.content) + print(data, "this is issue data") + details = data['description'] + subject = data['subject'] + issue_id = data['id'] + issue_version = data['version'] # fetch the id as well + #print(issue_id) + print("Step 1") + """ + 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 + issue_customattr = requests.get( + id_url, + headers=headers, + ) + """ + try: + r = tgaissue.caget_issue(issue_id, config) + if r.status_code == 200: + data = json.loads(r.content) + print(data, "step 2") + #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'] + fedora_version = data['attributes_values']['11383'] + print(fedora_version) + #print("summary", summary) + #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': project_id, + 'description': details, + 'subject': subject + } + #print(payload) + r = tgauserstory.post_us(payload, config) + #print(json.loads(r.content)) + data = json.loads(r.content) + #print(r.status_code) + if r.status_code == 201: + print("step 3") + data = json.loads(r.content) + us_id = data['id'] + print(id) + payload = { + "attributes_values": { + config['TAIGA']['US_CA_SYSTEM_WIDE_CHANGE']: system_wide_change, + config['TAIGA']['US_CA_SUMMARY']: summary, + config['TAIGA']['US_CA_RELENG_TICKET']: relengticket, + config['TAIGA']['US_CA_TRADEMARK_APPROVAL']: approval_required, + #config['TAIGA']['US_CA_OWNERS']: owners, + config['TAIGA']['US_CA_FESCO_TICKET']: 'random', + config['TAIGA']['US_CA_BUGZILLA_TRACKER']: 'random', + config['TAIGA']['US_CA_BUGZILLA_CONTACT']: bugzilla_id, + config['TAIGA']['US_CA_RELEASE_NOTES']: 'random', + config['TAIGA']['US_CA_CONTINGENCY']: contingency_deadline, + config['TAIGA']['US_CA_MASS_REBUILD']: mass_rebuild, + config['TAIGA']['US_CA_POLICY_CHANGE']: policy_change, + config['TAIGA']['US_CA_MODIFIES_DELIVERABLES']: modifies_deliverables + }, + "version": 1 + } + print(payload) + r = tgauserstory.post_usca(payload, us_id, config) + print(json.loads(r.content)) + print(r.status_code) + if r.status_code == 200: + print("Sucessfully converted issue to user story") + try: + r = tgaepic.list_epic(config) + data = json.loads(r.content) + if r.status_code == 200: + for i in data: + if i['subject'] == str(fedora_version): + epicid = i['id'] + epicref = i['ref'] + break + + r = tgaepic.post_relatedus(us_id, epicid, epicref, config) + if r.status_code == 201: + print("Sucessfully mapped epics") + payload = { + 'status': config['TAIGA']['IS_STATUS_PROCESSED'], + 'version': issue_version + } + r = tgaissue.changestatus_issue(issue_id, payload, config) + print(r.status_code) + print(r.content) + #print(json.loads(r.content)) + if r.status_code == 200: + print("Sucessfully closed issue") + else: + print("Unsuccesful at closing issue,check logs") + else: + print("Unnsucessful conversion please check logs") + except requests.exceptions.RequestException as e: + print(e) + else: + print("Unsuccesful Conversion") + else: + print("Unsuccesful conversion") + except requests.exceptions.RequestException as e: + print(e) + else: + print("Unsuccesful Conversion") + except requests.exceptions.RequestException as e: + print("Failed to fetch attributes of the issue") + print(e) + else: + print("Unable to Convert Issue,Check logs and contact the developer", json.loads(r.content)) + except Exception as e: + print(e) + except requests.exceptions.RequestException as e: + print(e) + diff --git a/tga/userstory b/tga/userstory new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/tga/userstory From eaf8800cf5514aac1cd31def49dcbe3d790bfac7 Mon Sep 17 00:00:00 2001 From: Manas Date: Jun 19 2019 17:25:42 +0000 Subject: [PATCH 26/71] removed as per divide as per funcitonality --- diff --git a/convert.py b/convert.py deleted file mode 100644 index 566869c..0000000 --- a/convert.py +++ /dev/null @@ -1,185 +0,0 @@ -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 - -config = configparser.ConfigParser() -config.read('config.ini') -#config.read('%s' % (configpath)) -#config.read(['userconfig.ini', os.path.expanduser('~/.')]) - -service_id = config['TAIGA']['SERVICE_ID'] # service id -service_token = config['TAIGA']['SERVICE_TOKEN'] -project_id = config['TAIGA']['PROJECT_ID'] -taiga_url = config['TAIGA']['CUSTOM_TAIGA_URL'] -""" -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 convert(args, 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'] - taiga_url = config['TAIGA']['CUSTOM_TAIGA_URL'] - for _, value in args._get_kwargs(): # iteratingover name space object - for x in value: - try: - r = tgaissue.issue_get(x, config) # gets the issue - if r.status_code == 200: - data = json.loads(r.content) - print(data, "this is issue data") - details = data['description'] - subject = data['subject'] - issue_id = data['id'] - issue_version = data['version'] # fetch the id as well - #print(issue_id) - print("Step 1") - """ - 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 - issue_customattr = requests.get( - id_url, - headers=headers, - ) - """ - try: - r = tgaissue.issue_caget(issue_id, config) - if r.status_code == 200: - data = json.loads(r.content) - print(data, "step 2") - #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'] - fedora_version = data['attributes_values']['11383'] - print(fedora_version) - #print("summary", summary) - #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': project_id, - 'description': details, - 'subject': subject - } - #print(payload) - r = tgauserstory.post_us(payload, config) - #print(json.loads(r.content)) - data = json.loads(r.content) - #print(r.status_code) - if r.status_code == 201: - print("step 3") - data = json.loads(r.content) - us_id = data['id'] - print(id) - payload = { - "attributes_values": { - config['TAIGA']['US_CA_SYSTEM_WIDE_CHANGE']: system_wide_change, - config['TAIGA']['US_CA_SUMMARY']: summary, - config['TAIGA']['US_CA_RELENG_TICKET']: relengticket, - config['TAIGA']['US_CA_TRADEMARK_APPROVAL']: approval_required, - #config['TAIGA']['US_CA_OWNERS']: owners, - config['TAIGA']['US_CA_FESCO_TICKET']: 'random', - config['TAIGA']['US_CA_BUGZILLA_TRACKER']: 'random', - config['TAIGA']['US_CA_BUGZILLA_CONTACT']: bugzilla_id, - config['TAIGA']['US_CA_RELEASE_NOTES']: 'random', - config['TAIGA']['US_CA_CONTINGENCY']: contingency_deadline, - config['TAIGA']['US_CA_MASS_REBUILD']: mass_rebuild, - config['TAIGA']['US_CA_POLICY_CHANGE']: policy_change, - config['TAIGA']['US_CA_MODIFIES_DELIVERABLES']: modifies_deliverables - }, - "version": 1 - } - print(payload) - r = tgauserstory.post_usca(payload, us_id, config) - print(json.loads(r.content)) - print(r.status_code) - if r.status_code == 200: - print("Sucessfully converted issue to user story") - try: - r = tgaepic.list_epic(config) - data = json.loads(r.content) - if r.status_code == 200: - for i in data: - if i['subject'] == str(fedora_version): - epicid = i['id'] - epicref = i['ref'] - break - - r = tgaepic.post_relatedus(us_id, epicid, epicref, config) - if r.status_code == 201: - print("Sucessfully mapped epics") - r = tgaissue.issue_close(issue_id, issue_version, config) - print(r.status_code) - print(r.content) - #print(json.loads(r.content)) - if r.status_code == 200: - print("Sucessfully closed issue") - else: - print("Unsuccesful at closing issue,check logs") - else: - print("Unnsucessful conversion please check logs") - except requests.exceptions.RequestException as e: - print(e) - else: - print("Unsuccesful Conversion") - else: - print("Unsuccesful conversion") - except requests.exceptions.RequestException as e: - print(e) - else: - print("Unsuccesful Conversion") - except requests.exceptions.RequestException as e: - print("Failed to fetch attributes of the issue") - print(e) - else: - print("Unable to Convert Issue,Check logs and contact the developer", json.loads(r.content)) - except Exception as e: - print(e) - except requests.exceptions.RequestException as e: - print(e) - diff --git a/fesco.py b/fesco.py deleted file mode 100644 index bb94f93..0000000 --- a/fesco.py +++ /dev/null @@ -1,69 +0,0 @@ -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 From b7ada7e17118879bb49b9b98b4febceffc2393fb Mon Sep 17 00:00:00 2001 From: Manas Date: Jun 19 2019 17:26:19 +0000 Subject: [PATCH 27/71] minor fixes --- diff --git a/bz/bugzilla_auth.py b/bz/bugzilla_auth.py index ae5603c..6c4b14e 100644 --- a/bz/bugzilla_auth.py +++ b/bz/bugzilla_auth.py @@ -7,6 +7,7 @@ import binascii import getpass import configparser +"""" config = configparser.ConfigParser() config.read('config.ini') @@ -16,13 +17,22 @@ bz_url = config['BUGZILLA']['DEFAULT_BUGZILLA_URL'] # taiga server note custom_bz = config['BUGZILLA']['CUSTOM_BUGZILLA_URL'] """ + +""" bugzilla uses a api key to enable the api acess Currently there is a xml-rpc method to acess That method is going to be deprecated soon Thus the latest method uses API key to acess the api token.is sued by the modern rest api """ -def reset(): + + +def reset(configpath): + config = configparser.ConfigParser() + config.read(configpath) + service_id = config['BUGZILLA']['SERVICE_ID'] # service id + service_token = config['BUGZILLA']['SERVICE_TOKEN'] # service d for auth + bz_url = config['BUGZILLA']['BUGZILLA_URL'] # taiga server note print("You User Id and password will be securly store in the Keyring") username = input("Enter your user id for bugzilla: ") password = getpass.getpass("Enter your password for bugzilla: ") diff --git a/mail/climail.py b/mail/climail.py index d1fd906..56324e8 100644 --- a/mail/climail.py +++ b/mail/climail.py @@ -11,8 +11,7 @@ import editor from mail import maillist from tga import issues -config = configparser.ConfigParser() -config.read('config.ini') + """ service_id = config['EMAIL']['SERVICE_ID'] # service id # service_token = config['']['SERVICE_TOKEN'] @@ -49,41 +48,49 @@ def email_send(issueno): """ -def mails(args): - for _, value in args._get_kwargs(): - for x in value: +def mails(args, replyto, configpath): + config = configparser.ConfigParser() + config.read(configpath) + service_id = config['EMAIL']['SERVICE_ID'] + sender = config['EMAIL']['SENDER_EMAIL_ID'] + reciver = config['EMAIL']['LIST'] + print(args) + for x in args: + #for x in value: #ref = input("input the issue no you want to announce: ") - try: - r = issues.issue_get(x) - if r.status_code == 200: - data = json.loads(r.content) - print(data) - try: - ra = issues.issue_caget(data['id']) - if ra.status_code == 200: - cadata = json.loads(ra.content) - """ - body = '''\ - == Summary == - {} - == Owners == - {} - == 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)) - editor.edit(filename="mail.txt") - try: - maillist.email_send(data['subject']) - except Exception as e: - print(e) - else: - print("check logs") - except requests.exceptions.RequestException as e: - print(e) - else: - print("unable to send emails check logs") - except requests.exceptions.RequestException as e: - print(e) + try: + print(x) + r = issues.get_issue(x, config) + if r.status_code == 200: + data = json.loads(r.content) + print(data) + try: + ra = issues.caget_issue(data['id'], config) + if ra.status_code == 200: + cadata = json.loads(ra.content) + """ + body = '''\ + == Summary == + {} + == Owners == + {} + == 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)) + editor.edit(filename="mail.txt") + try: + subject = str(cadata['attributes_values']['11383']) + ":" + str(data['subject']) + maillist.email_send(subject, replyto, config) + except Exception as e: + print(e) + else: + print("check logs") + except requests.exceptions.RequestException as e: + print(e) + else: + print("unable to send emails check logs") + except requests.exceptions.RequestException as e: + print(e) diff --git a/mail/mailauth.py b/mail/mailauth.py index 8e0f690..11beb6e 100644 --- a/mail/mailauth.py +++ b/mail/mailauth.py @@ -4,13 +4,18 @@ import getpass import configparser import binascii +""" config = configparser.ConfigParser() config.read('config.ini') service_id = config['EMAIL']['SERVICE_ID'] +""" def reset(): + config = configparser.ConfigParser() + config.read('config.ini') + service_id = config['EMAIL']['SERVICE_ID'] print("You User Id and password will be securly store in the Keyring") username = input("Enter your id: ") password = getpass.getpass("Enter your password for email: ") diff --git a/mail/maillist.py b/mail/maillist.py index 6162f80..5936012 100644 --- a/mail/maillist.py +++ b/mail/maillist.py @@ -11,10 +11,11 @@ from email.mime.base import MIMEBase from email.mime.multipart import MIMEMultipart from email.mime.text import MIMEText +""" config = configparser.ConfigParser() config.read('config.ini') +""" -service_id = config['EMAIL']['SERVICE_ID'] # service id # service_token = config['']['SERVICE_TOKEN'] # pid = config['TAIGA']['PID'] """ @@ -28,9 +29,17 @@ else: print("please set proper test status in config") """ -def email_send(subject): + +def email_send(subject, replyto, config): + """ + config = configparser.ConfigParser() + config.read('config.ini') + """ + service_id = config['EMAIL']['SERVICE_ID'] # service id port = config['EMAIL']['PORT'] # For SSL smtp_server = config['EMAIL']['SMTP_SERVER'] + sender = config['EMAIL']['SENDER_EMAIL_ID'] + reciver = config['EMAIL']['LIST'] sender_email = sender # Enter your address """ awesome because it does automatically "cast" values @@ -38,8 +47,8 @@ def email_send(subject): https://stackoverflow.com/questions/335695/lists-in-configparser The answer below the selected/chosen answer """ - reciver_emaillist = json.loads(config.get("EMAIL","TEST_LIST")) - print(reciver_emaillist) + reciver_emaillist = json.loads(config.get("EMAIL", "LIST")) + print(type(reciver_emaillist)) #reciver_email = ['manas.man95@gmail.com', 'ttim3886@gmail.com'] #reciver_email = reciver_email.split(',') reciver_email = ', '.join(reciver_emaillist) @@ -63,7 +72,11 @@ def email_send(subject): msg['To'] = reciver_email msg['From'] = sender msg['Subject'] = subject - msg.add_header('reply-to', reciver_emaillist[0]) + print("this step") + if replyto == True: + msg.add_header('reply-to', reciver_email) + elif replyto == False: + msg.add_header('reply-to', reciver_emaillist[0]) with open("mail.txt", "r") as m_text: data = m_text.read()#.replace('\n', '') print(data) diff --git a/main.py b/main.py index 3633b74..9265b45 100644 --- a/main.py +++ b/main.py @@ -9,9 +9,10 @@ from pgure import pagure_auth from bz import bugzilla_auth from tga import issues as tgaissue from tga import userstory as tguserstory -from convert import convert +from tga import convert from mail import climail from mail import mailauth +from pgure import fesco class Change_Tool(object): @@ -20,7 +21,6 @@ class Change_Tool(object): description='Cli for Change Tool', usage='''change-tool []''' ) - parser.add_argument('command', help='Subcommand to run') # parse_args defaults to [1:] for args, but you need to # exclude the rest of the args too, or validation will fail @@ -35,7 +35,7 @@ class Change_Tool(object): def auth(self): parser = argparse.ArgumentParser( description='Module for authentication functions') - parser.add_argument('--auth', help='runs the auth instance') + # parser.add_argument('--auth', help='runs the auth instance') subparsers = parser.add_subparsers(dest='command', help='sub-command help') # Subparser for taiga @@ -55,32 +55,39 @@ class Change_Tool(object): email = subparsers.add_parser('email', help='email auth module') email.add_argument('--reset', action='store_true', help='sets/resets teh email adress') - + parser.add_argument('--config', + #dest='configpath', + #action='store', + #type=string, + default='config.ini', + help='Sets config path') args = parser.parse_args(sys.argv[2:]) - if args.auth: - print("Incomplete command,please specify the auth") + configpath = args.config + print(configpath) # debug only + print(args) # debug only + # print(args) # debug only if args.command == 'taiga': if args.token: - taiga_auth.refresh_token() + taiga_auth.refresh_token(args.config) elif args.reset: - taiga_auth.reset() + taiga_auth.reset(args.config) else: print("Wrong command") elif args.command == 'pagure': if args.reset: - pagure_auth.reset() + pagure_auth.reset(args.config) else: print("Wrong command") elif args.command == 'bugzilla': if args.token: - bugzilla_auth.refresh_token() + bugzilla_auth.refresh_token(args.config) elif args.reset: - bugzilla_auth.reset() + bugzilla_auth.reset(args.config) else: print("Wrong command,please check documentation for the proper command") elif args.command == 'email': if args.reset: - mailauth.reset() + mailauth.reset(args.config) else: print("Wrong Command check documentation") else: @@ -95,17 +102,18 @@ class Change_Tool(object): parser.add_argument('--taiga', nargs='+', type=int, - help="Converts Issue to User Story") + help='Converts Issue to User Story') parser.add_argument('--config', - action='store', - type=string, - dest='configPath', - default='"%s/config.ini" % (expanduser("~))', - required=False, + #dest='configpath', + #action='store', + #type=string, + default='config.ini', help='Sets config path') args = parser.parse_args(sys.argv[2:]) - # print(args) # Debug only - convert(args,configPath) + configpath = args.config + print(configpath) # Debug only + print(args) # debug only + convert.convert(args.taiga, args.config) def list(self): parser = argparse.ArgumentParser( @@ -119,17 +127,24 @@ class Change_Tool(object): userstory = subparser.add_parser('userstory', help='Lists user stories') userstory.add_argument('--pending', action='store_true', help='lists pending users stories') + parser.add_argument('--config', + #action='store', + #type=string, + #dest='configpath', + default='config.ini', + #required=False, + help='Sets config path') args = parser.parse_args(sys.argv[2:]) if args.list: print("Incomplete command,please specify right sub-command") if args.command == 'issue': if args.pending: - tguserstory.list_us() + tguserstory.list_us(configpath) else: print("wrong command") elif args.command == 'userstory': if args.pending: - tgaissue.issue_list() + tgaissue.issue_list(configpath) else: print("Wrong command") else: @@ -141,11 +156,47 @@ class Change_Tool(object): parser.add_argument('--ml', nargs='+', type=int, - help="Announces to Mailing list") + help='Announces to Mailing list') + parser.add_argument('--reply', + #nargs='+', + action='store_true', + help="""Option to set reply to header + if not set defaults reply to all recivers + listed in config""") + parser.add_argument('--config', + #dest='configpath', + #action='store', + #type=string, + default='config.ini', + help='Sets config path') args = parser.parse_args(sys.argv[2:]) + configpath = args.config + print(configpath) + #print(args) + print(args.reply) # print(args) # debug only - climail.mails(args) + climail.mails(args.ml, args.reply, args.config) + def fesco(self): + parser = argparse.ArgumentParser( + description='Creates a Issue on fesco repo on pagure') + parser.add_argument('--fesco', + nargs='+', + type=int, + help='Announces to Fesco') + parser.add_argument('--config', + #dest='configpath', + #action='store', + #type=string, + default='config.ini', + help='Sets config path') + args = parser.parse_args(sys.argv[2:]) + configpath = args.config + print(configpath) + print(args) + # print(args) # debug only + fesco.fesissue(args.fesco, args.config) + """ def config(self): parser = argparse.ArgumentParser( description='sets the user defined config') @@ -157,7 +208,7 @@ class Change_Tool(object): help='configPath is set') args = parser.parse_args(sys.argv[2:]) - + """ """ def accept(self): parser = argparse.ArgumentParser( diff --git a/tga/epics.py b/tga/epics.py index 7534053..d690a32 100644 --- a/tga/epics.py +++ b/tga/epics.py @@ -3,9 +3,11 @@ import configparser import keyring import requests +""" 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'] @@ -19,16 +21,25 @@ elif config['TAIGA']['TEST'] == 'no': else: print("please set test status in config") """ - +""" headers = { 'Content-Type': 'application/json', 'Authorization': 'Bearer {0}'.format(keyring.get_password(config['TAIGA']['SERVICE_TOKEN'], "taiga_token")) } +""" def list_epic(config): try: - url = str(taiga_url) + "/api/v1/epics?project=" + str(config['TAIGA']['PROJECT_ID']) + """ + config = configparser.ConfigParser() + config.read(configpath) + """ + headers = { + 'Content-Type': 'application/json', + 'Authorization': 'Bearer {0}'.format(keyring.get_password(config['TAIGA']['SERVICE_TOKEN'], "taiga_token")) + } + url = str(config['TAIGA']['TAIGA_URL']) + "/api/v1/epics?project=" + str(config['TAIGA']['PROJECT_ID']) r = requests.get( url, headers=headers @@ -40,6 +51,15 @@ def list_epic(config): def post_relatedus(us_id, epicid, epicref, config): try: + """ + config = configparser.ConfigParser() + config.read(configpath) + """ + url = str(config['TAIGA']['TAIGA_URL']) + '/api/v1/epics/' + str(epicid) + '/related_userstories', + headers = { + 'Content-Type': 'application/json', + 'Authorization': 'Bearer {0}'.format(keyring.get_password(config['TAIGA']['SERVICE_TOKEN'], "taiga_token")) + } payload = { "epic": epicid, "user_story": us_id diff --git a/tga/issues.py b/tga/issues.py index 980c67d..b685845 100644 --- a/tga/issues.py +++ b/tga/issues.py @@ -29,8 +29,12 @@ headers = { """ -def issue_list(config): +def list_issue(config): try: + """ + config = configparser.ConfigParser() + config.read(configpath) + """ url = str(config['TAIGA']['TAIGA_URL']) + "/api/v1/issues?project=" + str(config['TAIGA']['PROJECT_ID']) + "\&status=" + str(config['TAIGA']['IS_STATUS_NEW']) print(url) # Debug only headers = { @@ -65,8 +69,17 @@ def issue_list(config): print(e) -def issue_get(x, config): +def get_issue(x, config): try: + """ + config = configparser.ConfigParser() + config.read(configpath) + """ + headers = { + 'Content-Type': 'application/json', + 'Authorization': 'Bearer {0}'.format(keyring.get_password(config['TAIGA']['SERVICE_TOKEN'], "taiga_token")) + # 'Authorization': 'Bearer {0}'.format(str(123)) + } url = str(config['TAIGA']['TAIGA_URL']) + "/api/v1/issues/by_ref?ref=" + str(x) + "&project=" + str(config['TAIGA']['PROJECT_ID']) print(url) # debug/dev env only @@ -79,10 +92,18 @@ def issue_get(x, config): print(e) -def issue_caget(x, config): +def caget_issue(x, config): """ Gets custom attributes from taiga for issue + + config = configparser.ConfigParser() + config.read(configpath) """ + headers = { + 'Content-Type': 'application/json', + 'Authorization': 'Bearer {0}'.format(keyring.get_password(config['TAIGA']['SERVICE_TOKEN'], "taiga_token")) + # 'Authorization': 'Bearer {0}'.format(str(123)) + } print(x) id_url = str(config['TAIGA']['TAIGA_URL']) + "/api/v1/issues/custom-attributes-values/" + str(x) # x is id print(id_url) @@ -96,12 +117,23 @@ def issue_caget(x, config): print(e) -def issue_close(x, issue_version, config): +def changestatus_issue(x, payload, config): + """ + config = configparser.ConfigParser() + config.read(configpath) + """ id_url = str(config['TAIGA']['TAIGA_URL']) + "/api/v1/issues/" + str(x) # x is id + headers = { + 'Content-Type': 'application/json', + 'Authorization': 'Bearer {0}'.format(keyring.get_password(config['TAIGA']['SERVICE_TOKEN'], "taiga_token")) + # 'Authorization': 'Bearer {0}'.format(str(123)) + } + """ payload = { 'status': config['TAIGA']['IS_STATUS_PROCESSED'], 'version': issue_version } + """ try: r = requests.patch( id_url, diff --git a/tga/taiga_auth.py b/tga/taiga_auth.py index e115f2d..fc7b6c4 100644 --- a/tga/taiga_auth.py +++ b/tga/taiga_auth.py @@ -8,7 +8,7 @@ import getpass import configparser import keyring - +""" config = configparser.ConfigParser() config.read(config(filename)) @@ -19,6 +19,7 @@ service_token = config['TAIGA']['SERVICE_TOKEN'] # service d for auth project_id = config['TAIGA']['PROJECT_ID'] taiga_url = config['TAIGA']['TAIGA_URL'] """ +""" if config['TAIGA']['TEST'] == 'yes': taiga_url = config['TAIGA']['CUSTOM_TAIGA_URL'] elif config['TAIGA']['TEST'] == 'no': @@ -26,9 +27,6 @@ elif config['TAIGA']['TEST'] == 'no': else: print("please set test status in config") """ -headers = { - 'Content-Type': 'application/json', -} def refresh_token(filename): @@ -40,6 +38,9 @@ def refresh_token(filename): """ config = configparser.ConfigParser() config.read(config(filename)) + headers = { + 'Content-Type': 'application/json', + } service_id = config['TAIGA']['SERVICE_ID'] project_id = config['TAIGA']['PROJECT_ID'] taiga_url = config['TAIGA']['TAIGA_URL'] @@ -77,6 +78,9 @@ def refresh_token(filename): def reset(filename): config = configparser.ConfigParser() config.read(config(filename)) + headers = { + 'Content-Type': 'application/json', + } service_id = config['TAIGA']['SERVICE_ID'] print("You User Id and password will be securly store in the Keyring") username = input("Enter your user id for taiga: ") diff --git a/tga/userstory.py b/tga/userstory.py index 1bdeea6..9221cb6 100644 --- a/tga/userstory.py +++ b/tga/userstory.py @@ -6,10 +6,11 @@ import requests 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'] status = config['TAIGA']['TEST_US_STATUS_NEW'] @@ -18,17 +19,26 @@ elif config['TAIGA']['TEST'] == 'no': status = config['TAIGA']['US_STATUS_NEW'] else: print("please set test status in config") -""" headers = { 'Content-Type': 'application/json', 'Authorization': 'Bearer {0}'.format(keyring.get_password(service_token, "taiga_token")) } +""" def get_us(refusid, config): try: - url = str(taiga_url) + "/api/v1/userstories/by_ref?ref=" + str(refusid) + "\&project=" + str(project_id) + """ + config = configparser.ConfigParser() + config.read(configpath) + """ + headers = { + 'Content-Type': 'application/json', + 'Authorization': 'Bearer {0}'.format(keyring.get_password(config['TAIGA']['SERVICE_TOKEN'], "taiga_token")) + # 'Authorization': 'Bearer {0}'.format(str(123)) + } + url = str(config['TAIGA']['TAIGA_URL']) + "/api/v1/userstories/by_ref?ref=" + str(refusid) + "\&project=" + str(config['TAIGA']['PROJECT_ID']) print(url) # debug only r = requests.get( url, @@ -41,7 +51,16 @@ def get_us(refusid, config): def list_us(config): try: - url = str(taiga_url) + "/api/v1/issues/userstories?project=" + str(project_id) + "\&status=" + str(status) + """ + config = configparser.ConfigParser() + config.read(configpath) + """ + headers = { + 'Content-Type': 'application/json', + 'Authorization': 'Bearer {0}'.format(keyring.get_password(config['TAIGA']['SERVICE_TOKEN'], "taiga_token")) + # 'Authorization': 'Bearer {0}'.format(str(123)) + } + url = str(config['TAIGA']['TAIGA_URL']) + "/api/v1/issues/userstories?project=" + str(config['TAIGA']['PROJECT_ID']) + "\&status=" + str(config['TAIGA']['US_STATUS_NEW']) print(url) # Debug only try: r = requests.get( @@ -72,6 +91,15 @@ def list_us(config): def post_us(x, config): try: + """ + config = configparser.ConfigParser() + config.read(configpath) + """ + headers = { + 'Content-Type': 'application/json', + 'Authorization': 'Bearer {0}'.format(keyring.get_password(config['TAIGA']['SERVICE_TOKEN'], "taiga_token")) + # 'Authorization': 'Bearer {0}'.format(str(123)) + } r = requests.post( 'https://api.taiga.io/api/v1/userstories', data=json.dumps(x), @@ -84,6 +112,15 @@ def post_us(x, config): def post_usca(x, id, config): try: + """ + config = configparser.ConfigParser() + config.read(configpath) + """ + headers = { + 'Content-Type': 'application/json', + 'Authorization': 'Bearer {0}'.format(keyring.get_password(config['TAIGA']['SERVICE_TOKEN'], "taiga_token")) + # 'Authorization': 'Bearer {0}'.format(str(123)) + } r = requests.patch( 'https://api.taiga.io/api/v1/userstories/custom-attributes-values/' + str(id), data=json.dumps(x), From 04e289dbedbbdb47bb432923a3a7466bc5030c51 Mon Sep 17 00:00:00 2001 From: Manas Date: Jun 19 2019 17:26:43 +0000 Subject: [PATCH 28/71] pip freezed requirements --- diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..d975f77 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,71 @@ +apturl==0.5.2 +asn1crypto==0.24.0 +Brlapi==0.6.6 +bugzilla==1.0.0 +certifi==2019.3.9 +cffi==1.12.3 +chardet==3.0.4 +command-not-found==0.3 +cryptography==2.6.1 +cupshelpers==1.0 +dbus-python==1.2.8 +defer==1.0.6 +distro-info===0.18ubuntu0.18.04.1 +entrypoints==0.3 +flake8==3.7.7 +httplib2==0.9.2 +idna==2.8 +jeepney==0.4 +keyring==19.0.2 +keyrings.alt==3.0 +language-selector==0.1 +launchpadlib==1.10.6 +lazr.restfulclient==0.13.5 +lazr.uri==1.0.3 +louis==3.5.0 +macaroonbakery==1.1.3 +Mako==1.0.7 +MarkupSafe==1.0 +mccabe==0.6.1 +netifaces==0.10.4 +oauth==1.0.1 +olefile==0.45.1 +pexpect==4.2.1 +Pillow==5.1.0 +protobuf==3.0.0 +psutil==5.6.1 +pycairo==1.16.2 +pycodestyle==2.5.0 +pycparser==2.19 +pycrypto==2.6.1 +pycups==1.9.73 +pyflakes==2.1.1 +pygobject==3.26.1 +pymacaroons==0.13.0 +PyNaCl==1.1.2 +pyRFC3339==1.0 +python-apt==1.6.4 +python-dateutil==2.6.1 +python-debian==0.1.32 +python-editor==1.0.4 +pytz==2018.3 +pyxdg==0.25 +PyYAML==3.12 +reportlab==3.4.0 +requests==2.22.0 +requests-unixsocket==0.1.5 +screen-resolution-extra==0.0.0 +SecretStorage==3.1.1 +simplejson==3.13.2 +six==1.12.0 +system-service==0.3 +systemd-python==234 +ubuntu-drivers-common==0.0.0 +ufw==0.36 +unattended-upgrades==0.1 +urllib3==1.25.2 +usb-creator==0.3.3 +virtualenv==15.1.0 +wadllib==1.3.2 +xkit==0.0.0 +zope.interface==4.3.2 From c6c93b7d11cd9905a40bfcb762c97167cb21bdbf Mon Sep 17 00:00:00 2001 From: Manas Date: Jun 19 2019 17:27:37 +0000 Subject: [PATCH 29/71] Pagure issue creation ,not working payload pagure error --- diff --git a/config.ini b/config.ini index 2d7a47e..8ae6752 100644 --- a/config.ini +++ b/config.ini @@ -8,6 +8,7 @@ TAIGA_SITE_ISSUE_URL = https://tree.taiga.io/project/pac_23-test-changes-tracker IS_STATUS_NEW = 2283176 IS_STATUS_NEEDS_INFO = 2283180 IS_STATUS_READY_FOR_WRANGLER = 2283232 +IS_STATUS_READY_FOR_FESCO = 2295359 IS_STATUS_PROCESSED = 2283182 US_STATUS_NEW = 1952887 US_STATUS_ANNOUNCED = 1952888 @@ -38,7 +39,7 @@ US_CA_RELENG_TICKET = 21926 US_CA_TRADEMARK_APPROVAL = 21927 US_CA_OWNERS = 21928 US_CA_FESCO_TICKET = 21929 -US_cA_BUGZILLA_TRACKER = 21930 +US_CA_BUGZILLA_TRACKER = 21930 US_CA_RELEASE_NOTES = 21931 US_CA_CONTINGENCY = 21932 US_CA_MASS_REBUILD = 21933 @@ -48,19 +49,19 @@ US_CA_MODIFIES_DELIVERABLES = 21935 [PAGURE] SERVICE_ID = pagure +API_URL = https://pagure.io/api/0/fedora-change-wrangler [BUGZILLA] SERVICE_ID = bugzilla SERVICE_TOKEN = bugzilla_auth -project_id = 315827 # for test only -DEFAULT_BUGZILLA_URL = https://bugzilla.redhat.com/ +PROJECT_ID = 315827 # for test only +BUGZILLA_URL = https://bugzilla.redhat.com/ ; TEST = no [EMAIL] SERVICE_ID = email -DEFAULT_EMAIL_ID = bcotton@redhat.org -CUSTOM_EMAIL_ID = manasmangaonkar@gmail.com -LIST: ["manas.man95@gmail.com","bcotton@redhat.org"] +SENDER_EMAIL_ID = manasmangaonkar@gmail.com +LIST: ["manas.man95@gmail.com","ttim3886@gmail.com"] ; LIST: [devel@lists.fedoraproject.org,devel-announce@lists.fedoraproject.org] PORT = 465 SMTP_SERVER = smtp.gmail.com diff --git a/pgure/issues.py b/pgure/issues.py index e10ae62..e4fe0c6 100644 --- a/pgure/issues.py +++ b/pgure/issues.py @@ -1,23 +1,85 @@ -import requets -import config +import requests +import configparser +import keyring +import json +""" headers = { - 'Content-Type': 'application/json', + 'Content-Type': 'application/x-www-form-urlencoded', 'Authorization': token {}.format(keyring.get_password(service_token, "repo_name")) } +""" -def list_issue(): + +def list_issue(config): """kusts ussyes""" + try: + """ + repo_name = (config['PAGURE']['SERVICE_ID'], "repo_name") + print(repo_name) + """ + headers = { + 'Content-Type': 'application/x-www-form-urlencoded', + 'Authorization': 'token {0}'.format(keyring.get_password(config['PAGURE']['SERVICE_ID'], "repo_name")) + } + url = str(config['PAGURE']['URL']) + '/issues' + + r = requests.get( + url, + headers=headers, + ) + return r + except requests.exceptions.RequestException as e: + print(e) + except Exception as e: + print(e) -def get_issue(): +def get_issue(issueid, config): """gets issue from pagure""" + try: + """ + repo_name = (config['PAGURE']['SERVICE_ID'], "repo_name") + print(repo_name) + """ + headers = { + 'Content-Type': 'application/x-www-form-urlencoded', + 'Authorization': 'token {0}'.format(keyring.get_password(config['PAGURE']['SERVICE_ID'], "repo_name")) + } + url = str(config['PAGURE']['URL']) + "/issue/" + str(issueid) + + r = requests.get( + url, + headers=headers, + ) + return r + except requests.exceptions.RequestException as e: + print(e) + except Exception as e: + print(e) -def post_issue(config): +def post_issue(payload, config): """ Posts issue to pagure """ try: - - print() - - + #repo_name = (config['PAGURE']['SERVICE_ID'], "repo_name") + #print(repo_name) + headers = { + #'Content-Type': 'application/x-www-form-urlencoded', + 'Authorization': 'token {0}'.format(keyring.get_password(config['PAGURE']['SERVICE_ID'], "repo_name")) + } + print(headers) + url = str(config['PAGURE']['API_URL']) + '/new_issue' + #print(data) # debug only + print(url) + print(payload) + r = requests.post( + url, + data=json.dumps(payload), + headers=headers + ) + return r + except requests.exceptions.RequestException as e: + print(e) + except Exception as e: + print(e) \ No newline at end of file diff --git a/pgure/pagure_auth.py b/pgure/pagure_auth.py index dfe3ebb..cf26169 100644 --- a/pgure/pagure_auth.py +++ b/pgure/pagure_auth.py @@ -7,20 +7,21 @@ import binascii import getpass import configparser -config = configparser.ConfigParser() -config.read('config.ini') - -def reset(): +def reset(configpath): + config = configparser.ConfigParser() + config.read(configpath) print("Your auth token will be securly store in the Keyring") # username = input("Enter your user id for taiga: ") - api_token = "api_token" + service_id = config['PAGURE']['SERVICE_ID'] repo_name = input("Enter the repo name you want to set api key for: ") token = getpass.getpass("Enter your token for" + ' ' + repo_name + ' ' "repository: ") try: # keyring.set_password("taiga", username) - keyring.set_password(repo_name, api_token, token) + keyring.set_password(service_id, "repo_name", repo_name) + keyring.set_password(service_id, repo_name, str(token)) print("token reset succesfully") except (keyring.errors.PasswordSetError, Exception) as e: print("Failed to reset token") + print(e) # print(e + "Contact the developers asap") From c9aef6d8f9d66be9c6fa226ce6345df3e3ae240c Mon Sep 17 00:00:00 2001 From: Manas Date: Jun 21 2019 14:39:47 +0000 Subject: [PATCH 30/71] pagure post issues fixed --- diff --git a/pgure/fesco.py b/pgure/fesco.py index 809c145..6192076 100644 --- a/pgure/fesco.py +++ b/pgure/fesco.py @@ -54,36 +54,40 @@ def fesissue(args, configpath): relengticket = data['attributes_values']['11371'] fedora_version = data['attributes_values']['11383'] 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("pagure_issue.txt", "w+") as p_txt: - p_txt.write("{}\n\n*{}\n*{}\n*{}\n*{}\n".format(summary, taiga_issue_link, maillist_link, maillist_dsc_list, owner)) - editor.edit(filename="pagure_issue.txt") + with open("fesco_issue.txt", "w+") as pg_txt: + pg_txt.write("{}\n\n*{}\n*{}\n*{}\n*{}\n".format(summary, taiga_issue_link, maillist_link, maillist_dsc_list, owner)) + editor.edit(filename="fesco_issue.txt") try: - with open("pagure_issue.txt", "r") as pg_txt: + with open("fesco_issue.txt", "r") as pg_txt: issue_text = pg_txt.read() if system_wide_change == True: syschange = "System-Wide Change" elif system_wide_change == False: syschange = "Self-Contained Change" - title = str(fedora_version) + ' ' + str(syschange) + ':' + str(subject) + title = "F" + str(fedora_version) + ' ' + str(syschange) + ':' + str(subject) print(issue_text) payload = { 'title': title, 'issue_content': issue_text } - print(title,payload) - r = pgaissues.post_issue(payload, config) + print(title, payload) + repo = config['PAGURE']['FESCO_REPO'] + r = pgaissues.post_issue(payload, repo, config) print(r) if r.status_code == 200: payload = { 'status': config['TAIGA']['IS_STATUS_READY_FOR_FESCO'], 'version': taiga_issue_version } - r = chagnestatus_issue(taiga_issue_id, payload, config) + r = tgaissue.changestatus_issue(taiga_issue_id, payload, config) print("Succesfully posted issue") else: print("Check logs for errors",json.loads(r.content)) diff --git a/pgure/issues.py b/pgure/issues.py index e4fe0c6..60e0c64 100644 --- a/pgure/issues.py +++ b/pgure/issues.py @@ -19,7 +19,7 @@ def list_issue(config): print(repo_name) """ headers = { - 'Content-Type': 'application/x-www-form-urlencoded', + 'Content-Type': 'application/json', 'Authorization': 'token {0}'.format(keyring.get_password(config['PAGURE']['SERVICE_ID'], "repo_name")) } url = str(config['PAGURE']['URL']) + '/issues' @@ -43,7 +43,7 @@ def get_issue(issueid, config): print(repo_name) """ headers = { - 'Content-Type': 'application/x-www-form-urlencoded', + 'Content-Type': 'application/json', 'Authorization': 'token {0}'.format(keyring.get_password(config['PAGURE']['SERVICE_ID'], "repo_name")) } url = str(config['PAGURE']['URL']) + "/issue/" + str(issueid) @@ -59,17 +59,17 @@ def get_issue(issueid, config): print(e) -def post_issue(payload, config): +def post_issue(payload, repo, config): """ Posts issue to pagure """ try: #repo_name = (config['PAGURE']['SERVICE_ID'], "repo_name") #print(repo_name) headers = { - #'Content-Type': 'application/x-www-form-urlencoded', + 'Content-Type': 'application/json', 'Authorization': 'token {0}'.format(keyring.get_password(config['PAGURE']['SERVICE_ID'], "repo_name")) } print(headers) - url = str(config['PAGURE']['API_URL']) + '/new_issue' + url = str(config['PAGURE']['API_URL']) + '/' + repo + '/new_issue' #print(data) # debug only print(url) print(payload) From a326c41819d202e173941d27573bce53079cc110 Mon Sep 17 00:00:00 2001 From: Manas Date: Jun 21 2019 14:40:22 +0000 Subject: [PATCH 31/71] accept stage of tool --- diff --git a/bz/accept.py b/bz/accept.py new file mode 100644 index 0000000..568f33a --- /dev/null +++ b/bz/accept.py @@ -0,0 +1,122 @@ +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(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: + convert = convert.convert(x, configpath) + if convert == True: + bz = pgba.pgbz(x, 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") + except Exception as e: + print(e, /n"Unable to accept the Change Proposal") + diff --git a/bz/bugs.py b/bz/bugs.py new file mode 100644 index 0000000..19fca49 --- /dev/null +++ b/bz/bugs.py @@ -0,0 +1,27 @@ +import requests +import configparser +import keyring +import json + + +def post_bug(payload, config): + try: + """ + config = configparser.ConfigParser() + config.read(configpath) + """ + headers = { + 'Content-Type': 'application/json', + 'Authorization': 'Bearer {0}'.format(keyring.get_password(config['TAIGA']['SERVICE_TOKEN'], "taiga_token")) + # 'Authorization': 'Bearer {0}'.format(str(123)) + } + url = str(config['BUGZILLA']['BUGZILLA_URL']) + "/rest/bug" + print(url) # debug/dev env only + r = requests.get( + url, + headers=headers, + data=json.dumps(payload) + ) + return r + except requests.exceptions.RequestException as e: + print(e) diff --git a/bz/pgba.py b/bz/pgba.py new file mode 100644 index 0000000..39d26f3 --- /dev/null +++ b/bz/pgba.py @@ -0,0 +1,128 @@ +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 pgure import issues as pgaissues +from bz import bugs as bzbugz + + +def pgtobz: + 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: + print("Sucessful Bugzilla Bug Creation") + 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) + print("Sucessful creation of issue on pagure release notes") + return True + except requests.exceptions.RequestException as e: + print("Failed to fetch attributes of the issue") + print(e) + except Exception as e: + print(e) + else: + print("Unable to Create bug check logs for errors") + except requests.exceptions.RequestException as e: + print("Failed to fetch attributes of the issue") + print(e) + except Exception as e: + print(e) + except requests.exceptions.RequestException as e: + print("Failed to fetch attributes of the issue") + print(e) + except Exception as e: + print(e) + else: + print("Cant fetch attributes from Taiga") + except requests.exceptions.RequestException as e: + print("Failed to fetch attributes of the issue") + print(e) + except Exception as e: + print(e) + except requests.exceptions.RequestException as e: + print("Failed to fetch attributes of the issue") + print(e) + except Exception as e: + print(e) + diff --git a/config_depre.ini b/config_depre.ini new file mode 100644 index 0000000..5616928 --- /dev/null +++ b/config_depre.ini @@ -0,0 +1,82 @@ +[TAIGA] +SERVICE_ID = taiga +SERVICE_TOKEN = taiga_auth +PROJECT_ID = 325667 +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/ +IS_STATUS_NEW = 21 +IS_STATUS_NEEDS_INFO = 22 +IS_STATUS_READY_FOR_WRANGLER = 12 +IS_STATUS_PROCESSED = 24 +IS_CA_VERSION = 25 +US_STATUS_ANNOUNCED = 25 +US_STATUS_R_FESCO = 30 +US_STATUS_ACCEPTED = 31 +US_STATUS_ARCHIVED = 32 +US_STATUS_CODE_COMPLETE = 33 +US_STATUS_TESTABLE = 34 + +TEST_IS_STATUS_NEW = 2283176 +TEST_IS_STATUS_NEEDS_INFO = 2283180 +TEST_IS_STATUS_READY_FOR_WRANGLER = 2283232 +TEST_IS_STATUS_PROCESSED = 2283182 +TEST_US_STATUS_NEW = 1952887 +TEST_US_STATUS_ANNOUNCED = 1952888 +TEST_US_STATUS_R_FESCO = 1952889 +TEST_US_STATUS_ACCEPTED = 1952891 +TEST_US_STATUS_ARCHIVED = 1952890 +TEST_US_STATUS_CODE_COMPLETE = 1892839 +TEST_US_STATUS_TESTABLE = 1952932 + +TEST_IS_CA_SYSTEM_WIDE_CHANGE = 11370 +TEST_IS_CA_SUMMARY = 11372 +TEST_IS_CA_BUGZILLA_CONTACT = 11373 +TEST_IS_CA_RELENG_TICKET = 11371 +TEST_IS_CA_TRADEMARK_APPROVAL = 11374 +TEST_IS_CA_OWNERS = 11375 +TEST_IS_CA_FESCO_TICKET = 534454574 +TEST_IS_CA_BUGZILLA_TRACKER = 21930 +TEST_IS_CA_RELEASE_NOTES = 21931 +TEST_IS_CA_CONTINGENCY = 11376 +TEST_IS_CA_MASS_REBUILD = 11377 +TEST_IS_CA_POLICY_CHANGE = 11378 +TEST_IS_CA_MODIFIES_DELIVERABLES = 11379 +TEST_IS_CA_VERSION = 11383 +TEST_US_CA_SYSTEM_WIDE_CHANGE = 21923 +TEST_US_cA_SUMMARY = 21924 +TEST_US_CA_BUGZILLA_CONTACT = 21925 +TEST_US_CA_RELENG_TICKET = 21926 +TEST_US_CA_TRADEMARK_APPROVAL = 21927 +TEST_US_CA_OWNERS = 21928 +TEST_US_CA_FESCO_TICKET = 21929 +TEST_US_cA_BUGZILLA_TRACKER = 21930 +TEST_US_CA_RELEASE_NOTES = 21931 +TEST_US_CA_CONTINGENCY = 21932 +TEST_US_CA_MASS_REBUILD = 21933 +TEST_US_CA_POLICY_CHANGE = 21934 +TEST_US_CA_MODIFIES_DELIVERABLES = 21935 +TEST = yes + +[PAGURE] +SERVICE_ID = pagure + +[BUGZILLA] +SERVICE_ID = bugzilla +SERVICE_TOKEN = bugzilla_auth +project_id = 315827 # for test only +DEFAULT_BUGZILLA_URL = https://bugzilla.redhat.com/ +CUSTOM_BUGZILLA_URL = https://bugzilla.redhat.com/ +TEST = no + +[EMAIL] +SERVICE_ID = email +DEFAULT_EMAIL_ID = bcotton@redhat.org +CUSTOM_EMAIL_ID = manasmangaonkar@gmail.com +TEST_LIST: ["manas.man95@gmail.com","bcotton@redhat.org"] +LIST: [devel@lists.fedoraproject.org,devel-announce@lists.fedoraproject.org] +PORT = 465 +SMTP_SERVER = smtp.gmail.com +TEST = yes +# 1892835 + From 423c06d2729288737f992571e89dcb7013ed769e Mon Sep 17 00:00:00 2001 From: Manas Date: Jun 21 2019 16:24:47 +0000 Subject: [PATCH 32/71] fix configparser typo in taiga auth --- diff --git a/config.ini b/config.ini index 8ae6752..125a458 100644 --- a/config.ini +++ b/config.ini @@ -49,7 +49,9 @@ US_CA_MODIFIES_DELIVERABLES = 21935 [PAGURE] SERVICE_ID = pagure -API_URL = https://pagure.io/api/0/fedora-change-wrangler +API_URL = https://pagure.io/api/0/ +FESCO_REPO = fedora-change-wrangler +RELEASE_NOTES_REPO = Test-for-Release-Notes [BUGZILLA] SERVICE_ID = bugzilla diff --git a/tga/taiga_auth.py b/tga/taiga_auth.py index fc7b6c4..ddcc37e 100644 --- a/tga/taiga_auth.py +++ b/tga/taiga_auth.py @@ -37,11 +37,12 @@ def refresh_token(filename): Doing the follwoing in prod is security risk. """ config = configparser.ConfigParser() - config.read(config(filename)) + config.read(filename) headers = { 'Content-Type': 'application/json', } service_id = config['TAIGA']['SERVICE_ID'] + service_token = config['TAIGA']['SERVICE_TOKEN'] project_id = config['TAIGA']['PROJECT_ID'] taiga_url = config['TAIGA']['TAIGA_URL'] username = keyring.get_password(service_id, "taiga_username") @@ -69,6 +70,7 @@ def refresh_token(filename): print("succesful authentication") except (keyring.errors.PasswordSetError, Exception) as e: print("Failed to set auth token") + print(e) elif r.status_code == 400: print("auth error") except requests.exceptions.RequestException as e: @@ -77,7 +79,7 @@ def refresh_token(filename): def reset(filename): config = configparser.ConfigParser() - config.read(config(filename)) + config.read(filename) headers = { 'Content-Type': 'application/json', } From 2a6124c438c94f2c233d7e12e7e6f1b91cea3cdd Mon Sep 17 00:00:00 2001 From: Manas Date: Jun 21 2019 16:42:23 +0000 Subject: [PATCH 33/71] fix fesco issue formatting --- diff --git a/pgure/fesco.py b/pgure/fesco.py index 6192076..4d133e0 100644 --- a/pgure/fesco.py +++ b/pgure/fesco.py @@ -63,7 +63,7 @@ def fesissue(args, configpath): maillist_dsc_list = "random" owner = "@" + str(owner) with open("fesco_issue.txt", "w+") as pg_txt: - pg_txt.write("{}\n\n*{}\n*{}\n*{}\n*{}\n".format(summary, taiga_issue_link, maillist_link, maillist_dsc_list, owner)) + pg_txt.write("{}\n\n * [Change Proposal]({})\n * [devel-announce post]({})\n * [devel list discussion]({})\n * owner:{}\n".format(summary, taiga_issue_link, maillist_link, maillist_dsc_list, owner)) editor.edit(filename="fesco_issue.txt") try: with open("fesco_issue.txt", "r") as pg_txt: From 2105c313e589e1012880f6e58b11ed78f9a304e3 Mon Sep 17 00:00:00 2001 From: Manas Date: Jun 26 2019 14:57:44 +0000 Subject: [PATCH 34/71] basic readme added --- diff --git a/ReadMe.md b/ReadMe.md new file mode 100644 index 0000000..c7d9f56 --- /dev/null +++ b/ReadMe.md @@ -0,0 +1,46 @@ +## Basic usage + +python3.6 main.py auth taiga --token +Refreshes/Fetches new token from taiga + +python3.6 main.py auth taiga --reset +Resets/Sets the Username and Password in the keyring for taiga + +python3.6 main.py auth pagure --whoami +To check if pagure can identify you and if token is valid + +python3.6 main.py auth pagure --reset +Resets/Sets the Username and Password in the keyring for pagure + +python3.6 main.py auth bugzilla --reset +Resets/Sets the Username and Password in the keyring for Bugzilla + +python3.6 main.py auth email --reset +Resets/Sets the Username and Password in the keyring for Email + +python3.6 main.py convert --taiga x +Converts issue to user story in taiga the "X" stands for the issue refrence no +i.e python3.6 main.py convert --taiga 4 +There can also be multiple issues converted in bulk at once +i.e python3.6 main.py convert --taiga 5 10 15 20 25 30 35 40 45 50 + +python3.6 main.py list issue --pending +Lists pending issues from taiga + +python3.6 main.py list userstory --pending +Lists pending userstory from taiga + +python3.6 main.py announce --ml "X" --reply +Announces to the mailing list the "X" stands for issue refrence from taiga,--reply if not mentioned has the reply option for all emails, +if set only the first email adress is set as reply to in the header + +python3.6 main.py fesco --fesco "X" +Creates a issue in the fesco repo on pagure. "X" stands for the issue refrence/No from taiga + +python3.6 main.py accept --accept "X" +Accepts the Change Converts Issue to UserStory creates a Bug in bugzilla +"X" stands for issue Refrence/No from taiga + +--reply +An optional Header if not mentioned has the reply option for all emails, +if set only the first email adress is set as reply to in the header From cbbdbd4ae8dff987724d7904c7e9f7a87cf5bccb Mon Sep 17 00:00:00 2001 From: Manas Date: Jun 26 2019 14:58:19 +0000 Subject: [PATCH 35/71] bugzilla changed to use pybugzilla module rest not wokrng --- diff --git a/bz/bugs.py b/bz/bugs.py index 19fca49..fe0af4d 100644 --- a/bz/bugs.py +++ b/bz/bugs.py @@ -2,26 +2,54 @@ import requests import configparser import keyring import json +import time +# import bugzilla as bapi -def post_bug(payload, config): - try: - """ - config = configparser.ConfigParser() - config.read(configpath) - """ - headers = { - 'Content-Type': 'application/json', - 'Authorization': 'Bearer {0}'.format(keyring.get_password(config['TAIGA']['SERVICE_TOKEN'], "taiga_token")) - # 'Authorization': 'Bearer {0}'.format(str(123)) - } - url = str(config['BUGZILLA']['BUGZILLA_URL']) + "/rest/bug" +def post_bug(createinfo, bzapi, config): + #try: + """ + config = configparser.ConfigParser() + config.read(configpath) + """ + #url = str(config['BUGZILLA']['BUGZILLA_URL']) + "/rest/bug" + """ + headers = { + 'Content-Type': 'application/json', + #'Authorization': '{}'.format(keyring.get_password(config['BUGZILLA']['SERVICE_TOKEN'], "api_token")) + # 'Authorization': 'Bearer {0}'.format(str(123)) + #'X-BUGZILLA-API-KEY': '{}'.format(keyring.get_password(config['BUGZILLA']['SERVICE_TOKEN'], "api_token")) + #'Bugzilla_api_key': '{}'.format(keyring.get_password(config['BUGZILLA']['SERVICE_TOKEN'], "api_token")) + } + """ + #print(headers) + if not bzapi.logged_in: + print("This example requires cached login credentials for %s" % URL) + bzapi.interactive_login() + print(createinfo) + newbug = bzapi.createbug(createinfo) + #print(newbug) + print("Created new bug id=%s url=%s" % (newbug.id, newbug.weburl)) + """ + url = str(config['BUGZILLA']['BUGZILLA_URL']) + "/rest.cgi/bug?" + "api_key=ZzKzxycfIG42FD1PaEEzJbTiZwCGIoo2GJvkWZGt"#.format(keyring.get_password(config['BUGZILLA']['SERVICE_TOKEN'], "api_token")) print(url) # debug/dev env only - r = requests.get( + r = requests.post( url, headers=headers, data=json.dumps(payload) ) return r + """ + """ except requests.exceptions.RequestException as e: print(e) + except Exception as e: + print(e) + return e + """ +""" +curl -X GET \ +-H "Content-Type: application/json" \ +-H "api_key: WChvNU7Z94xuk6adFn4GA8Y8UgcqQyIx5wgLVkbf" \ +-s https://bugzilla.redhat.com/rest/whoami? +""" \ No newline at end of file diff --git a/bz/bugzilla_auth.py b/bz/bugzilla_auth.py index 6c4b14e..5cdb4ab 100644 --- a/bz/bugzilla_auth.py +++ b/bz/bugzilla_auth.py @@ -27,7 +27,8 @@ the api token.is sued by the modern rest api """ -def reset(configpath): +def reset(args): + configpath = args.config config = configparser.ConfigParser() config.read(configpath) service_id = config['BUGZILLA']['SERVICE_ID'] # service id @@ -36,12 +37,11 @@ def reset(configpath): print("You User Id and password will be securly store in the Keyring") username = input("Enter your user id for bugzilla: ") password = getpass.getpass("Enter your password for bugzilla: ") - api_key = getpass.getpass("Enter your bugzilla api: ") + api_key = getpass.getpass("Enter your bugzilla api token: ") try: - # keyring.set_password("taiga", username) - # keyring.set_password(service_id, "username", username) - keyring.set_password(service_id, username, str(password)) - keyring.set_password(service_id, username, api_key) + keyring.set_password(service_id, "bugzilla_id", username) + keyring.set_password(service_id, username, password) + keyring.set_password(service_token, "api_token", api_key) username = binascii.hexlify(os.urandom(20)) # randomising username to avoid sneak memory attacks password = binascii.hexlify(os.urandom(20)) # ranomising pass to avoid sneak memory attacks # username = random.choices(string.ascii_uppercase + string.digits, k=random.randint(1,10)) diff --git a/bz/pgba.py b/bz/pgba.py index 39d26f3..183178a 100644 --- a/bz/pgba.py +++ b/bz/pgba.py @@ -8,15 +8,18 @@ from tga import epics as tgaepic from tga import issues as tgaissue from tga import userstory as tgauserstory from pgure import issues as pgaissues -from bz import bugs as bzbugz +from bz import bugs as bzbugs +import bugzilla -def pgtobz: +def pgtobz(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'] + URL = config['BUGZILLA']['BUGZILLA_URL'] + bzapi = bugzilla.Bugzilla(URL) for x in value: # iteratingover name space object try: r = tgaissue.get_issue(x, config) # x is user story refrence id @@ -56,11 +59,12 @@ def pgtobz: 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)) + b_txt.write("{}\n\n{}\n".format(taiga_issue_link, summary)) editor.edit(filename="bugzilla_bug.txt") try: - with open ("bugzilla_bug.txt", "r") as b_txt: + with open("bugzilla_bug.txt", "r") as b_txt: bug_text = b_txt.read() + """ payload = { 'product': 'Fedora', 'component': 'Changes Tracking', # temporary only @@ -68,41 +72,54 @@ def pgtobz: 'summary': subject, 'description': bug_text, 'assigned_to': bzid[0], - 'cc': bz_id[1:] + 'cc': bzid[1:] + #'api_key': '{}'.format(keyring.get_password(config['BUGZILLA']['SERVICE_TOKEN'], "api_token")) } - r = bzbugs.post_bug(payload, config) - print(r.content, r.status_code) # Development only - if r.status_code == 200: - print("Sucessful Bugzilla Bug Creation") - 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) + """ + + createinfo = bzapi.build_createbug( + product="Fedora", + version="rawhide", + component="Changes Tracking", + summary=subject, + description=bug_text, + assigned_to=bzid[0], + cc=bzid[1:] + ) + bzbugs.post_bug(createinfo, bzapi, config) + #print(r.content, r.status_code) # Development only + #if r.status_code == 200: + print("Sucessful Bugzilla Bug Creation") + owner = "@" + str(owner) + with open("rnotes_issue.txt", "w+") as rnotes_txt: + rnotes_txt.write("{}\n\n[Change Proposal]({})\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 = config['PAGURE']['RELEASE_NOTES_REPO'] + r = pgaissues.post_issue(payload, repo, config) + print(r) + if r.status_code == 200: print("Sucessful creation of issue on pagure release notes") - return True - except requests.exceptions.RequestException as e: - print("Failed to fetch attributes of the issue") - print(e) - except Exception as e: - print(e) - else: - print("Unable to Create bug check logs for errors") + return True + else: + print("failed to complete acceptance") + except requests.exceptions.RequestException as e: + print("Failed to fetch attributes of the issue") + print(e) + except Exception as e: + print(e) except requests.exceptions.RequestException as e: print("Failed to fetch attributes of the issue") print(e) From 2e7fa75a896ae879e313d154e49ddc339b852c5e Mon Sep 17 00:00:00 2001 From: Manas Date: Jun 26 2019 15:00:03 +0000 Subject: [PATCH 36/71] mailing list fixes with reply header --- diff --git a/mail/climail.py b/mail/climail.py index 56324e8..41c7360 100644 --- a/mail/climail.py +++ b/mail/climail.py @@ -48,14 +48,16 @@ def email_send(issueno): """ -def mails(args, replyto, configpath): +def mails(args): + configpath = args.config config = configparser.ConfigParser() config.read(configpath) service_id = config['EMAIL']['SERVICE_ID'] sender = config['EMAIL']['SENDER_EMAIL_ID'] reciver = config['EMAIL']['LIST'] print(args) - for x in args: + value = args.ml + for x in value: #for x in value: #ref = input("input the issue no you want to announce: ") try: @@ -83,7 +85,7 @@ def mails(args, replyto, configpath): editor.edit(filename="mail.txt") try: subject = str(cadata['attributes_values']['11383']) + ":" + str(data['subject']) - maillist.email_send(subject, replyto, config) + maillist.email_send(subject, args.reply, config) except Exception as e: print(e) else: diff --git a/mail/mailauth.py b/mail/mailauth.py index 11beb6e..23df271 100644 --- a/mail/mailauth.py +++ b/mail/mailauth.py @@ -12,9 +12,10 @@ service_id = config['EMAIL']['SERVICE_ID'] """ -def reset(): +def reset(args): + configpath = args.config config = configparser.ConfigParser() - config.read('config.ini') + config.read(configpath) service_id = config['EMAIL']['SERVICE_ID'] print("You User Id and password will be securly store in the Keyring") username = input("Enter your id: ") From 2e282707ede46c13bf5fbc06cd8f3e9665512150 Mon Sep 17 00:00:00 2001 From: Manas Date: Jun 26 2019 15:01:10 +0000 Subject: [PATCH 37/71] args fixed to decipher in the modules directly --- diff --git a/main.py b/main.py index 9265b45..e26fec0 100644 --- a/main.py +++ b/main.py @@ -4,6 +4,7 @@ import requests import json import argparse import sys +import accept from tga import taiga_auth from pgure import pagure_auth from bz import bugzilla_auth @@ -68,26 +69,26 @@ class Change_Tool(object): # print(args) # debug only if args.command == 'taiga': if args.token: - taiga_auth.refresh_token(args.config) + taiga_auth.refresh_token(args) elif args.reset: - taiga_auth.reset(args.config) + taiga_auth.reset(args) else: print("Wrong command") elif args.command == 'pagure': if args.reset: - pagure_auth.reset(args.config) + pagure_auth.reset(args) else: print("Wrong command") elif args.command == 'bugzilla': if args.token: - bugzilla_auth.refresh_token(args.config) + bugzilla_auth.refresh_token(args) elif args.reset: - bugzilla_auth.reset(args.config) + bugzilla_auth.reset(args) else: print("Wrong command,please check documentation for the proper command") elif args.command == 'email': if args.reset: - mailauth.reset(args.config) + mailauth.reset(args) else: print("Wrong Command check documentation") else: @@ -95,8 +96,17 @@ class Change_Tool(object): # print("Running the auth instance.....") # authenticate() - + def convert(self): + """ + Convert is the only module + that has directly mapped args to the module + as we want to maintain the ability to use + the convert functionality on its own and + the way the multi[ple conversion is + structured,prevents passing just the args + as a whole. + """ parser = argparse.ArgumentParser( description='converts taiga issue to user story') parser.add_argument('--taiga', @@ -139,12 +149,12 @@ class Change_Tool(object): print("Incomplete command,please specify right sub-command") if args.command == 'issue': if args.pending: - tguserstory.list_us(configpath) + tguserstory.list_us(args) else: print("wrong command") elif args.command == 'userstory': if args.pending: - tgaissue.issue_list(configpath) + tgaissue.issue_list(args) else: print("Wrong command") else: @@ -175,7 +185,8 @@ class Change_Tool(object): #print(args) print(args.reply) # print(args) # debug only - climail.mails(args.ml, args.reply, args.config) + #climail.mails(args.ml, args.reply, args.config) + climail.mails(args) def fesco(self): parser = argparse.ArgumentParser( @@ -195,7 +206,31 @@ class Change_Tool(object): print(configpath) print(args) # print(args) # debug only - fesco.fesissue(args.fesco, args.config) + #fesco.fesissue(args.fesco, args.config) + fesco.fesissue(args) + + def accept(self): + parser = argparse.ArgumentParser( + description='announces to mailing list') + parser.add_argument('--accept', + nargs='+', + type=int, + help='Announces to Mailing list') + parser.add_argument('--config', + #dest='configpath', + #action='store', + #type=string, + default='config.ini', + help='Sets config path') + args = parser.parse_args(sys.argv[2:]) + #configpath = args.config + #print(configpath) + #print(args) + #print(args.reply) + # print(args) # debug only + #accept.accept(args.accept, args.config) + accept.accept(args) + """ def config(self): parser = argparse.ArgumentParser( diff --git a/tga/convert.py b/tga/convert.py index 4baf8be..2e317d0 100644 --- a/tga/convert.py +++ b/tga/convert.py @@ -29,14 +29,17 @@ else: def convert(value, configpath): + #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'] taiga_url = config['TAIGA']['TAIGA_URL'] + #value = args.taiga for x in value: try: + print(x,"this is x") r = tgaissue.get_issue(x, config) # gets the issue if r.status_code == 200: data = json.loads(r.content) @@ -164,6 +167,7 @@ def convert(value, configpath): #print(json.loads(r.content)) if r.status_code == 200: print("Sucessfully closed issue") + return True else: print("Unsuccesful at closing issue,check logs") else: diff --git a/tga/issues.py b/tga/issues.py index b685845..729904b 100644 --- a/tga/issues.py +++ b/tga/issues.py @@ -29,12 +29,12 @@ headers = { """ -def list_issue(config): +def list_issue(args): try: - """ + configpath = args.config config = configparser.ConfigParser() config.read(configpath) - """ + url = str(config['TAIGA']['TAIGA_URL']) + "/api/v1/issues?project=" + str(config['TAIGA']['PROJECT_ID']) + "\&status=" + str(config['TAIGA']['IS_STATUS_NEW']) print(url) # Debug only headers = { @@ -81,7 +81,7 @@ def get_issue(x, config): # 'Authorization': 'Bearer {0}'.format(str(123)) } url = str(config['TAIGA']['TAIGA_URL']) + "/api/v1/issues/by_ref?ref=" + str(x) + "&project=" + str(config['TAIGA']['PROJECT_ID']) - + print(headers) print(url) # debug/dev env only r = requests.get( url, diff --git a/tga/taiga_auth.py b/tga/taiga_auth.py index ddcc37e..83263f9 100644 --- a/tga/taiga_auth.py +++ b/tga/taiga_auth.py @@ -29,15 +29,16 @@ else: """ -def refresh_token(filename): +def refresh_token(args): """ Used only for testing and Demo Encrypted Config file/Application token used in production. Doing the follwoing in prod is security risk. """ + configpath = args.config config = configparser.ConfigParser() - config.read(filename) + config.read(configpath) headers = { 'Content-Type': 'application/json', } @@ -77,9 +78,10 @@ def refresh_token(filename): print(e) -def reset(filename): +def reset(args): + configpath = args.config config = configparser.ConfigParser() - config.read(filename) + config.read(configpath) headers = { 'Content-Type': 'application/json', } From d14c1a5e158328614793c38a3dcc77b14d35c0c9 Mon Sep 17 00:00:00 2001 From: Manas Date: Jun 26 2019 15:01:30 +0000 Subject: [PATCH 38/71] keyring issues fixed with pagure --- diff --git a/config.ini b/config.ini index 125a458..4528088 100644 --- a/config.ini +++ b/config.ini @@ -57,16 +57,15 @@ RELEASE_NOTES_REPO = Test-for-Release-Notes SERVICE_ID = bugzilla SERVICE_TOKEN = bugzilla_auth PROJECT_ID = 315827 # for test only -BUGZILLA_URL = https://bugzilla.redhat.com/ +BUGZILLA_URL = https://bugzilla.redhat.com/xmlrpc.cgi ; TEST = no [EMAIL] SERVICE_ID = email SENDER_EMAIL_ID = manasmangaonkar@gmail.com -LIST: ["manas.man95@gmail.com","ttim3886@gmail.com"] +LIST: ["bcotton@funnelfiasco.com","bcotton@redhat.com"] ; LIST: [devel@lists.fedoraproject.org,devel-announce@lists.fedoraproject.org] PORT = 465 SMTP_SERVER = smtp.gmail.com ; TEST = yes ; 1892835 - diff --git a/pgure/fesco.py b/pgure/fesco.py index 4d133e0..3e3c97b 100644 --- a/pgure/fesco.py +++ b/pgure/fesco.py @@ -19,13 +19,15 @@ else: """ -def fesissue(args, configpath): +def fesissue(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'] - for x in args: # iteratingover name space object + value = args.fesco + 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: diff --git a/pgure/issues.py b/pgure/issues.py index 60e0c64..9b8131c 100644 --- a/pgure/issues.py +++ b/pgure/issues.py @@ -66,10 +66,10 @@ def post_issue(payload, repo, config): #print(repo_name) headers = { 'Content-Type': 'application/json', - 'Authorization': 'token {0}'.format(keyring.get_password(config['PAGURE']['SERVICE_ID'], "repo_name")) + 'Authorization': 'token {0}'.format(keyring.get_password(config['PAGURE']['SERVICE_ID'], repo)) } print(headers) - url = str(config['PAGURE']['API_URL']) + '/' + repo + '/new_issue' + url = str(config['PAGURE']['API_URL']) + repo + '/new_issue' #print(data) # debug only print(url) print(payload) diff --git a/pgure/pagure_auth.py b/pgure/pagure_auth.py index cf26169..3d5d547 100644 --- a/pgure/pagure_auth.py +++ b/pgure/pagure_auth.py @@ -8,18 +8,21 @@ import getpass import configparser -def reset(configpath): +def reset(args): + configpath = args.config config = configparser.ConfigParser() config.read(configpath) print("Your auth token will be securly store in the Keyring") # username = input("Enter your user id for taiga: ") service_id = config['PAGURE']['SERVICE_ID'] - repo_name = input("Enter the repo name you want to set api key for: ") - token = getpass.getpass("Enter your token for" + ' ' + repo_name + ' ' "repository: ") + #repo_name = input("Enter the repo name you want to set api key for: ") + fescotoken = getpass.getpass("Enter your token for" + ' ' + "fesco" + ' ' "repository: ") + releasetoken = getpass.getpass("Enter your token for" + ' ' + "release-notes" + ' ' "repository: ") try: # keyring.set_password("taiga", username) - keyring.set_password(service_id, "repo_name", repo_name) - keyring.set_password(service_id, repo_name, str(token)) + #keyring.set_password(service_id, "repo_name", repo_name) + keyring.set_password(service_id, config['PAGURE']['FESCO_REPO'], str(fescotoken)) + keyring.set_password(service_id, config['PAGURE']['RELEASE_NOTES_REPO'], str(releasetoken)) print("token reset succesfully") except (keyring.errors.PasswordSetError, Exception) as e: print("Failed to reset token") From c6b620aebe68755bddb6ea1ce0ff1e042ea0bc2d Mon Sep 17 00:00:00 2001 From: Manas Date: Jun 26 2019 15:01:42 +0000 Subject: [PATCH 39/71] move accept to outside --- diff --git a/bz/accept.py b/bz/accept.py deleted file mode 100644 index 568f33a..0000000 --- a/bz/accept.py +++ /dev/null @@ -1,122 +0,0 @@ -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(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: - convert = convert.convert(x, configpath) - if convert == True: - bz = pgba.pgbz(x, 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") - except Exception as e: - print(e, /n"Unable to accept the Change Proposal") - From c8be185f5030b7371f263a9a1d20dfba6dc016e6 Mon Sep 17 00:00:00 2001 From: Manas Date: Jun 26 2019 15:56:35 +0000 Subject: [PATCH 40/71] 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") + From 645757f32c9f3c9e76f7df9aef7d20359a10681e Mon Sep 17 00:00:00 2001 From: Manas Date: Jun 28 2019 09:28:37 +0000 Subject: [PATCH 41/71] remove email redundancy --- diff --git a/config.ini b/config.ini index 4528088..c34551f 100644 --- a/config.ini +++ b/config.ini @@ -62,7 +62,7 @@ BUGZILLA_URL = https://bugzilla.redhat.com/xmlrpc.cgi [EMAIL] SERVICE_ID = email -SENDER_EMAIL_ID = manasmangaonkar@gmail.com +#SENDER_EMAIL_ID = manasmangaonkar@gmail.com LIST: ["bcotton@funnelfiasco.com","bcotton@redhat.com"] ; LIST: [devel@lists.fedoraproject.org,devel-announce@lists.fedoraproject.org] PORT = 465 diff --git a/mail/maillist.py b/mail/maillist.py index 5936012..4e245e9 100644 --- a/mail/maillist.py +++ b/mail/maillist.py @@ -70,7 +70,7 @@ def email_send(subject, replyto, config): try: msg = MIMEMultipart() msg['To'] = reciver_email - msg['From'] = sender + msg['From'] = username msg['Subject'] = subject print("this step") if replyto == True: From a34ca69a628d4a6967231927e0f5843b5984c489 Mon Sep 17 00:00:00 2001 From: Manas Date: Jun 28 2019 09:29:39 +0000 Subject: [PATCH 42/71] change is to issue and us to userstory --- diff --git a/bz/pgba.py b/bz/pgba.py index 183178a..3b0a78e 100644 --- a/bz/pgba.py +++ b/bz/pgba.py @@ -12,7 +12,7 @@ from bz import bugs as bzbugs import bugzilla -def pgtobz(value, configpath): +def pgtobz(value, USERSTORY_id, configpath): config = configparser.ConfigParser() config.read(configpath) service_id = config['TAIGA']['SERVICE_ID'] # service id @@ -86,7 +86,7 @@ def pgtobz(value, configpath): assigned_to=bzid[0], cc=bzid[1:] ) - bzbugs.post_bug(createinfo, bzapi, config) + bug = bzbugs.post_bug(createinfo, bzapi, config) #print(r.content, r.status_code) # Development only #if r.status_code == 200: print("Sucessful Bugzilla Bug Creation") @@ -113,6 +113,17 @@ def pgtobz(value, configpath): if r.status_code == 200: print("Sucessful creation of issue on pagure release notes") return True + payload = { + "attributes_values": { + config['TAIGA']['USERSTORY_CA_BUGZILLA_TRACKER']: bug.weburl, + }, + "version": 2 + } + r = tgauserstory.post_usca(payload, USERSTORY_id, config) + if r.status_code == 200: + print("Sucessfully mapped bz to user story") + else: + print("check logs for errors") else: print("failed to complete acceptance") except requests.exceptions.RequestException as e: diff --git a/config.ini b/config.ini index c34551f..7d9da54 100644 --- a/config.ini +++ b/config.ini @@ -5,46 +5,46 @@ PROJECT_ID = 325667 TAIGA_URL = https://api.taiga.io TAIGA_SITE_ISSUE_URL = https://tree.taiga.io/project/pac_23-test-changes-tracker-kanban/issue/ -IS_STATUS_NEW = 2283176 -IS_STATUS_NEEDS_INFO = 2283180 -IS_STATUS_READY_FOR_WRANGLER = 2283232 -IS_STATUS_READY_FOR_FESCO = 2295359 -IS_STATUS_PROCESSED = 2283182 -US_STATUS_NEW = 1952887 -US_STATUS_ANNOUNCED = 1952888 -US_STATUS_R_FESCO = 1952889 -US_STATUS_ACCEPTED = 1952891 -US_STATUS_ARCHIVED = 1952890 -US_STATUS_CODE_COMPLETE = 1892839 -US_STATUS_TESTABLE = 1952932 +ISSUE_STATUS_NEW = 2283176 +ISSUE_STATUS_NEEDS_INFO = 2283180 +ISSUE_STATUS_READY_FOR_WRANGLER = 2283232 +ISSUE_STATUS_READY_FOR_FESCO = 2295359 +ISSUE_STATUS_PROCESSED = 2283182 +USERSTORY_STATUS_NEW = 1952887 +USERSTORY_STATUS_ANNOUNCED = 1952888 +USERSTORY_STATUS_R_FESCO = 1952889 +USERSTORY_STATUS_ACCEPTED = 1952891 +USERSTORY_STATUS_ARCHIVED = 1952890 +USERSTORY_STATUS_CODE_COMPLETE = 1892839 +USERSTORY_STATUS_TESTABLE = 1952932 -IS_CA_SYSTEM_WIDE_CHANGE = 11370 -IS_CA_SUMMARY = 11372 -IS_CA_BUGZILLA_CONTACT = 11373 -IS_CA_RELENG_TICKET = 11371 -IS_CA_TRADEMARK_APPROVAL = 11374 -IS_CA_OWNERS = 11375 -IS_CA_FESCO_TICKET = 534454574 -IS_CA_BUGZILLA_TRACKER = 21930 -IS_CA_RELEASE_NOTES = 21931 -IS_CA_CONTINGENCY = 11376 -IS_CA_MASS_REBUILD = 11377 -IS_CA_POLICY_CHANGE = 11378 -IS_CA_MODIFIES_DELIVERABLES = 11379 -IS_CA_VERSION = 11383 -US_CA_SYSTEM_WIDE_CHANGE = 21923 -US_cA_SUMMARY = 21924 -US_CA_BUGZILLA_CONTACT = 21925 -US_CA_RELENG_TICKET = 21926 -US_CA_TRADEMARK_APPROVAL = 21927 -US_CA_OWNERS = 21928 -US_CA_FESCO_TICKET = 21929 -US_CA_BUGZILLA_TRACKER = 21930 -US_CA_RELEASE_NOTES = 21931 -US_CA_CONTINGENCY = 21932 -US_CA_MASS_REBUILD = 21933 -US_CA_POLICY_CHANGE = 21934 -US_CA_MODIFIES_DELIVERABLES = 21935 +ISSUE_CA_SYSTEM_WIDE_CHANGE = 11370 +ISSUE_CA_SUMMARY = 11372 +ISSUE_CA_BUGZILLA_CONTACT = 11373 +ISSUE_CA_RELENG_TICKET = 11371 +ISSUE_CA_TRADEMARK_APPROVAL = 11374 +ISSUE_CA_OWNERS = 11375 +ISSUE_CA_FESCO_TICKET = 534454574 +ISSUE_CA_BUGZILLA_TRACKER = 21930 +ISSUE_CA_RELEASE_NOTES = 21931 +ISSUE_CA_CONTINGENCY = 11376 +ISSUE_CA_MASS_REBUILD = 11377 +ISSUE_CA_POLICY_CHANGE = 11378 +ISSUE_CA_MODIFIES_DELIVERABLES = 11379 +ISSUE_CA_VERSION = 11383 +USERSTORY_CA_SYSTEM_WIDE_CHANGE = 21923 +USERSTORY_CA_SUMMARY = 21924 +USERSTORY_CA_BUGZILLA_CONTACT = 21925 +USERSTORY_CA_RELENG_TICKET = 21926 +USERSTORY_CA_TRADEMARK_APPROVAL = 21927 +USERSTORY_CA_OWNERS = 21928 +USERSTORY_CA_FESCO_TICKET = 21929 +USERSTORY_CA_BUGZILLA_TRACKER = 21930 +USERSTORY_CA_RELEASE_NOTES = 21931 +USERSTORY_CA_CONTINGENCY = 21932 +USERSTORY_CA_MASS_REBUILD = 21933 +USERSTORY_CA_POLICY_CHANGE = 21934 +USERSTORY_CA_MODIFIES_DELIVERABLES = 21935 [PAGURE] diff --git a/tga/convert.py b/tga/convert.py index 2e317d0..abc95cc 100644 --- a/tga/convert.py +++ b/tga/convert.py @@ -118,28 +118,28 @@ def convert(value, configpath): if r.status_code == 201: print("step 3") data = json.loads(r.content) - us_id = data['id'] + USERSTORY_id = data['id'] print(id) payload = { "attributes_values": { - config['TAIGA']['US_CA_SYSTEM_WIDE_CHANGE']: system_wide_change, - config['TAIGA']['US_CA_SUMMARY']: summary, - config['TAIGA']['US_CA_RELENG_TICKET']: relengticket, - config['TAIGA']['US_CA_TRADEMARK_APPROVAL']: approval_required, - #config['TAIGA']['US_CA_OWNERS']: owners, - config['TAIGA']['US_CA_FESCO_TICKET']: 'random', - config['TAIGA']['US_CA_BUGZILLA_TRACKER']: 'random', - config['TAIGA']['US_CA_BUGZILLA_CONTACT']: bugzilla_id, - config['TAIGA']['US_CA_RELEASE_NOTES']: 'random', - config['TAIGA']['US_CA_CONTINGENCY']: contingency_deadline, - config['TAIGA']['US_CA_MASS_REBUILD']: mass_rebuild, - config['TAIGA']['US_CA_POLICY_CHANGE']: policy_change, - config['TAIGA']['US_CA_MODIFIES_DELIVERABLES']: modifies_deliverables + config['TAIGA']['USERSTORY_CA_SYSTEM_WIDE_CHANGE']: system_wide_change, + config['TAIGA']['USERSTORY_CA_SUMMARY']: summary, + config['TAIGA']['USERSTORY_CA_RELENG_TICKET']: relengticket, + config['TAIGA']['USERSTORY_CA_TRADEMARK_APPROVAL']: approval_required, + #config['TAIGA']['USERSTORY_CA_OWNERS']: owners, + config['TAIGA']['USERSTORY_CA_FESCO_TICKET']: 'random', + config['TAIGA']['USERSTORY_CA_BUGZILLA_TRACKER']: 'random', + config['TAIGA']['USERSTORY_CA_BUGZILLA_CONTACT']: bugzilla_id, + config['TAIGA']['USERSTORY_CA_RELEASE_NOTES']: 'random', + config['TAIGA']['USERSTORY_CA_CONTINGENCY']: contingency_deadline, + config['TAIGA']['USERSTORY_CA_MASS_REBUILD']: mass_rebuild, + config['TAIGA']['USERSTORY_CA_POLICY_CHANGE']: policy_change, + config['TAIGA']['USERSTORY_CA_MODIFIES_DELIVERABLES']: modifies_deliverables }, "version": 1 } print(payload) - r = tgauserstory.post_usca(payload, us_id, config) + r = tgauserstory.post_usca(payload, USERSTORY_id, config) print(json.loads(r.content)) print(r.status_code) if r.status_code == 200: @@ -154,11 +154,11 @@ def convert(value, configpath): epicref = i['ref'] break - r = tgaepic.post_relatedus(us_id, epicid, epicref, config) + r = tgaepic.post_relatedus(USERSTORY_id, epicid, epicref, config) if r.status_code == 201: print("Sucessfully mapped epics") payload = { - 'status': config['TAIGA']['IS_STATUS_PROCESSED'], + 'status': config['TAIGA']['ISSUE_STATUS_PROCESSED'], 'version': issue_version } r = tgaissue.changestatus_issue(issue_id, payload, config) @@ -167,7 +167,7 @@ def convert(value, configpath): #print(json.loads(r.content)) if r.status_code == 200: print("Sucessfully closed issue") - return True + return True, USERSTORY_id else: print("Unsuccesful at closing issue,check logs") else: diff --git a/tga/epics.py b/tga/epics.py index d690a32..2d501f4 100644 --- a/tga/epics.py +++ b/tga/epics.py @@ -49,7 +49,7 @@ def list_epic(config): print(e) -def post_relatedus(us_id, epicid, epicref, config): +def post_relatedus(USERSTORY_id, epicid, epicref, config): try: """ config = configparser.ConfigParser() @@ -62,7 +62,7 @@ def post_relatedus(us_id, epicid, epicref, config): } payload = { "epic": epicid, - "user_story": us_id + "user_story": USERSTORY_id } r = requests.post( 'https://api.taiga.io/api/v1/epics/' + str(epicid) + '/related_userstories', diff --git a/tga/issues.py b/tga/issues.py index 729904b..bf8a59e 100644 --- a/tga/issues.py +++ b/tga/issues.py @@ -13,10 +13,10 @@ project_id = config['TAIGA']['PROJECT_ID'] if config['TAIGA']['TEST'] == 'yes': taiga_url = config['TAIGA']['CUSTOM_TAIGA_URL'] - status = config['TAIGA']['TEST_IS_STATUS_NEW'] + status = config['TAIGA']['TEST_ISSUE_STATUS_NEW'] elif config['TAIGA']['TEST'] == 'no': taiga_url = config['TAIGA']['DEFAULT_TAIGA_URL'] - status = config['TAIGA']['IS_STATUS_NEW'] + status = config['TAIGA']['ISSUE_STATUS_NEW'] else: print("please set test status in config") @@ -34,8 +34,7 @@ def list_issue(args): configpath = args.config config = configparser.ConfigParser() config.read(configpath) - - url = str(config['TAIGA']['TAIGA_URL']) + "/api/v1/issues?project=" + str(config['TAIGA']['PROJECT_ID']) + "\&status=" + str(config['TAIGA']['IS_STATUS_NEW']) + url = str(config['TAIGA']['TAIGA_URL']) + "/api/v1/issues?project=" + config['TAIGA']['PROJECT_ID'] + "\&status=" + str(config['TAIGA']['ISSUE_STATUS_NEW']) print(url) # Debug only headers = { 'Content-Type': 'application/json', @@ -63,8 +62,11 @@ def list_issue(args): print(table) else: print("Unable to fetch list check logs") + print(r.content) except requests.exceptions.RequestException as e: print(e) + except Exception as e: + print(e) except Exception as e: print(e) @@ -130,7 +132,7 @@ def changestatus_issue(x, payload, config): } """ payload = { - 'status': config['TAIGA']['IS_STATUS_PROCESSED'], + 'status': config['TAIGA']['ISSUE_STATUS_PROCESSED'], 'version': issue_version } """ diff --git a/tga/userstory b/tga/userstory deleted file mode 100644 index e69de29..0000000 --- a/tga/userstory +++ /dev/null diff --git a/tga/userstory.py b/tga/userstory.py index 9221cb6..c2f825b 100644 --- a/tga/userstory.py +++ b/tga/userstory.py @@ -13,10 +13,10 @@ project_id = config['TAIGA']['PROJECT_ID'] if config['TAIGA']['TEST'] == 'yes': taiga_url = config['TAIGA']['CUSTOM_TAIGA_URL'] - status = config['TAIGA']['TEST_US_STATUS_NEW'] + status = config['TAIGA']['TEST_USERSTORY_STATUS_NEW'] elif config['TAIGA']['TEST'] == 'no': taiga_url = config['TAIGA']['DEFAULT_TAIGA_URL'] - status = config['TAIGA']['US_STATUS_NEW'] + status = config['TAIGA']['USERSTORY_STATUS_NEW'] else: print("please set test status in config") @@ -39,6 +39,7 @@ def get_us(refusid, config): # 'Authorization': 'Bearer {0}'.format(str(123)) } url = str(config['TAIGA']['TAIGA_URL']) + "/api/v1/userstories/by_ref?ref=" + str(refusid) + "\&project=" + str(config['TAIGA']['PROJECT_ID']) + url = "https://api.taiga.io/api/v1/issues?project=325667\&status=2283176" print(url) # debug only r = requests.get( url, @@ -49,18 +50,19 @@ def get_us(refusid, config): print(e) -def list_us(config): +def list_us(args): try: - """ + configpath = args.config config = configparser.ConfigParser() config.read(configpath) - """ headers = { 'Content-Type': 'application/json', 'Authorization': 'Bearer {0}'.format(keyring.get_password(config['TAIGA']['SERVICE_TOKEN'], "taiga_token")) # 'Authorization': 'Bearer {0}'.format(str(123)) } - url = str(config['TAIGA']['TAIGA_URL']) + "/api/v1/issues/userstories?project=" + str(config['TAIGA']['PROJECT_ID']) + "\&status=" + str(config['TAIGA']['US_STATUS_NEW']) + print(headers) + url = str(config['TAIGA']['TAIGA_URL']) + "/api/v1/userstories?project=" + str(config['TAIGA']['PROJECT_ID']) + "\&status=" + str(config['TAIGA']['USERSTORY_STATUS_NEW']) + url = "https://api.taiga.io/api/v1/issues?project=325667\&status=2283176" print(url) # Debug only try: r = requests.get( @@ -68,23 +70,29 @@ def list_us(config): headers=headers ) if r.status_code == 200: + print(r.status_code) table = BeautifulTable() table.column_headers = ["refrence no", "subject", "fedora-version", "owner"] data = json.loads(r.content) for item in data: subject = item['subject'] - us_id = item['id'] - us_ref = item['ref'] + USERSTORY_id = item['id'] + USERSTORY_ref = item['ref'] version = item['epics'] duedate = item['due_date'] tags = ['tags'] for item in data['owner_extra_info']: owner = item['username'] - table.append_row([us_ref, subject, version, owner]) - #print(us_id, us_ref owner) + table.append_row([USERSTORY_ref, subject, version, owner]) + #print(USERSTORY_id, USERSTORY_ref owner) print(table) + else: + print(r.content) except requests.exceptions.RequestException as e: print(e) + print(r.content) + except Exception as e: + print(e) except Exception as e: print(e) @@ -130,3 +138,9 @@ def post_usca(x, id, config): return r except requests.exceptions.RequestException as e: print(e) +""" +curl -X GET \ +-H "Content-Type: application/json" \ +-H "Authorization: Bearer ${eyJ1c2VyX2F1dGhlbnRpY2F0aW9uX2lkIjozNTY4MDR9:1hI6pm:4d4mA-gUXC2S0FxaladX0Fd_3gA}" \ +-s https://api.taiga.io/api/v1/issues?project=325667\&status=2283176 +""" \ No newline at end of file From f815ae59f808637bf9d3fe79946c979fd152659e Mon Sep 17 00:00:00 2001 From: Manas Date: Jun 28 2019 09:35:24 +0000 Subject: [PATCH 43/71] change is to issue and us to userstory fixes #46 --- diff --git a/bz/pgba.py b/bz/pgba.py index 183178a..3b0a78e 100644 --- a/bz/pgba.py +++ b/bz/pgba.py @@ -12,7 +12,7 @@ from bz import bugs as bzbugs import bugzilla -def pgtobz(value, configpath): +def pgtobz(value, USERSTORY_id, configpath): config = configparser.ConfigParser() config.read(configpath) service_id = config['TAIGA']['SERVICE_ID'] # service id @@ -86,7 +86,7 @@ def pgtobz(value, configpath): assigned_to=bzid[0], cc=bzid[1:] ) - bzbugs.post_bug(createinfo, bzapi, config) + bug = bzbugs.post_bug(createinfo, bzapi, config) #print(r.content, r.status_code) # Development only #if r.status_code == 200: print("Sucessful Bugzilla Bug Creation") @@ -113,6 +113,17 @@ def pgtobz(value, configpath): if r.status_code == 200: print("Sucessful creation of issue on pagure release notes") return True + payload = { + "attributes_values": { + config['TAIGA']['USERSTORY_CA_BUGZILLA_TRACKER']: bug.weburl, + }, + "version": 2 + } + r = tgauserstory.post_usca(payload, USERSTORY_id, config) + if r.status_code == 200: + print("Sucessfully mapped bz to user story") + else: + print("check logs for errors") else: print("failed to complete acceptance") except requests.exceptions.RequestException as e: diff --git a/config.ini b/config.ini index c34551f..7d9da54 100644 --- a/config.ini +++ b/config.ini @@ -5,46 +5,46 @@ PROJECT_ID = 325667 TAIGA_URL = https://api.taiga.io TAIGA_SITE_ISSUE_URL = https://tree.taiga.io/project/pac_23-test-changes-tracker-kanban/issue/ -IS_STATUS_NEW = 2283176 -IS_STATUS_NEEDS_INFO = 2283180 -IS_STATUS_READY_FOR_WRANGLER = 2283232 -IS_STATUS_READY_FOR_FESCO = 2295359 -IS_STATUS_PROCESSED = 2283182 -US_STATUS_NEW = 1952887 -US_STATUS_ANNOUNCED = 1952888 -US_STATUS_R_FESCO = 1952889 -US_STATUS_ACCEPTED = 1952891 -US_STATUS_ARCHIVED = 1952890 -US_STATUS_CODE_COMPLETE = 1892839 -US_STATUS_TESTABLE = 1952932 +ISSUE_STATUS_NEW = 2283176 +ISSUE_STATUS_NEEDS_INFO = 2283180 +ISSUE_STATUS_READY_FOR_WRANGLER = 2283232 +ISSUE_STATUS_READY_FOR_FESCO = 2295359 +ISSUE_STATUS_PROCESSED = 2283182 +USERSTORY_STATUS_NEW = 1952887 +USERSTORY_STATUS_ANNOUNCED = 1952888 +USERSTORY_STATUS_R_FESCO = 1952889 +USERSTORY_STATUS_ACCEPTED = 1952891 +USERSTORY_STATUS_ARCHIVED = 1952890 +USERSTORY_STATUS_CODE_COMPLETE = 1892839 +USERSTORY_STATUS_TESTABLE = 1952932 -IS_CA_SYSTEM_WIDE_CHANGE = 11370 -IS_CA_SUMMARY = 11372 -IS_CA_BUGZILLA_CONTACT = 11373 -IS_CA_RELENG_TICKET = 11371 -IS_CA_TRADEMARK_APPROVAL = 11374 -IS_CA_OWNERS = 11375 -IS_CA_FESCO_TICKET = 534454574 -IS_CA_BUGZILLA_TRACKER = 21930 -IS_CA_RELEASE_NOTES = 21931 -IS_CA_CONTINGENCY = 11376 -IS_CA_MASS_REBUILD = 11377 -IS_CA_POLICY_CHANGE = 11378 -IS_CA_MODIFIES_DELIVERABLES = 11379 -IS_CA_VERSION = 11383 -US_CA_SYSTEM_WIDE_CHANGE = 21923 -US_cA_SUMMARY = 21924 -US_CA_BUGZILLA_CONTACT = 21925 -US_CA_RELENG_TICKET = 21926 -US_CA_TRADEMARK_APPROVAL = 21927 -US_CA_OWNERS = 21928 -US_CA_FESCO_TICKET = 21929 -US_CA_BUGZILLA_TRACKER = 21930 -US_CA_RELEASE_NOTES = 21931 -US_CA_CONTINGENCY = 21932 -US_CA_MASS_REBUILD = 21933 -US_CA_POLICY_CHANGE = 21934 -US_CA_MODIFIES_DELIVERABLES = 21935 +ISSUE_CA_SYSTEM_WIDE_CHANGE = 11370 +ISSUE_CA_SUMMARY = 11372 +ISSUE_CA_BUGZILLA_CONTACT = 11373 +ISSUE_CA_RELENG_TICKET = 11371 +ISSUE_CA_TRADEMARK_APPROVAL = 11374 +ISSUE_CA_OWNERS = 11375 +ISSUE_CA_FESCO_TICKET = 534454574 +ISSUE_CA_BUGZILLA_TRACKER = 21930 +ISSUE_CA_RELEASE_NOTES = 21931 +ISSUE_CA_CONTINGENCY = 11376 +ISSUE_CA_MASS_REBUILD = 11377 +ISSUE_CA_POLICY_CHANGE = 11378 +ISSUE_CA_MODIFIES_DELIVERABLES = 11379 +ISSUE_CA_VERSION = 11383 +USERSTORY_CA_SYSTEM_WIDE_CHANGE = 21923 +USERSTORY_CA_SUMMARY = 21924 +USERSTORY_CA_BUGZILLA_CONTACT = 21925 +USERSTORY_CA_RELENG_TICKET = 21926 +USERSTORY_CA_TRADEMARK_APPROVAL = 21927 +USERSTORY_CA_OWNERS = 21928 +USERSTORY_CA_FESCO_TICKET = 21929 +USERSTORY_CA_BUGZILLA_TRACKER = 21930 +USERSTORY_CA_RELEASE_NOTES = 21931 +USERSTORY_CA_CONTINGENCY = 21932 +USERSTORY_CA_MASS_REBUILD = 21933 +USERSTORY_CA_POLICY_CHANGE = 21934 +USERSTORY_CA_MODIFIES_DELIVERABLES = 21935 [PAGURE] diff --git a/tga/convert.py b/tga/convert.py index 2e317d0..abc95cc 100644 --- a/tga/convert.py +++ b/tga/convert.py @@ -118,28 +118,28 @@ def convert(value, configpath): if r.status_code == 201: print("step 3") data = json.loads(r.content) - us_id = data['id'] + USERSTORY_id = data['id'] print(id) payload = { "attributes_values": { - config['TAIGA']['US_CA_SYSTEM_WIDE_CHANGE']: system_wide_change, - config['TAIGA']['US_CA_SUMMARY']: summary, - config['TAIGA']['US_CA_RELENG_TICKET']: relengticket, - config['TAIGA']['US_CA_TRADEMARK_APPROVAL']: approval_required, - #config['TAIGA']['US_CA_OWNERS']: owners, - config['TAIGA']['US_CA_FESCO_TICKET']: 'random', - config['TAIGA']['US_CA_BUGZILLA_TRACKER']: 'random', - config['TAIGA']['US_CA_BUGZILLA_CONTACT']: bugzilla_id, - config['TAIGA']['US_CA_RELEASE_NOTES']: 'random', - config['TAIGA']['US_CA_CONTINGENCY']: contingency_deadline, - config['TAIGA']['US_CA_MASS_REBUILD']: mass_rebuild, - config['TAIGA']['US_CA_POLICY_CHANGE']: policy_change, - config['TAIGA']['US_CA_MODIFIES_DELIVERABLES']: modifies_deliverables + config['TAIGA']['USERSTORY_CA_SYSTEM_WIDE_CHANGE']: system_wide_change, + config['TAIGA']['USERSTORY_CA_SUMMARY']: summary, + config['TAIGA']['USERSTORY_CA_RELENG_TICKET']: relengticket, + config['TAIGA']['USERSTORY_CA_TRADEMARK_APPROVAL']: approval_required, + #config['TAIGA']['USERSTORY_CA_OWNERS']: owners, + config['TAIGA']['USERSTORY_CA_FESCO_TICKET']: 'random', + config['TAIGA']['USERSTORY_CA_BUGZILLA_TRACKER']: 'random', + config['TAIGA']['USERSTORY_CA_BUGZILLA_CONTACT']: bugzilla_id, + config['TAIGA']['USERSTORY_CA_RELEASE_NOTES']: 'random', + config['TAIGA']['USERSTORY_CA_CONTINGENCY']: contingency_deadline, + config['TAIGA']['USERSTORY_CA_MASS_REBUILD']: mass_rebuild, + config['TAIGA']['USERSTORY_CA_POLICY_CHANGE']: policy_change, + config['TAIGA']['USERSTORY_CA_MODIFIES_DELIVERABLES']: modifies_deliverables }, "version": 1 } print(payload) - r = tgauserstory.post_usca(payload, us_id, config) + r = tgauserstory.post_usca(payload, USERSTORY_id, config) print(json.loads(r.content)) print(r.status_code) if r.status_code == 200: @@ -154,11 +154,11 @@ def convert(value, configpath): epicref = i['ref'] break - r = tgaepic.post_relatedus(us_id, epicid, epicref, config) + r = tgaepic.post_relatedus(USERSTORY_id, epicid, epicref, config) if r.status_code == 201: print("Sucessfully mapped epics") payload = { - 'status': config['TAIGA']['IS_STATUS_PROCESSED'], + 'status': config['TAIGA']['ISSUE_STATUS_PROCESSED'], 'version': issue_version } r = tgaissue.changestatus_issue(issue_id, payload, config) @@ -167,7 +167,7 @@ def convert(value, configpath): #print(json.loads(r.content)) if r.status_code == 200: print("Sucessfully closed issue") - return True + return True, USERSTORY_id else: print("Unsuccesful at closing issue,check logs") else: diff --git a/tga/epics.py b/tga/epics.py index d690a32..2d501f4 100644 --- a/tga/epics.py +++ b/tga/epics.py @@ -49,7 +49,7 @@ def list_epic(config): print(e) -def post_relatedus(us_id, epicid, epicref, config): +def post_relatedus(USERSTORY_id, epicid, epicref, config): try: """ config = configparser.ConfigParser() @@ -62,7 +62,7 @@ def post_relatedus(us_id, epicid, epicref, config): } payload = { "epic": epicid, - "user_story": us_id + "user_story": USERSTORY_id } r = requests.post( 'https://api.taiga.io/api/v1/epics/' + str(epicid) + '/related_userstories', diff --git a/tga/issues.py b/tga/issues.py index 729904b..bf8a59e 100644 --- a/tga/issues.py +++ b/tga/issues.py @@ -13,10 +13,10 @@ project_id = config['TAIGA']['PROJECT_ID'] if config['TAIGA']['TEST'] == 'yes': taiga_url = config['TAIGA']['CUSTOM_TAIGA_URL'] - status = config['TAIGA']['TEST_IS_STATUS_NEW'] + status = config['TAIGA']['TEST_ISSUE_STATUS_NEW'] elif config['TAIGA']['TEST'] == 'no': taiga_url = config['TAIGA']['DEFAULT_TAIGA_URL'] - status = config['TAIGA']['IS_STATUS_NEW'] + status = config['TAIGA']['ISSUE_STATUS_NEW'] else: print("please set test status in config") @@ -34,8 +34,7 @@ def list_issue(args): configpath = args.config config = configparser.ConfigParser() config.read(configpath) - - url = str(config['TAIGA']['TAIGA_URL']) + "/api/v1/issues?project=" + str(config['TAIGA']['PROJECT_ID']) + "\&status=" + str(config['TAIGA']['IS_STATUS_NEW']) + url = str(config['TAIGA']['TAIGA_URL']) + "/api/v1/issues?project=" + config['TAIGA']['PROJECT_ID'] + "\&status=" + str(config['TAIGA']['ISSUE_STATUS_NEW']) print(url) # Debug only headers = { 'Content-Type': 'application/json', @@ -63,8 +62,11 @@ def list_issue(args): print(table) else: print("Unable to fetch list check logs") + print(r.content) except requests.exceptions.RequestException as e: print(e) + except Exception as e: + print(e) except Exception as e: print(e) @@ -130,7 +132,7 @@ def changestatus_issue(x, payload, config): } """ payload = { - 'status': config['TAIGA']['IS_STATUS_PROCESSED'], + 'status': config['TAIGA']['ISSUE_STATUS_PROCESSED'], 'version': issue_version } """ diff --git a/tga/userstory b/tga/userstory deleted file mode 100644 index e69de29..0000000 --- a/tga/userstory +++ /dev/null diff --git a/tga/userstory.py b/tga/userstory.py index 9221cb6..c2f825b 100644 --- a/tga/userstory.py +++ b/tga/userstory.py @@ -13,10 +13,10 @@ project_id = config['TAIGA']['PROJECT_ID'] if config['TAIGA']['TEST'] == 'yes': taiga_url = config['TAIGA']['CUSTOM_TAIGA_URL'] - status = config['TAIGA']['TEST_US_STATUS_NEW'] + status = config['TAIGA']['TEST_USERSTORY_STATUS_NEW'] elif config['TAIGA']['TEST'] == 'no': taiga_url = config['TAIGA']['DEFAULT_TAIGA_URL'] - status = config['TAIGA']['US_STATUS_NEW'] + status = config['TAIGA']['USERSTORY_STATUS_NEW'] else: print("please set test status in config") @@ -39,6 +39,7 @@ def get_us(refusid, config): # 'Authorization': 'Bearer {0}'.format(str(123)) } url = str(config['TAIGA']['TAIGA_URL']) + "/api/v1/userstories/by_ref?ref=" + str(refusid) + "\&project=" + str(config['TAIGA']['PROJECT_ID']) + url = "https://api.taiga.io/api/v1/issues?project=325667\&status=2283176" print(url) # debug only r = requests.get( url, @@ -49,18 +50,19 @@ def get_us(refusid, config): print(e) -def list_us(config): +def list_us(args): try: - """ + configpath = args.config config = configparser.ConfigParser() config.read(configpath) - """ headers = { 'Content-Type': 'application/json', 'Authorization': 'Bearer {0}'.format(keyring.get_password(config['TAIGA']['SERVICE_TOKEN'], "taiga_token")) # 'Authorization': 'Bearer {0}'.format(str(123)) } - url = str(config['TAIGA']['TAIGA_URL']) + "/api/v1/issues/userstories?project=" + str(config['TAIGA']['PROJECT_ID']) + "\&status=" + str(config['TAIGA']['US_STATUS_NEW']) + print(headers) + url = str(config['TAIGA']['TAIGA_URL']) + "/api/v1/userstories?project=" + str(config['TAIGA']['PROJECT_ID']) + "\&status=" + str(config['TAIGA']['USERSTORY_STATUS_NEW']) + url = "https://api.taiga.io/api/v1/issues?project=325667\&status=2283176" print(url) # Debug only try: r = requests.get( @@ -68,23 +70,29 @@ def list_us(config): headers=headers ) if r.status_code == 200: + print(r.status_code) table = BeautifulTable() table.column_headers = ["refrence no", "subject", "fedora-version", "owner"] data = json.loads(r.content) for item in data: subject = item['subject'] - us_id = item['id'] - us_ref = item['ref'] + USERSTORY_id = item['id'] + USERSTORY_ref = item['ref'] version = item['epics'] duedate = item['due_date'] tags = ['tags'] for item in data['owner_extra_info']: owner = item['username'] - table.append_row([us_ref, subject, version, owner]) - #print(us_id, us_ref owner) + table.append_row([USERSTORY_ref, subject, version, owner]) + #print(USERSTORY_id, USERSTORY_ref owner) print(table) + else: + print(r.content) except requests.exceptions.RequestException as e: print(e) + print(r.content) + except Exception as e: + print(e) except Exception as e: print(e) @@ -130,3 +138,9 @@ def post_usca(x, id, config): return r except requests.exceptions.RequestException as e: print(e) +""" +curl -X GET \ +-H "Content-Type: application/json" \ +-H "Authorization: Bearer ${eyJ1c2VyX2F1dGhlbnRpY2F0aW9uX2lkIjozNTY4MDR9:1hI6pm:4d4mA-gUXC2S0FxaladX0Fd_3gA}" \ +-s https://api.taiga.io/api/v1/issues?project=325667\&status=2283176 +""" \ No newline at end of file From 758b4efb8958774893bf16ade7a9b57b3889c854 Mon Sep 17 00:00:00 2001 From: Manas Date: Jun 28 2019 13:07:30 +0000 Subject: [PATCH 45/71] add bz to user story --- diff --git a/accept.py b/accept.py index e875d34..a7ab0b0 100644 --- a/accept.py +++ b/accept.py @@ -123,10 +123,10 @@ def accept(args): issuel = [] issuel.append(x) print(issuel) - conversion = convert.convert(issuel, configpath) + userstoryid, conversion = convert.convert(issuel, configpath) if conversion == True: print("Sucessfully Converted Issue to User story") - bz = pgba.pgtobz(issuel, configpath) + bz = pgba.pgtobz(issuel, userstoryid, configpath) if bz == True: print("""Sucessfully Created Bugzilla Bug and issue in release notes """) diff --git a/bz/bugs.py b/bz/bugs.py index fe0af4d..8a9a37a 100644 --- a/bz/bugs.py +++ b/bz/bugs.py @@ -29,6 +29,7 @@ def post_bug(createinfo, bzapi, config): print(createinfo) newbug = bzapi.createbug(createinfo) #print(newbug) + return newbug print("Created new bug id=%s url=%s" % (newbug.id, newbug.weburl)) """ url = str(config['BUGZILLA']['BUGZILLA_URL']) + "/rest.cgi/bug?" + "api_key=ZzKzxycfIG42FD1PaEEzJbTiZwCGIoo2GJvkWZGt"#.format(keyring.get_password(config['BUGZILLA']['SERVICE_TOKEN'], "api_token")) diff --git a/tga/convert.py b/tga/convert.py index abc95cc..23bda45 100644 --- a/tga/convert.py +++ b/tga/convert.py @@ -118,7 +118,7 @@ def convert(value, configpath): if r.status_code == 201: print("step 3") data = json.loads(r.content) - USERSTORY_id = data['id'] + userstoryid = data['id'] print(id) payload = { "attributes_values": { @@ -139,7 +139,7 @@ def convert(value, configpath): "version": 1 } print(payload) - r = tgauserstory.post_usca(payload, USERSTORY_id, config) + r = tgauserstory.post_usca(payload, userstoryid, config) print(json.loads(r.content)) print(r.status_code) if r.status_code == 200: @@ -154,7 +154,7 @@ def convert(value, configpath): epicref = i['ref'] break - r = tgaepic.post_relatedus(USERSTORY_id, epicid, epicref, config) + r = tgaepic.post_relatedus(userstoryid, epicid, epicref, config) if r.status_code == 201: print("Sucessfully mapped epics") payload = { @@ -167,7 +167,7 @@ def convert(value, configpath): #print(json.loads(r.content)) if r.status_code == 200: print("Sucessfully closed issue") - return True, USERSTORY_id + return userstoryid, True else: print("Unsuccesful at closing issue,check logs") else: From f63b619b75fdc1bb9c7759da0be0597820a70a78 Mon Sep 17 00:00:00 2001 From: Manas Date: Jun 28 2019 13:08:06 +0000 Subject: [PATCH 46/71] add announced status after mail sent --- diff --git a/config.ini b/config.ini index 7d9da54..7a1192d 100644 --- a/config.ini +++ b/config.ini @@ -7,6 +7,8 @@ TAIGA_SITE_ISSUE_URL = https://tree.taiga.io/project/pac_23-test-changes-tracker ISSUE_STATUS_NEW = 2283176 ISSUE_STATUS_NEEDS_INFO = 2283180 +ISSSUE_STATUS_ACCEPTED = 2302390 +ISSUE_STATUS_ANNOUNCED = 2302389 ISSUE_STATUS_READY_FOR_WRANGLER = 2283232 ISSUE_STATUS_READY_FOR_FESCO = 2295359 ISSUE_STATUS_PROCESSED = 2283182 diff --git a/config_depre.ini b/config_depre.ini index 5616928..d8276f6 100644 --- a/config_depre.ini +++ b/config_depre.ini @@ -5,11 +5,11 @@ PROJECT_ID = 325667 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/ -IS_STATUS_NEW = 21 -IS_STATUS_NEEDS_INFO = 22 -IS_STATUS_READY_FOR_WRANGLER = 12 -IS_STATUS_PROCESSED = 24 -IS_CA_VERSION = 25 +ISSUE_STATUS_NEW = 21 +ISSUE_STATUS_NEEDS_INFO = 22 +ISSUE_STATUS_READY_FOR_WRANGLER = 12 +ISSUE_STATUS_PROCESSED = 24 +ISSUE_CA_VERSION = 25 US_STATUS_ANNOUNCED = 25 US_STATUS_R_FESCO = 30 US_STATUS_ACCEPTED = 31 @@ -17,10 +17,10 @@ US_STATUS_ARCHIVED = 32 US_STATUS_CODE_COMPLETE = 33 US_STATUS_TESTABLE = 34 -TEST_IS_STATUS_NEW = 2283176 -TEST_IS_STATUS_NEEDS_INFO = 2283180 -TEST_IS_STATUS_READY_FOR_WRANGLER = 2283232 -TEST_IS_STATUS_PROCESSED = 2283182 +TEST_ISSUE_STATUS_NEW = 2283176 +TEST_ISSUE_STATUS_NEEDS_INFO = 2283180 +TEST_ISSUE_STATUS_READY_FOR_WRANGLER = 2283232 +TEST_ISSUE_STATUS_PROCESSED = 2283182 TEST_US_STATUS_NEW = 1952887 TEST_US_STATUS_ANNOUNCED = 1952888 TEST_US_STATUS_R_FESCO = 1952889 @@ -29,20 +29,20 @@ TEST_US_STATUS_ARCHIVED = 1952890 TEST_US_STATUS_CODE_COMPLETE = 1892839 TEST_US_STATUS_TESTABLE = 1952932 -TEST_IS_CA_SYSTEM_WIDE_CHANGE = 11370 -TEST_IS_CA_SUMMARY = 11372 -TEST_IS_CA_BUGZILLA_CONTACT = 11373 -TEST_IS_CA_RELENG_TICKET = 11371 -TEST_IS_CA_TRADEMARK_APPROVAL = 11374 -TEST_IS_CA_OWNERS = 11375 -TEST_IS_CA_FESCO_TICKET = 534454574 -TEST_IS_CA_BUGZILLA_TRACKER = 21930 -TEST_IS_CA_RELEASE_NOTES = 21931 -TEST_IS_CA_CONTINGENCY = 11376 -TEST_IS_CA_MASS_REBUILD = 11377 -TEST_IS_CA_POLICY_CHANGE = 11378 -TEST_IS_CA_MODIFIES_DELIVERABLES = 11379 -TEST_IS_CA_VERSION = 11383 +TEST_ISSUE_CA_SYSTEM_WIDE_CHANGE = 11370 +TEST_ISSUE_CA_SUMMARY = 11372 +TEST_ISSUE_CA_BUGZILLA_CONTACT = 11373 +TEST_ISSUE_CA_RELENG_TICKET = 11371 +TEST_ISSUE_CA_TRADEMARK_APPROVAL = 11374 +TEST_ISSUE_CA_OWNERS = 11375 +TEST_ISSUE_CA_FESCO_TICKET = 534454574 +TEST_ISSUE_CA_BUGZILLA_TRACKER = 21930 +TEST_ISSUE_CA_RELEASE_NOTES = 21931 +TEST_ISSUE_CA_CONTINGENCY = 11376 +TEST_ISSUE_CA_MASS_REBUILD = 11377 +TEST_ISSUE_CA_POLICY_CHANGE = 11378 +TEST_ISSUE_CA_MODIFIES_DELIVERABLES = 11379 +TEST_ISSUE_CA_VERSION = 11383 TEST_US_CA_SYSTEM_WIDE_CHANGE = 21923 TEST_US_cA_SUMMARY = 21924 TEST_US_CA_BUGZILLA_CONTACT = 21925 diff --git a/mail/climail.py b/mail/climail.py index 41c7360..049558b 100644 --- a/mail/climail.py +++ b/mail/climail.py @@ -65,9 +65,11 @@ def mails(args): r = issues.get_issue(x, config) if r.status_code == 200: data = json.loads(r.content) + issue_id = data['id'] + issue_version = data['version'] print(data) try: - ra = issues.caget_issue(data['id'], config) + ra = issues.caget_issue(issue_id, config) if ra.status_code == 200: cadata = json.loads(ra.content) """ @@ -85,7 +87,19 @@ def mails(args): editor.edit(filename="mail.txt") try: subject = str(cadata['attributes_values']['11383']) + ":" + str(data['subject']) - maillist.email_send(subject, args.reply, config) + mailstatus = maillist.email_send(subject, args.reply, config) + if mailstatus == True: + payload = { + 'status': config['TAIGA']['ISSUE_STATUS_ANNOUNCED'], + 'version': issue_version + } + r = tgaissue.changestatus_issue(issue_id, payload, config) + if r.status_code == 200: + print("Sucessfully changed status to announced") + else: + print("Unable to Change issue status") + else: + print("Mail was not sent check logs for errors") except Exception as e: print(e) else: diff --git a/mail/maillist.py b/mail/maillist.py index 4e245e9..79fa0ed 100644 --- a/mail/maillist.py +++ b/mail/maillist.py @@ -69,7 +69,7 @@ def email_send(subject, replyto, config): print(password, "this is pass") try: msg = MIMEMultipart() - msg['To'] = reciver_email + msg['To'] = reciver_emails msg['From'] = username msg['Subject'] = subject print("this step") @@ -88,5 +88,6 @@ def email_send(subject, replyto, config): server.sendmail(sender_email, reciver_email, msg.as_string()) #server.send_message(msg) print("succesfully sent email") + return True except Exception as e: print(e) From 78622ab59de5617bcb37a6b73b95936b44ca3cd5 Mon Sep 17 00:00:00 2001 From: Manas Date: Jun 28 2019 13:23:35 +0000 Subject: [PATCH 47/71] is expanded to issue in fesco --- diff --git a/pgure/fesco.py b/pgure/fesco.py index 3e3c97b..73dac8d 100644 --- a/pgure/fesco.py +++ b/pgure/fesco.py @@ -86,7 +86,7 @@ def fesissue(args): print(r) if r.status_code == 200: payload = { - 'status': config['TAIGA']['IS_STATUS_READY_FOR_FESCO'], + 'status': config['TAIGA']['ISSUE_STATUS_READY_FOR_FESCO'], 'version': taiga_issue_version } r = tgaissue.changestatus_issue(taiga_issue_id, payload, config) From 7e3b55268c5fd3708b0cf64ee3c3cc74608265fb Mon Sep 17 00:00:00 2001 From: Manas Date: Jun 28 2019 13:24:03 +0000 Subject: [PATCH 48/71] userstoryid typo fixed --- diff --git a/bz/pgba.py b/bz/pgba.py index 3b0a78e..92b3f8d 100644 --- a/bz/pgba.py +++ b/bz/pgba.py @@ -12,7 +12,7 @@ from bz import bugs as bzbugs import bugzilla -def pgtobz(value, USERSTORY_id, configpath): +def pgtobz(value, userstoryid, configpath): config = configparser.ConfigParser() config.read(configpath) service_id = config['TAIGA']['SERVICE_ID'] # service id @@ -119,7 +119,7 @@ def pgtobz(value, USERSTORY_id, configpath): }, "version": 2 } - r = tgauserstory.post_usca(payload, USERSTORY_id, config) + r = tgauserstory.post_usca(payload, userstoryid, config) if r.status_code == 200: print("Sucessfully mapped bz to user story") else: @@ -128,9 +128,9 @@ def pgtobz(value, USERSTORY_id, configpath): print("failed to complete acceptance") except requests.exceptions.RequestException as e: print("Failed to fetch attributes of the issue") - print(e) + print(e) except Exception as e: - print(e) + print(e) except requests.exceptions.RequestException as e: print("Failed to fetch attributes of the issue") print(e) From 4f8c40c1fb6c801913ba1a9fbe443661619d4108 Mon Sep 17 00:00:00 2001 From: pac23 Date: Jul 03 2019 12:01:01 +0000 Subject: [PATCH 49/71] fixes #21 sync between bz and taiga --- diff --git a/.gitignore b/.gitignore index 0d20b64..abb94a1 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ *.pyc +/venv \ No newline at end of file diff --git a/bz/bugs.py b/bz/bugs.py index 8a9a37a..c363d66 100644 --- a/bz/bugs.py +++ b/bz/bugs.py @@ -48,6 +48,12 @@ def post_bug(createinfo, bzapi, config): print(e) return e """ +def get_bug(bugid, bzapi, config): + if not bzapi.logged_in: + bzapi.interactive_login() + print(bugid) + bug = bzapi.getbug(bugid) + return bug """ curl -X GET \ -H "Content-Type: application/json" \ diff --git a/bz/pgba.py b/bz/pgba.py index 92b3f8d..2a9ba22 100644 --- a/bz/pgba.py +++ b/bz/pgba.py @@ -120,7 +120,7 @@ def pgtobz(value, userstoryid, configpath): "version": 2 } r = tgauserstory.post_usca(payload, userstoryid, config) - if r.status_code == 200: + if r.status_code == 201: print("Sucessfully mapped bz to user story") else: print("check logs for errors") diff --git a/main.py b/main.py index e26fec0..bf29c6d 100644 --- a/main.py +++ b/main.py @@ -4,7 +4,9 @@ import requests import json import argparse import sys -import accept +import accept +import sync + from tga import taiga_auth from pgure import pagure_auth from bz import bugzilla_auth @@ -128,14 +130,14 @@ class Change_Tool(object): def list(self): parser = argparse.ArgumentParser( description='announces to mailing list') - parser.add_argument('--list', help='runs the auth instance') + #parser.add_argument('--list', help='runs the auth instance') subparsers = parser.add_subparsers(dest='command', help='sub-command help') # list issues - issue = subparser.add_parser('issue', help='Lists issues') + issue = subparsers.add_parser('issue', help='Lists issues') issue.add_argument('--pending', action='store_true', help='lists all the pending issues') - userstory = subparser.add_parser('userstory', help='Lists user stories') + userstory = subparsers.add_parser('userstory', help='Lists user stories') userstory.add_argument('--pending', action='store_true', help='lists pending users stories') parser.add_argument('--config', #action='store', @@ -145,16 +147,14 @@ class Change_Tool(object): #required=False, help='Sets config path') args = parser.parse_args(sys.argv[2:]) - if args.list: - print("Incomplete command,please specify right sub-command") if args.command == 'issue': if args.pending: - tguserstory.list_us(args) + tgaissue.list_issue(args) else: print("wrong command") elif args.command == 'userstory': if args.pending: - tgaissue.issue_list(args) + tguserstory.list_us(args) else: print("Wrong command") else: @@ -231,6 +231,22 @@ class Change_Tool(object): #accept.accept(args.accept, args.config) accept.accept(args) + def sync(self): + parser = argparse.ArgumentParser( + description='Syncing Between Bugzilla and Taiga') + parser.add_argument('--sync_status', + nargs='+', + type=int, + help='Syncing between bugzilla and taiga') + parser.add_argument('--config', + #dest='configpath', + #action='store', + #type=string, + default='config.ini', + help='Sets config path') + args = parser.parse_args(sys.argv[2:]) + sync.sync(args) + """ def config(self): parser = argparse.ArgumentParser( diff --git a/sync.py b/sync.py new file mode 100644 index 0000000..cdf2677 --- /dev/null +++ b/sync.py @@ -0,0 +1,110 @@ +import requests +import json +import keyring +import os +import configparser +import editor +import bugzilla + +from tga import epics as tgaepic +from tga import issues as tgaissue +from tga import userstory as tgauserstory +from pgure import issues as pgaissues +from bz import bugs as bzbugs +from urllib.parse import urlparse + +def sync(args): + # fvid is fedora version + configpath = args.config + config = configparser.ConfigParser() + config.read(configpath) + fvid = args.sync_status + bzapi = bugzilla.Bugzilla(config['BUGZILLA']['BUGZILLA_URL']) + for x in fvid: + #config.read('config.ini') + + """ + bzapi = bzapi = bugzilla.Bugzilla(URL) + query = bzapi.build_query( + component="Changes Tracking", + status="NEW", + include_fields=["description"]) + #query["status"] = "NEW" + bugs = bzapi.query(query) + print(bugs) + """ + print(x) + try: + r = tgaepic.list_epic(config) + if r.status_code == 200: + data = json.loads(r.content) + #print(data) + for i in data: + print(i['subject']) + if int(i['subject']) == x: + epicid = i['id'] + epicref = i['ref'] + break + + #url = str(config['TAIGA']['TAIGA_URL']) + "/api/v1/issues/userstories? + r = tgaepic.listrelepic_userstory(epicid, config) + if r.status_code == 200: + data = json.loads(r.content) + for i in data: + userstoryid = i['user_story'] + print(userstoryid) + try: + r = tgauserstory.get_us(userstoryid, config) + if r.status_code == 200: + userstorydata = json.loads(r.content) + userstory_version = userstorydata['version'] + userstoryref = userstorydata['ref'] + r = tgauserstory.caget_us(userstoryid, config) + userstorycadata = json.loads(r.content) + bztracker = userstorycadata['attributes_values'][config['TAIGA']['USERSTORY_CA_BUGZILLA_TRACKER']] + bugid = urlparse(bztracker).query.lstrip("id=") + print(bugid) + bug = bzbugs.get_bug(bugid, bzapi, config) + if bug.status == 'MODIFIED': + statusid = config['TAIGA']['USERSTORY_STATUS_TESTABLE'] + elif bug.status == 'ON_QA': + statusid = config['TAIGA']['USERSTORY_STATUS_CODE_COMPLETE'] + #elif bug.status == 'VERIFIED': + #elif bug.status == 'RELEASE_PENDING': + elif bug.status == 'CLOSED': + statusid = config['TAIGA']['USERSTORY_STATUS_ARCHIVED'] + else: + print("failed to fetch bug status") + payload = { + 'status': statusid, + 'version': userstory_version + } + try: + r = tgauserstory.changestatus_userstory(userstoryid, payload, config) + if r.status_code == 200: + print("Sucesfully Synced status from Bugzilla Bug {} to Taiga Userstory {}".format(bug.id, userstoryref)) + else: + print("Check logs for errors,Unable to Sync",r.content, r.status_code) + except requests.exceptions.RequestException as e: + print(e) + except Exception as e: + print(e) + else: + print("Error in fetching user story") + except requests.exceptions.RequestException as e: + print(e) + except Exception as e: + print(e) + else: + print("Unable to fetch epic related user stories,check logs for errors") + else: + print("Unable to Sync Check logs", r.content) + except requests.exceptions.RequestException as e: + print(e) + except Exception as e: + print(e) + +""" +if __name__ == "__main__": + sync() +""" \ No newline at end of file diff --git a/tga/epics.py b/tga/epics.py index 2d501f4..2cd266c 100644 --- a/tga/epics.py +++ b/tga/epics.py @@ -40,6 +40,7 @@ def list_epic(config): 'Authorization': 'Bearer {0}'.format(keyring.get_password(config['TAIGA']['SERVICE_TOKEN'], "taiga_token")) } url = str(config['TAIGA']['TAIGA_URL']) + "/api/v1/epics?project=" + str(config['TAIGA']['PROJECT_ID']) + print(url) r = requests.get( url, headers=headers @@ -47,6 +48,8 @@ def list_epic(config): return r except requests.exceptions.RequestException as e: print(e) + except Exception as e: + print(e) def post_relatedus(USERSTORY_id, epicid, epicref, config): @@ -72,3 +75,23 @@ def post_relatedus(USERSTORY_id, epicid, epicref, config): return r except requests.exceptions.RequestException as e: print(e) + +def listrelepic_userstory(epicid, config): + #url = str(config['TAIGA']['TAIGA_URL']) + "/api/v1/userstories?project=" + str(config['TAIGA']['PROJECT_ID']) + "&epic=" + epicid + url = str(config['TAIGA']['TAIGA_URL']) + '/api/v1/epics/' + str(epicid) + '/related_userstories' + print(url) + headers = { + 'Content-Type': 'application/json', + 'x-disable-pagination': 'True', + 'Authorization': 'Bearer {0}'.format(keyring.get_password(config['TAIGA']['SERVICE_TOKEN'], "taiga_token")) + } + try: + r = requests.get( + url, + headers=headers + ) + return r + except requests.exceptions.RequestException as e: + print(e) + except Exception as e: + print(e) \ No newline at end of file diff --git a/tga/issues.py b/tga/issues.py index bf8a59e..a457449 100644 --- a/tga/issues.py +++ b/tga/issues.py @@ -34,7 +34,7 @@ def list_issue(args): configpath = args.config config = configparser.ConfigParser() config.read(configpath) - url = str(config['TAIGA']['TAIGA_URL']) + "/api/v1/issues?project=" + config['TAIGA']['PROJECT_ID'] + "\&status=" + str(config['TAIGA']['ISSUE_STATUS_NEW']) + url = str(config['TAIGA']['TAIGA_URL']) + "/api/v1/issues?project=" + config['TAIGA']['PROJECT_ID'] + "&status=" + str(config['TAIGA']['ISSUE_STATUS_NEW']) print(url) # Debug only headers = { 'Content-Type': 'application/json', @@ -107,7 +107,7 @@ def caget_issue(x, config): # 'Authorization': 'Bearer {0}'.format(str(123)) } print(x) - id_url = str(config['TAIGA']['TAIGA_URL']) + "/api/v1/issues/custom-attributes-values/" + str(x) # x is id + id_url = str(config['TAIGA']['TAIGA_URL']) + "/api/v1/issues/custom-attributes-values/" + str(x) # x is issue id print(id_url) try: r = requests.get( diff --git a/tga/userstory.py b/tga/userstory.py index c2f825b..4660fa2 100644 --- a/tga/userstory.py +++ b/tga/userstory.py @@ -27,29 +27,6 @@ headers = { """ -def get_us(refusid, config): - try: - """ - config = configparser.ConfigParser() - config.read(configpath) - """ - headers = { - 'Content-Type': 'application/json', - 'Authorization': 'Bearer {0}'.format(keyring.get_password(config['TAIGA']['SERVICE_TOKEN'], "taiga_token")) - # 'Authorization': 'Bearer {0}'.format(str(123)) - } - url = str(config['TAIGA']['TAIGA_URL']) + "/api/v1/userstories/by_ref?ref=" + str(refusid) + "\&project=" + str(config['TAIGA']['PROJECT_ID']) - url = "https://api.taiga.io/api/v1/issues?project=325667\&status=2283176" - print(url) # debug only - r = requests.get( - url, - headers=headers - ) - return r - except requests.exceptions.RequestException as e: - print(e) - - def list_us(args): try: configpath = args.config @@ -61,8 +38,8 @@ def list_us(args): # 'Authorization': 'Bearer {0}'.format(str(123)) } print(headers) - url = str(config['TAIGA']['TAIGA_URL']) + "/api/v1/userstories?project=" + str(config['TAIGA']['PROJECT_ID']) + "\&status=" + str(config['TAIGA']['USERSTORY_STATUS_NEW']) - url = "https://api.taiga.io/api/v1/issues?project=325667\&status=2283176" + url = str(config['TAIGA']['TAIGA_URL']) + "/api/v1/userstories?project=" + str(config['TAIGA']['PROJECT_ID']) + "&status=" + str(config['TAIGA']['USERSTORY_STATUS_NEW']) + #url = "https://api.taiga.io/api/v1/issues?project=325667\&status=2283176" print(url) # Debug only try: r = requests.get( @@ -97,6 +74,50 @@ def list_us(args): print(e) +def get_us(usid, config): + try: + """ + config = configparser.ConfigParser() + config.read(configpath) + """ + headers = { + 'Content-Type': 'application/json', + 'Authorization': 'Bearer {0}'.format(keyring.get_password(config['TAIGA']['SERVICE_TOKEN'], "taiga_token")) + # 'Authorization': 'Bearer {0}'.format(str(123)) + } + #url = str(config['TAIGA']['TAIGA_URL']) + "/api/v1/userstories/by_ref?ref=" + str(refusid) + "\&project=" + str(config['TAIGA']['PROJECT_ID']) + #url = "https://api.taiga.io/api/v1/issues?project=325667\&status=2283176" + url = str(config['TAIGA']['TAIGA_URL']) + "/api/v1/userstories/" + str(usid) + print(url) # debug only + r = requests.get( + url, + headers=headers + ) + return r + except requests.exceptions.RequestException as e: + print(e) + except Exception as e: + print(e) + + +def caget_us(usid, config): + try: + headers = { + 'Content-Type': 'application/json', + 'Authorization': 'Bearer {0}'.format(keyring.get_password(config['TAIGA']['SERVICE_TOKEN'], "taiga_token")) + } + url = str(config['TAIGA']['TAIGA_URL']) + "/api/v1/userstories/" + "/custom-attributes-values/" + str(usid) + r = requests.get( + url, + headers=headers + ) + return r + except requests.exceptions.RequestException as e: + print(e) + except Exception as e: + print(e) + + def post_us(x, config): try: """ @@ -138,9 +159,53 @@ def post_usca(x, id, config): return r except requests.exceptions.RequestException as e: print(e) + + +def changestatus_userstory(x, payload, config): + """ + config = configparser.ConfigParser() + config.read(configpath) + """ + id_url = str(config['TAIGA']['TAIGA_URL']) + "/api/v1/userstories/" + str(x) # x is id + print(id_url) + headers = { + 'Content-Type': 'application/json', + 'Authorization': 'Bearer {0}'.format(keyring.get_password(config['TAIGA']['SERVICE_TOKEN'], "taiga_token")) + # 'Authorization': 'Bearer {0}'.format(str(123)) + } + """ + payload = { + 'status': config['TAIGA']['ISSUE_STATUS_PROCESSED'], + 'version': issue_version + } + """ + try: + r = requests.patch( + id_url, + data=json.dumps(payload), + headers=headers + ) + return r + except requests.exceptions.RequestException as e: + print(e) + + +def listrelepic_userstory(epicid, config): + url = str(config['TAIGA']['TAIGA_URL']) + "/api/v1/userstories?project=" + str(config['TAIGA']['PROJECT_ID']) + "&epic=" + epicid + try: + r = requests.get( + url, + headers=headers + ) + return r + except requests.exceptions.RequestException as e: + print(e) + except Exception as e: + print(e) """ curl -X GET \ -H "Content-Type: application/json" \ -H "Authorization: Bearer ${eyJ1c2VyX2F1dGhlbnRpY2F0aW9uX2lkIjozNTY4MDR9:1hI6pm:4d4mA-gUXC2S0FxaladX0Fd_3gA}" \ -s https://api.taiga.io/api/v1/issues?project=325667\&status=2283176 -""" \ No newline at end of file +""" + From 1103a73a838e5925eebbcbcc3c0f5f004d3982a2 Mon Sep 17 00:00:00 2001 From: pac23 Date: Jul 03 2019 14:42:48 +0000 Subject: [PATCH 50/71] fix list issue of user story --- diff --git a/tga/issues.py b/tga/issues.py index a457449..e29d676 100644 --- a/tga/issues.py +++ b/tga/issues.py @@ -3,6 +3,8 @@ import configparser import keyring import requests +from beautifultable import BeautifulTable + """ config = configparser.ConfigParser() config.read('config.ini') @@ -48,17 +50,28 @@ def list_issue(args): ) if r.status_code == 200: table = BeautifulTable() - table.column_headers = ["refrence no", "subject", "fedora-version", "owner"] + table.column_headers = ["refrence no", "subject", "fedora-version"] data = json.loads(r.content) for item in data: + print(item) due_date = item['due_date'] issueid = item['id'] - issuerefrence = item['ref'] + issueref= item['ref'] subject = item['subject'] - version = "version" + version = item['version'] + print(issueref) + r = caget_issue(issueid, config) + if r.status_code == 200: + cadata = json.loads(r.content) + version = cadata['attributes_values'][config['TAIGA']['ISSUE_CA_VERSION']] #['11383'] + else: + print("Error fetching Fedora Version") + """ for item in data['owner_extra_info']: + print(item) owner = item['username'] - table.append_row([issueref, subject, version, owner]) + """ + table.append_row([issueref, subject, version]) print(table) else: print("Unable to fetch list check logs") From f4c3f8d2d59c8623ca88a0a7a104c3342b3be975 Mon Sep 17 00:00:00 2001 From: pac23 Date: Jul 03 2019 14:43:19 +0000 Subject: [PATCH 51/71] change config from hardcoded to dynamic using config file in convert function --- diff --git a/tga/convert.py b/tga/convert.py index 23bda45..87fd569 100644 --- a/tga/convert.py +++ b/tga/convert.py @@ -74,17 +74,17 @@ def convert(value, configpath): print(data, "step 2") #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'] - fedora_version = data['attributes_values']['11383'] + summary = data['attributes_values'][config['TAIGA']['ISSUE_CA_SUMMARY']]# ['11372'] + bugzilla_id = data['attributes_values'][config['TAIGA']['ISSUE_CA_BUGZILLA_CONTACT']]# ['11373'] + approval_required = data['attributes_values'][config['TAIGA']['ISSUE_CA_TRADEMARK_APPROVAL']]#['11374'] + owners = data['attributes_values'][config['TAIGA']['ISSUE_CA_OWNERS']]#['11375'] + contingency_deadline = data['attributes_values'][config['TAIGA']['ISSUE_CA_CONTINGENCY']]#['11376'] + mass_rebuild = data['attributes_values'][config['TAIGA']['ISSUE_CA_MASS_REBUILD']]#['11377'] + policy_change = data['attributes_values'][config['TAIGA']['ISSUE_CA_POLICY_CHANGE']]#['11378'] + modifies_deliverables = data['attributes_values'][config['TAIGA']['ISSUE_CA_MODIFIES_DELIVERABLES']]#['11379'] + system_wide_change = data['attributes_values'][config['TAIGA']['ISSUE_CA_SYSTEM_WIDE_CHANGE']]#['11370'] + relengticket = data['attributes_values'][config['TAIGA']['ISSUE_CA_RELENG_TICKET']]#['11371'] + fedora_version = data['attributes_values'][config['TAIGA']['ISSUE_CA_VERSION']]#['11383'] print(fedora_version) #print("summary", summary) #print(bugzilla_id) @@ -119,6 +119,7 @@ def convert(value, configpath): print("step 3") data = json.loads(r.content) userstoryid = data['id'] + usestory_version = data['version'] print(id) payload = { "attributes_values": { @@ -136,14 +137,14 @@ def convert(value, configpath): config['TAIGA']['USERSTORY_CA_POLICY_CHANGE']: policy_change, config['TAIGA']['USERSTORY_CA_MODIFIES_DELIVERABLES']: modifies_deliverables }, - "version": 1 + "version": usestory_version } print(payload) r = tgauserstory.post_usca(payload, userstoryid, config) print(json.loads(r.content)) print(r.status_code) if r.status_code == 200: - print("Sucessfully converted issue to user story") + print("Sucessfully mapped issue custom attirbutes to userstory") try: r = tgaepic.list_epic(config) data = json.loads(r.content) @@ -156,22 +157,33 @@ def convert(value, configpath): r = tgaepic.post_relatedus(userstoryid, epicid, epicref, config) if r.status_code == 201: + data = json.loads(r.content) + usestory_version = data['version'] print("Sucessfully mapped epics") payload = { - 'status': config['TAIGA']['ISSUE_STATUS_PROCESSED'], - 'version': issue_version + 'status': config['TAIGA']['USERSTORY_STATUS_ACCEPTED'], + 'version': usestory_version } - r = tgaissue.changestatus_issue(issue_id, payload, config) - print(r.status_code) - print(r.content) - #print(json.loads(r.content)) - if r.status_code == 200: - print("Sucessfully closed issue") - return userstoryid, True + r = tgauserstory.changestatus_userstory(userstoryid, payload, config) + if r.status_code == 201: + print("Sucessfully converted issue to user story") + payload = { + 'status': config['TAIGA']['ISSUE_STATUS_PROCESSED'], + 'version': issue_version + } + r = tgaissue.changestatus_issue(issue_id, payload, config) + print(r.status_code) + print(r.content) + #print(json.loads(r.content)) + if r.status_code == 201: + print("Sucessfully closed issue") + return userstoryid, True + else: + print("Unsuccesful at closing issue,check logs") else: - print("Unsuccesful at closing issue,check logs") + print("Converted User story,copied attributes mapped epics,faliure to change status to accepted") else: - print("Unnsucessful conversion please check logs") + print("Unnsucessful to map to epics,change user story status to accepted and issue status to processed") except requests.exceptions.RequestException as e: print(e) else: From 88184497b96af0c902c6bc7a03725b71c12b889f Mon Sep 17 00:00:00 2001 From: pac23 Date: Jul 03 2019 14:43:50 +0000 Subject: [PATCH 52/71] fix 200 to 201 for emails --- diff --git a/mail/climail.py b/mail/climail.py index 049558b..30eafad 100644 --- a/mail/climail.py +++ b/mail/climail.py @@ -94,7 +94,7 @@ def mails(args): 'version': issue_version } r = tgaissue.changestatus_issue(issue_id, payload, config) - if r.status_code == 200: + if r.status_code == 201: print("Sucessfully changed status to announced") else: print("Unable to Change issue status") From 1e261a89398e3d44f49c4c7183adaf97cbbec5be Mon Sep 17 00:00:00 2001 From: pac23 Date: Jul 05 2019 12:18:23 +0000 Subject: [PATCH 53/71] Documentation first draft --- diff --git a/Docs/antora.yml b/Docs/antora.yml new file mode 100644 index 0000000..f5d64d9 --- /dev/null +++ b/Docs/antora.yml @@ -0,0 +1,10 @@ +name: Fedora-change-wrangler-docs + +title: Fedora-change-wrangler-docs + +version: master + +start_page: ROOT:index + +nav: + - modules/ROOT/nav.adoc \ No newline at end of file diff --git a/Docs/build.sh b/Docs/build.sh new file mode 100644 index 0000000..05e4e7c --- /dev/null +++ b/Docs/build.sh @@ -0,0 +1,90 @@ +#!/bin/sh + + +image="docker.io/antora/antora" + +cmd="--html-url-extension-style=indexify site.yml" + + + +if [ "$(uname)" == "Darwin" ]; then + + # Running on macOS. + + # Let's assume that the user has the Docker CE installed + + # which doesn't require a root password. + + echo "" + + echo "This build script is using Docker container runtime to run the build in an isolated environment." + + echo "" + + docker run --rm -it -v $(pwd):/antora $image $cmd + + + +elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then + + # Running on Linux. + + # Check whether podman is available, else faill back to docker + + # which requires root. + + + + if [ -f /usr/bin/podman ]; then + + echo "" + + echo "This build script is using Podman to run the build in an isolated environment." + + echo "" + + podman run --rm -it -v $(pwd):/antora:z $image $cmd + + + + elif [ -f /usr/bin/docker ]; then + + echo "" + + echo "This build script is using Docker to run the build in an isolated environment." + + echo "" + + + + if groups | grep -wq "docker"; then + + docker run --rm -it -v $(pwd):/antora:z $image $cmd + + else + + echo "" + + echo "This build script is using $runtime to run the build in an isolated environment. You might be asked for your password." + + echo "You can avoid this by adding your user to the 'docker' group, but be aware of the security implications. See https://docs.docker.com/install/linux/linux-postinstall/." + + echo "" + + sudo docker run --rm -it -v $(pwd):/antora:z $image $cmd + + fi + + else + + echo "" + + echo "Error: Container runtime haven't been found on your system. Fix it by:" + + echo "$ sudo dnf install podman" + + exit 1 + + fi + +fi \ No newline at end of file diff --git a/Docs/modules/ROOT/nav.adoc b/Docs/modules/ROOT/nav.adoc new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/Docs/modules/ROOT/nav.adoc @@ -0,0 +1 @@ + diff --git a/Docs/modules/ROOT/pages/Accept/accepting-changes.adoc b/Docs/modules/ROOT/pages/Accept/accepting-changes.adoc new file mode 100644 index 0000000..148179f --- /dev/null +++ b/Docs/modules/ROOT/pages/Accept/accepting-changes.adoc @@ -0,0 +1,34 @@ +ifdef::context[:parent-context: {context}] +:context: accepting-changes + += Accepting Changes in the Tool + +Accept command enables the user to accept a change proosal. It takes the issue no as a argument and initiates the convert functionality followed by creating the issue in bugzilla linked with the pagure repo. + +== Usage + +include::config.note.adoc[] + +Accept has only once command that does everything mentioned in the above sections + +Accepts the Change Converts Issue to UserStory creates a Bug in bugzilla +"X" stands for issue Refrence/No from taiga + ++ +---- +fedora-change-wrangler accept --accept "X" +---- + + + +The --accept flag is to let the system know that you are passing N number of issue no's. + +The --config can be passed as ++ +---- +fedora-change-wrangler accept --accept "X" --config +---- + + + + diff --git a/Docs/modules/ROOT/pages/Announce/announce-mailinglist.adoc b/Docs/modules/ROOT/pages/Announce/announce-mailinglist.adoc new file mode 100644 index 0000000..8e5e483 --- /dev/null +++ b/Docs/modules/ROOT/pages/Announce/announce-mailinglist.adoc @@ -0,0 +1,38 @@ +ifdef::context[:parent-context: {context}] +:context: annoucing-mailinglist + += Annoucing to the Mailing list + +The Annouce command announces to the Mailing list. It takes the issue refrence no as a argument and initiates the mailing functionality.It will fetch the issue with its description,summary and all other attributes and send a mail as per the predefined email id list in the config. + +== Usage + +include::config.note.adoc[] + +Accept has only one command that does everything mentioned in the above sections + +Announces the Issue to the mailing list +"X" stands for issue Refrence/No from taiga + ++ +---- +fedora-change-wrangler announce --ml "X" +---- + +Announces the Issue to the mailing list but with the reply header + +--reply if not mentioned has the reply option for all emails, +if set only the first email adress is set as reply to in the header + ++ +---- +fedora-change-wrangler announce --ml "X" --reply +---- + +The --config header as mentioned in the note above can also be used with all these. + ++ +---- +fedora-change-wrangler announce --ml "X" --reply --config +---- + diff --git a/Docs/modules/ROOT/pages/Auth/authenticate-bugzilla.adoc b/Docs/modules/ROOT/pages/Auth/authenticate-bugzilla.adoc new file mode 100644 index 0000000..b84deb0 --- /dev/null +++ b/Docs/modules/ROOT/pages/Auth/authenticate-bugzilla.adoc @@ -0,0 +1,11 @@ +ifdef::context[:parent-context: {context}] +:context: authentica-bugzilla + += Authenticate Bugzilla + +Bugzilla authentication is handled by the python-bugzilla module +It will ask for the user id and password from the user whenver a function that has the bugzilla functionality is used and saves the token fetched from it in a cookie. +For more information checkout the link_here[Developer-Documentation] + + + diff --git a/Docs/modules/ROOT/pages/Auth/authenticate-pagure.adoc b/Docs/modules/ROOT/pages/Auth/authenticate-pagure.adoc new file mode 100644 index 0000000..8796a1f --- /dev/null +++ b/Docs/modules/ROOT/pages/Auth/authenticate-pagure.adoc @@ -0,0 +1,32 @@ +ifdef::context[:parent-context: {context}] +:context: authenticate-pagure + += Authenticate Pagure + +Pagure requires using a token/key to acess the Rest api.The key is unique to each repository. +The auth command with the pagure flag and its subcommands sets the api token for the specfic repositories. + +include::config.note.adoc[] + +=== Set or Reset Taiga Credentials + +The API key is required for creating/delteting issues and other enabled functions on the repository.The token is stored securly in your system. + +For More information on the technical details of the storage kindly read the link_here[Developer Documentation] + +To set/reset the token : + ++ +---- +fedora-change-wrangler auth pagure --reset +---- + +=== Test if token is valid + +Using this command one may test the set api key/token.This command returns information of the user the repository tied to the api key. + ++ +---- +fedora-change-wrangler auth pagure --whoami +---- + diff --git a/Docs/modules/ROOT/pages/Auth/authenticate-taiga.adoc b/Docs/modules/ROOT/pages/Auth/authenticate-taiga.adoc new file mode 100644 index 0000000..31fa1f0 --- /dev/null +++ b/Docs/modules/ROOT/pages/Auth/authenticate-taiga.adoc @@ -0,0 +1,35 @@ +ifdef::context[:parent-context: {context}] +:context: authenticate-taiga + += Authenticate Taiga + +Taiga requires using a token/key to acess the Rest api. +The auth command with the --taiga flag and its sublags retrive the token or refresh it if expired. + +include::config.note.adoc[] + +=== Set or Reset Taiga Credentials + +The Credentials required for fetching the token are stored securly in your system.The users Taiga Username and Password would be required to +fetch the token. + +For More information on the technical details of the storage kindly read the link_here[Developer Documentation] + +To set/reset the token : + ++ +---- +fedora-change-wrangler auth taiga --reset +---- + +=== Refresh Expired Taiga Api Token + +Taiga's token expires every 60 days so it needs to be refreshed. + +To refresh the token: + ++ +---- +fedora-change-wrangler auth taiga --token +---- + diff --git a/Docs/modules/ROOT/pages/Config/Config-set.adoc b/Docs/modules/ROOT/pages/Config/Config-set.adoc new file mode 100644 index 0000000..49412e2 --- /dev/null +++ b/Docs/modules/ROOT/pages/Config/Config-set.adoc @@ -0,0 +1,47 @@ +ifdef::context[:parent-context: {context}] +:context: config-set + += Config + +The Tool has user defined settting available via the config.The config allows the user to have the tool work with thier own instances of Taiga,Pagure and Bugzilla. +It also allows the user to set the sender,reciver email id's for email funcitonality, + +=== User Defined Config Storage +The config can also be stored in a user defined location and the location can be passed as a argument to the tool in various commands. + ++ +---- +fedora-change-wrangler auth taiga --config /disk/folder/file.ini +---- + +=== Taiga Config +The config.ini file contains a [TAIGA] section which has all the taiga related configurations in it.The file holds the ID's using which taiga maps and identifies the userstories,statuses,custom attributes,epics etc. + +Without the ID's the tool would not function thus the user should fetch and set the custom attribtue id's as per the taiga instance they are using. +More information to fetch the ID'S can be found in https://taigaio.github.io/taiga-doc/dist/api.html[Taiga Documentation] + ++ +---- +[TAIGA] +TAIGA_URL = https://teams.fedoraproject.org +---- + +=== Pagure COnfig +The config.ini file contains the [PAGURE] section which has all the pagure related configurations in it.The section holds the service ID and the repository url's. + ++ +---- +[PAGURE] +FESCO_REPO = my repo name +RELEASE NOTES REPO = I give this a name +---- + +=== Bugzilla Config +The config.ini file contains the [PAGURE] section which has all the pagure related configurations in it.The section holds the service ID and the repository url's. + ++ +---- +[BUGZILLA] +BUGZILLA_URL = https://bugzilla.redhat.com +---- + diff --git a/Docs/modules/ROOT/pages/Config/config-note.adoc b/Docs/modules/ROOT/pages/Config/config-note.adoc new file mode 100644 index 0000000..32289f4 --- /dev/null +++ b/Docs/modules/ROOT/pages/Config/config-note.adoc @@ -0,0 +1,4 @@ +[NOTE] +==== +The --config is a optional command.If not passed it defaults to using the config.ini file from the the repo itself +==== diff --git a/Docs/modules/ROOT/pages/Convert/convert.adoc b/Docs/modules/ROOT/pages/Convert/convert.adoc new file mode 100644 index 0000000..e2d1a25 --- /dev/null +++ b/Docs/modules/ROOT/pages/Convert/convert.adoc @@ -0,0 +1,29 @@ +ifdef::context[:parent-context: {context}] +:context: convert + += Convert + +Note : The convert functionality is bundled in the accept functionality,indivisual conversion without the accept functionality is still possible. + +The convert command converts the issues in to Userstories on taiga. The user can spcify any no of issues to convert at once.The convert functionality not only creates the userstory but also maps all the custom attribtues of the issue to the user stoy. Once the issue is succcesuflly converted to the user story,the issue status is changed to close/processed. + +include::config.note.adoc[] + + +== Single Conversion + +Single Issue conversion example shown below,the "X" is the issue refrence no(the issue no that is seen in the gui) from taiga. + ++ +---- +fedora-change-wrangler convert --taiga "X" +---- + +== Bulk Conversion + +Bulk conversion example is shown below, the "X" is the issue refrence no(the issue no is seen in the gui). Multiple issues can thus be converted at once. + ++ +---- +fedora-change-wrangler convert --taiga 25 30 45 50 +---- diff --git a/Docs/modules/ROOT/pages/Developer Documentation/Bugzilla/Bugzilla-dev.adoc b/Docs/modules/ROOT/pages/Developer Documentation/Bugzilla/Bugzilla-dev.adoc new file mode 100644 index 0000000..01571d0 --- /dev/null +++ b/Docs/modules/ROOT/pages/Developer Documentation/Bugzilla/Bugzilla-dev.adoc @@ -0,0 +1,6 @@ +ifdef::context[:parent-context: {context}] +:context: bugzilla-dev.adoc + +The Current version of the Tool uses the https://github.com/python-bugzilla/python-bugzilla[Python-Bugzilla] to interact with bugzilla as there were too many issues with bugzillas rest api. + +One may find more information on the tool at the above link. diff --git a/Docs/modules/ROOT/pages/Developer Documentation/Config/config-dev.adoc b/Docs/modules/ROOT/pages/Developer Documentation/Config/config-dev.adoc new file mode 100644 index 0000000..38089b1 --- /dev/null +++ b/Docs/modules/ROOT/pages/Developer Documentation/Config/config-dev.adoc @@ -0,0 +1,6 @@ +ifdef::context[:parent-context: {context}] +:context: config-dev.adoc + +The config file is in a .ini format as it is human readable unlike json,yaml and similar ones. + +The config file can also be supplied from a user defined location usng the --config flag.The config contains all the required details mostly for taiga as the id's are important. diff --git a/Docs/modules/ROOT/pages/Developer Documentation/Mailing/mailing-list.adoc b/Docs/modules/ROOT/pages/Developer Documentation/Mailing/mailing-list.adoc new file mode 100644 index 0000000..b5c649c --- /dev/null +++ b/Docs/modules/ROOT/pages/Developer Documentation/Mailing/mailing-list.adoc @@ -0,0 +1,7 @@ +ifdef::context[:parent-context: {context}] +:context: mailing-list.adoc + +The Mailing functionality uses SMTP Multipart.The --reply flag if given in the cli sets the header to reply all to gain this we use a combination of lists and Multipart reply to header. + +Note: +By defualt wihtout the --reply flag the first id in the config.ini senders list is set in the reply to header and reply to all defaults to just that adress. diff --git a/Docs/modules/ROOT/pages/Developer Documentation/Pagure/pagure-dev.adoc b/Docs/modules/ROOT/pages/Developer Documentation/Pagure/pagure-dev.adoc new file mode 100644 index 0000000..5d99007 --- /dev/null +++ b/Docs/modules/ROOT/pages/Developer Documentation/Pagure/pagure-dev.adoc @@ -0,0 +1,11 @@ +ifdef::context[:parent-context: {context}] +:context: pagure-dev.adoc + +=== Auth +As mentioned in the user docs the api keys per repo are stored securly,they keyring module is used for the store of all the keys mapped by their repo name.Due to certain limitation only the fesco and the release docs keys are stored instead of per repo storage which was in a early commit of the tool. + +The authorization:token format is used and the tokens/api keys are passed in the header + +=== Calls & Token +All the calls are done via the rest api of pagure and use the requests module to call them. + diff --git a/Docs/modules/ROOT/pages/Developer Documentation/Taiga/taiga-dev.adoc b/Docs/modules/ROOT/pages/Developer Documentation/Taiga/taiga-dev.adoc new file mode 100644 index 0000000..666d14b --- /dev/null +++ b/Docs/modules/ROOT/pages/Developer Documentation/Taiga/taiga-dev.adoc @@ -0,0 +1,19 @@ +ifdef::context[:parent-context: {context}] +:context: taiga.adoc + +=== Auth +Taiga uses a token based auth each request to the api needs the token to be able to function.The token is fetching using the user id and password and then via https://taigaio.github.io/taiga-doc/dist/api.html#auth-normal-login[another call] the token is retrived and stored in the keyring. + +=== Conversion +Since there exists no endpoint for the direct conversion of the issue to user story,it has to be done manually. +1. Fetch the issue with its refrence id. +2. Fetch the Issues custom attributes using the issue id fetched from Step 1. +3. Post the User Story with the issue description retrived using Step 1 +4. Post the User Story Custom Attributes Fetched using Step 2. +5. Map the User Story as per the version custom attribute fetched from Step 2 to the respective Epic. +6. Changed the Issue Status to Closed. + +=== Config Mappings +Since taiga uses the ID format to recognize each function,custom attribute and issue the config file contains all the id's for the specifc status's,custom attributes etc + +Without these config mappings everything would have to be hardcoded which removes the functionality of having it point to user specific taiga instance. diff --git a/Docs/modules/ROOT/pages/Fesco/fesco.adoc b/Docs/modules/ROOT/pages/Fesco/fesco.adoc new file mode 100644 index 0000000..3c1d602 --- /dev/null +++ b/Docs/modules/ROOT/pages/Fesco/fesco.adoc @@ -0,0 +1,23 @@ +ifdef::context[:parent-context: {context}] +:context: fesco + += Fesco +The fesco command is used to create a issue with all the details of the proposed change and the link to the issue in taiga.The actual fesco repo can be pointed and changed via the config.ini file. + +include::config.note.adoc[] + +=== Create a issue +To create a issue the following command would be required below,the "X" is the issue refrence no(the issue no that is seen in the gui) from taiga. + ++ +---- +fedora-change-wrangler fesco --fesco "X" +---- + +=== Bulk Creation +To create issue in bulk ,below,the "X" is the issue refrence no(the issue no that is seen in the gui) from taiga. + ++ +--- +fedora-change-wrangler fesco --fesco 10 20 30 40 50 +--- diff --git a/Docs/modules/ROOT/pages/List/List-Userstories b/Docs/modules/ROOT/pages/List/List-Userstories new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Docs/modules/ROOT/pages/List/List-Userstories diff --git a/Docs/modules/ROOT/pages/List/list.adoc b/Docs/modules/ROOT/pages/List/list.adoc new file mode 100644 index 0000000..8eb9a6b --- /dev/null +++ b/Docs/modules/ROOT/pages/List/list.adoc @@ -0,0 +1,22 @@ +ifdef::context[:parent-context: {context}] +:context: list-userstories + += List +Listing is a functionality that allows the User to List out all the pending Usestories and Issues,It is configered to list all the Userstories and issues with the new status. + +List command prints out the output in the console itslef using ASCII formating and tables for good visuals. +The user would be able to see the version no,the subject and the issue no. + +=== List Issues + +To list Issue : ++ +---- +fedora-change-wrangeler list issue --pending +---- + +=== List UserStories : ++ +---- +fedora-change-wrangeler list Userstories -- pending +---- diff --git a/Docs/modules/ROOT/pages/Sync/sync-status.adoc b/Docs/modules/ROOT/pages/Sync/sync-status.adoc new file mode 100644 index 0000000..641eee9 --- /dev/null +++ b/Docs/modules/ROOT/pages/Sync/sync-status.adoc @@ -0,0 +1,17 @@ +ifdef::context[:parent-context: {context}] +:context: sync-status + += Sync +Sync-Status command would allow the user to sync the status of the bz to the status of taiga. It fetches the status from bugzilla and updates the appropriate one on the user story in taiga. +If the Bugzilla status is Modifies then the taiga user story status would be update to Testable +If the Bugzilla status is ON_QA then the Taiga user story status would update to Code_Complete + +The Sync command takes the fedora version as a argument which is linked to the epics for more on that you can refer to the link_here[Developer Documentation]. + +=== Sync-Status Bugzilla to Taiga + +To sync in the cli the following command has to be used with 32 being the fedora change version it is intended for : ++ +---- +fedora-change-wrangler sync-status 32 +---- diff --git a/Docs/preview.sh b/Docs/preview.sh new file mode 100644 index 0000000..effb9bd --- /dev/null +++ b/Docs/preview.sh @@ -0,0 +1,35 @@ + +#!/bin/sh + + +if [ "$(uname)" == "Darwin" ]; then + + # Running on macOS. + + # Let's assume that the user has the Docker CE installed + + # which doesn't require a root password. + + echo "The preview will be available at http://localhost:8080/" + + docker run --rm -v $(pwd):/antora:ro -v $(pwd)/nginx.conf:/etc/nginx/conf.d/default.conf:ro -p 8080:80 nginx + + + +elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then + + # Running on Linux. + + # Fedora Workstation has python3 installed as a default, so using that + + echo "" + + echo "The preview is available at http://localhost:8080" + + echo "" + + cd ./public + + python3 -m http.server 8080 + +fi \ No newline at end of file diff --git a/Docs/site.yml b/Docs/site.yml new file mode 100644 index 0000000..483da12 --- /dev/null +++ b/Docs/site.yml @@ -0,0 +1,40 @@ + +site: + + title: Fedora Change Wrangler Usage Guide + + start_page: fedora-change-wrangler::index + +content: + + sources: + + - url: . + + branches: HEAD + +ui: + + bundle: + + url: https://asamalik.fedorapeople.org/ui-bundle.zip + + snapshot: true + + default_layout: with_menu + +output: + + clean: true + + dir: ./public + + destinations: + + - provider: archive + +runtime: + + pull: true + + cache_dir: ./cache \ No newline at end of file From 267a7c740550d328afbf4da41ddc921f24d85bdb Mon Sep 17 00:00:00 2001 From: pac23 Date: Jul 06 2019 05:36:50 +0000 Subject: [PATCH 54/71] Change from Beautiful Table to PrettyTable with reference #49 --- diff --git a/tga/issues.py b/tga/issues.py index e29d676..078e10c 100644 --- a/tga/issues.py +++ b/tga/issues.py @@ -3,7 +3,7 @@ import configparser import keyring import requests -from beautifultable import BeautifulTable +from prettytable import PrettyTable """ config = configparser.ConfigParser() @@ -49,8 +49,8 @@ def list_issue(args): headers=headers ) if r.status_code == 200: - table = BeautifulTable() - table.column_headers = ["refrence no", "subject", "fedora-version"] + table = PrettyTable() + table.field_names = ["refrence no", "subject", "fedora-version"] data = json.loads(r.content) for item in data: print(item) @@ -71,7 +71,7 @@ def list_issue(args): print(item) owner = item['username'] """ - table.append_row([issueref, subject, version]) + table.add_row([issueref, subject, version]) print(table) else: print("Unable to fetch list check logs") diff --git a/tga/userstory.py b/tga/userstory.py index 4660fa2..906ac05 100644 --- a/tga/userstory.py +++ b/tga/userstory.py @@ -3,6 +3,8 @@ import json import keyring import requests +from prettytable import PrettyTable + config = configparser.ConfigParser() config.read('config.ini') @@ -48,8 +50,8 @@ def list_us(args): ) if r.status_code == 200: print(r.status_code) - table = BeautifulTable() - table.column_headers = ["refrence no", "subject", "fedora-version", "owner"] + table = PrettyTable() + table.field_names = ["refrence no", "subject", "fedora-version"] data = json.loads(r.content) for item in data: subject = item['subject'] @@ -58,9 +60,15 @@ def list_us(args): version = item['epics'] duedate = item['due_date'] tags = ['tags'] + r = caget_us(USERSTORY_id, config) + if r.status_code == 200: + cadata = json.loads(r.content) + version = cadata['attributes_values'][config['TAIGA']['US']] + """ for item in data['owner_extra_info']: owner = item['username'] - table.append_row([USERSTORY_ref, subject, version, owner]) + """ + table.add_row([USERSTORY_ref, subject, version]) #print(USERSTORY_id, USERSTORY_ref owner) print(table) else: From a12900c011e7083bbe0b46a56019855351b0dbac Mon Sep 17 00:00:00 2001 From: pac23 Date: Jul 09 2019 12:21:10 +0000 Subject: [PATCH 55/71] issue to user story and user story to issue working,in issue userstory link live in comments --- diff --git a/accept.py b/accept.py index a7ab0b0..62f8597 100644 --- a/accept.py +++ b/accept.py @@ -106,7 +106,7 @@ def accept(args): service_id = config['TAIGA']['SERVICE_ID'] # service id service_token = config['TAIGA']['SERVICE_TOKEN'] project_id = config['TAIGA']['PROJECT_ID'] - value = args.accept + value = args.issue for x in value: # iteratingover name space object try: print(x) diff --git a/bz/bugs.py b/bz/bugs.py index c363d66..1345cf4 100644 --- a/bz/bugs.py +++ b/bz/bugs.py @@ -12,7 +12,7 @@ def post_bug(createinfo, bzapi, config): config = configparser.ConfigParser() config.read(configpath) """ - #url = str(config['BUGZILLA']['BUGZILLA_URL']) + "/rest/bug" + url = str(config['BUGZILLA']['BUGZILLA_URL']) + "/rest/bug" """ headers = { 'Content-Type': 'application/json', @@ -24,7 +24,7 @@ def post_bug(createinfo, bzapi, config): """ #print(headers) if not bzapi.logged_in: - print("This example requires cached login credentials for %s" % URL) + print("This example requires cached login credentials for %s" % url) bzapi.interactive_login() print(createinfo) newbug = bzapi.createbug(createinfo) diff --git a/bz/pgba.py b/bz/pgba.py index 2a9ba22..7db09a8 100644 --- a/bz/pgba.py +++ b/bz/pgba.py @@ -22,7 +22,8 @@ def pgtobz(value, userstoryid, configpath): bzapi = bugzilla.Bugzilla(URL) for x in value: # iteratingover name space object try: - r = tgaissue.get_issue(x, config) # x is user story refrence id + issueurl, r = tgaissue.get_issue(x, config) # x is user story refrence id + print(r) if r.status_code == 200: data = json.loads(r.content) print(data, "this is user story data") diff --git a/config.ini b/config.ini index 7a1192d..a7f21b2 100644 --- a/config.ini +++ b/config.ini @@ -5,6 +5,9 @@ PROJECT_ID = 325667 TAIGA_URL = https://api.taiga.io TAIGA_SITE_ISSUE_URL = https://tree.taiga.io/project/pac_23-test-changes-tracker-kanban/issue/ +PROJECT_WEB_URL = https://tree.taiga.io/project/ +PROJECT_WEB_NAME = pac_23-test-changes-tracker-kanban + ISSUE_STATUS_NEW = 2283176 ISSUE_STATUS_NEEDS_INFO = 2283180 ISSSUE_STATUS_ACCEPTED = 2302390 @@ -34,6 +37,7 @@ ISSUE_CA_MASS_REBUILD = 11377 ISSUE_CA_POLICY_CHANGE = 11378 ISSUE_CA_MODIFIES_DELIVERABLES = 11379 ISSUE_CA_VERSION = 11383 +ISSUE_CA_USERSTORY_LINK = 11431 USERSTORY_CA_SYSTEM_WIDE_CHANGE = 21923 USERSTORY_CA_SUMMARY = 21924 USERSTORY_CA_BUGZILLA_CONTACT = 21925 @@ -47,6 +51,7 @@ USERSTORY_CA_CONTINGENCY = 21932 USERSTORY_CA_MASS_REBUILD = 21933 USERSTORY_CA_POLICY_CHANGE = 21934 USERSTORY_CA_MODIFIES_DELIVERABLES = 21935 +USERSTORY_CA_ISSUE_LINK = 22140 [PAGURE] diff --git a/tga/convert.py b/tga/convert.py index 87fd569..76dbed4 100644 --- a/tga/convert.py +++ b/tga/convert.py @@ -40,14 +40,17 @@ def convert(value, configpath): for x in value: try: print(x,"this is x") - r = tgaissue.get_issue(x, config) # gets the issue + issueurl, r = tgaissue.get_issue(x, config) # gets the issue if r.status_code == 200: data = json.loads(r.content) print(data, "this is issue data") details = data['description'] subject = data['subject'] issue_id = data['id'] - issue_version = data['version'] # fetch the id as well + issue_ref = data['ref'] + issue_version = data['version'] + print(issue_version, "this is issue version") + print("this is issue version") # fetch the id as well #print(issue_id) print("Step 1") """ @@ -71,12 +74,13 @@ def convert(value, configpath): r = tgaissue.caget_issue(issue_id, config) if r.status_code == 200: data = json.loads(r.content) + print(r.content) print(data, "step 2") #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'][config['TAIGA']['ISSUE_CA_SUMMARY']]# ['11372'] - bugzilla_id = data['attributes_values'][config['TAIGA']['ISSUE_CA_BUGZILLA_CONTACT']]# ['11373'] - approval_required = data['attributes_values'][config['TAIGA']['ISSUE_CA_TRADEMARK_APPROVAL']]#['11374'] + summary = data['attributes_values'][config['TAIGA']['ISSUE_CA_SUMMARY']] # ['11372'] + bugzilla_id = data['attributes_values'][config['TAIGA']['ISSUE_CA_BUGZILLA_CONTACT']] # ['11373'] + approval_required = data['attributes_values'][config['TAIGA']['ISSUE_CA_TRADEMARK_APPROVAL']] #['11374'] owners = data['attributes_values'][config['TAIGA']['ISSUE_CA_OWNERS']]#['11375'] contingency_deadline = data['attributes_values'][config['TAIGA']['ISSUE_CA_CONTINGENCY']]#['11376'] mass_rebuild = data['attributes_values'][config['TAIGA']['ISSUE_CA_MASS_REBUILD']]#['11377'] @@ -119,8 +123,10 @@ def convert(value, configpath): print("step 3") data = json.loads(r.content) userstoryid = data['id'] - usestory_version = data['version'] + userstoryref = data['ref'] + userstory_version = data['version'] print(id) + issueurl = str(config['TAIGA']['PROJECT_WEB_URL']) + str(config['TAIGA']['PROJECT_WEB_NAME']) +'/issue/'+ str(issue_ref) payload = { "attributes_values": { config['TAIGA']['USERSTORY_CA_SYSTEM_WIDE_CHANGE']: system_wide_change, @@ -135,9 +141,10 @@ def convert(value, configpath): config['TAIGA']['USERSTORY_CA_CONTINGENCY']: contingency_deadline, config['TAIGA']['USERSTORY_CA_MASS_REBUILD']: mass_rebuild, config['TAIGA']['USERSTORY_CA_POLICY_CHANGE']: policy_change, - config['TAIGA']['USERSTORY_CA_MODIFIES_DELIVERABLES']: modifies_deliverables + config['TAIGA']['USERSTORY_CA_MODIFIES_DELIVERABLES']: modifies_deliverables, + config['TAIGA']['USERSTORY_CA_ISSUE_LINK']: issueurl }, - "version": usestory_version + "version": userstory_version } print(payload) r = tgauserstory.post_usca(payload, userstoryid, config) @@ -156,41 +163,60 @@ def convert(value, configpath): break r = tgaepic.post_relatedus(userstoryid, epicid, epicref, config) + print(r.content, r.status_code) if r.status_code == 201: data = json.loads(r.content) - usestory_version = data['version'] print("Sucessfully mapped epics") payload = { 'status': config['TAIGA']['USERSTORY_STATUS_ACCEPTED'], - 'version': usestory_version + 'version': userstory_version } r = tgauserstory.changestatus_userstory(userstoryid, payload, config) - if r.status_code == 201: - print("Sucessfully converted issue to user story") + print(r.content,r.status_code) + if r.status_code == 200: + userstoryurl = str(config['TAIGA']['PROJECT_WEB_URL']) + str(config['TAIGA']['PROJECT_WEB_NAME']) +'/us/'+ str(userstoryref) + issue_version = issue_version # + 1 + print(type(issue_version)) + print(issue_version) payload = { - 'status': config['TAIGA']['ISSUE_STATUS_PROCESSED'], - 'version': issue_version - } - r = tgaissue.changestatus_issue(issue_id, payload, config) - print(r.status_code) - print(r.content) - #print(json.loads(r.content)) - if r.status_code == 201: - print("Sucessfully closed issue") - return userstoryid, True + 'version': issue_version, + "comment": userstoryurl + } + r = tgaissue.edit_issue(payload, issue_id, config) + if r.status_code == 200: + data = json.loads(r.content) + issue_version = data['version'] + print("Sucessfully converted issue to user story") + issue_version = issue_version #+1 + payload = { + 'status': config['TAIGA']['ISSUE_STATUS_PROCESSED'], + 'version': issue_version + } + r = tgaissue.changestatus_issue(issue_id, payload, config) + print(r.status_code) + print(r.content) + if r.status_code == 200: + print("Sucessfully closed issue") + return userstoryid, True + else: + print("Unsuccesful at closing issue,check logs") else: - print("Unsuccesful at closing issue,check logs") + print("Unable to map Issue url to user story attributes") else: print("Converted User story,copied attributes mapped epics,faliure to change status to accepted") else: print("Unnsucessful to map to epics,change user story status to accepted and issue status to processed") except requests.exceptions.RequestException as e: print(e) + except Exception as e: + print(e) else: print("Unsuccesful Conversion") else: print("Unsuccesful conversion") except requests.exceptions.RequestException as e: + print(e) + except Exception as e: print(e) else: print("Unsuccesful Conversion") diff --git a/tga/epics.py b/tga/epics.py index 2cd266c..69a0a9b 100644 --- a/tga/epics.py +++ b/tga/epics.py @@ -75,6 +75,8 @@ def post_relatedus(USERSTORY_id, epicid, epicref, config): return r except requests.exceptions.RequestException as e: print(e) + except Exception as e: + print(e) def listrelepic_userstory(epicid, config): #url = str(config['TAIGA']['TAIGA_URL']) + "/api/v1/userstories?project=" + str(config['TAIGA']['PROJECT_ID']) + "&epic=" + epicid diff --git a/tga/issues.py b/tga/issues.py index 078e10c..1ff6f6f 100644 --- a/tga/issues.py +++ b/tga/issues.py @@ -102,10 +102,11 @@ def get_issue(x, config): url, headers=headers ) - return r + return url, r except requests.exceptions.RequestException as e: print(e) - + except Exception as e: + print(e) def caget_issue(x, config): """ @@ -130,6 +131,8 @@ def caget_issue(x, config): return r except requests.exceptions.RequestException as e: print(e) + except Exception as e: + print(e) def changestatus_issue(x, payload, config): @@ -158,3 +161,27 @@ def changestatus_issue(x, payload, config): return r except requests.exceptions.RequestException as e: print(e) + except Exception as e: + print(e) + +def edit_issue(x, id, config): + #url = str(config['TAIGA']['TAIGA_URL']) + "/api/v1/issues?project=" + config['TAIGA']['PROJECT_ID'] + "&status=" + str(config['TAIGA']['ISSUE_STATUS_NEW']) + try: + url = 'https://api.taiga.io/api/v1/issues/' + str(id) + headers = { + 'Content-Type': 'application/json', + 'Authorization': 'Bearer {0}'.format(keyring.get_password(config['TAIGA']['SERVICE_TOKEN'], "taiga_token")) + # 'Authorization': 'Bearer {0}'.format(str(123)) + } + r = requests.patch( + url, + #'https://api.taiga.io/api/v1/userstories/custom-attributes-values/' + str(id), + data=json.dumps(x), + headers=headers + ) + print(json.loads(r.content)) + return r + except requests.exceptions.RequestException as e: + print(e) + except Exception as e: + print(e) \ No newline at end of file diff --git a/tga/taiga_auth.py b/tga/taiga_auth.py index 83263f9..3716499 100644 --- a/tga/taiga_auth.py +++ b/tga/taiga_auth.py @@ -76,6 +76,8 @@ def refresh_token(args): print("auth error") except requests.exceptions.RequestException as e: print(e) + except Exception as e: + print(e) def reset(args): @@ -106,4 +108,6 @@ def reset(args): print("Password reset succesfully") except (keyring.errors.PasswordSetError, Exception) as e: print("Failed to reset password") + except Exception as e: + print(e) diff --git a/tga/userstory.py b/tga/userstory.py index 906ac05..e3cdb64 100644 --- a/tga/userstory.py +++ b/tga/userstory.py @@ -145,6 +145,8 @@ def post_us(x, config): return r except requests.exceptions.RequestException as e: print(e) + except Exception as e: + print(e) def post_usca(x, id, config): @@ -152,14 +154,21 @@ def post_usca(x, id, config): """ config = configparser.ConfigParser() config.read(configpath) + + if url == True: + + else: + url = url """ + url = 'https://api.taiga.io/api/v1/userstories/custom-attributes-values/' + str(id) headers = { 'Content-Type': 'application/json', 'Authorization': 'Bearer {0}'.format(keyring.get_password(config['TAIGA']['SERVICE_TOKEN'], "taiga_token")) # 'Authorization': 'Bearer {0}'.format(str(123)) } r = requests.patch( - 'https://api.taiga.io/api/v1/userstories/custom-attributes-values/' + str(id), + url, + #'https://api.taiga.io/api/v1/userstories/custom-attributes-values/' + str(id), data=json.dumps(x), headers=headers ) @@ -167,6 +176,8 @@ def post_usca(x, id, config): return r except requests.exceptions.RequestException as e: print(e) + except Exception as e: + print(e) def changestatus_userstory(x, payload, config): @@ -196,6 +207,8 @@ def changestatus_userstory(x, payload, config): return r except requests.exceptions.RequestException as e: print(e) + except Exception as e: + print(e) def listrelepic_userstory(epicid, config): From 1a331ab673f2d7b3457b56fbd82511186938fbf0 Mon Sep 17 00:00:00 2001 From: pac23 Date: Jul 09 2019 12:21:49 +0000 Subject: [PATCH 56/71] --accept renamed to --issue --- diff --git a/main.py b/main.py index bf29c6d..3b2f2d0 100644 --- a/main.py +++ b/main.py @@ -212,7 +212,7 @@ class Change_Tool(object): def accept(self): parser = argparse.ArgumentParser( description='announces to mailing list') - parser.add_argument('--accept', + parser.add_argument('--issue', nargs='+', type=int, help='Announces to Mailing list') From 1a0488d1235bb642ccdf631080707f5c63def129 Mon Sep 17 00:00:00 2001 From: pac23 Date: Jul 11 2019 11:38:38 +0000 Subject: [PATCH 57/71] add more help in main.py --- diff --git a/main.py b/main.py index 3b2f2d0..e3aa9f5 100644 --- a/main.py +++ b/main.py @@ -22,9 +22,19 @@ class Change_Tool(object): def __init__(self): parser = argparse.ArgumentParser( description='Cli for Change Tool', - usage='''change-tool []''' - ) - parser.add_argument('command', help='Subcommand to run') + usage='''fedora-change-wrangler [] + +The commands are: + auth Authenticates with Bugzilla,Taiga and Pagure + convert Converts the Taiga issues to user stories + list Lists the Pending issues/userstory as per the optinal argument + announce Announces to the mailing list of the approved change + fesco Creates issues on the fesco repo with details from the approved change proposal + accept Accepts the Change Proposal by Converting issue to user story and creates a tracking bug in Bugzilla + sync Syncs the tracking bug status with Taiga status + --help Lists out the subcommand in each subcommand of the cli +''') + parser.add_argument('command', help='Subcommand --flags') # parse_args defaults to [1:] for args, but you need to # exclude the rest of the args too, or validation will fail args = parser.parse_args(sys.argv[1:2]) @@ -76,11 +86,13 @@ class Change_Tool(object): taiga_auth.reset(args) else: print("Wrong command") + print(parser.print_help()) elif args.command == 'pagure': if args.reset: pagure_auth.reset(args) else: print("Wrong command") + print(parser.print_help()) elif args.command == 'bugzilla': if args.token: bugzilla_auth.refresh_token(args) @@ -88,13 +100,16 @@ class Change_Tool(object): bugzilla_auth.reset(args) else: print("Wrong command,please check documentation for the proper command") + print(parser.print_help()) elif args.command == 'email': if args.reset: mailauth.reset(args) else: print("Wrong Command check documentation") + print(parser.print_help()) else: print("Please Check the Documentation for the proper command or press --h for help") + print(parser.print_help()) # print("Running the auth instance.....") # authenticate() @@ -125,7 +140,13 @@ class Change_Tool(object): configpath = args.config print(configpath) # Debug only print(args) # debug only - convert.convert(args.taiga, args.config) + if args.command == 'taiga': + convert.convert(args.taiga, args.config) + elif args.command == 'help': + print(parser.print_help()) + else: + print("Wrong Command") + print(parser.print_help()) def list(self): parser = argparse.ArgumentParser( @@ -215,13 +236,14 @@ class Change_Tool(object): parser.add_argument('--issue', nargs='+', type=int, - help='Announces to Mailing list') + #description='Issue No', + help='Accepts the taiga change propsal issue') parser.add_argument('--config', #dest='configpath', #action='store', #type=string, default='config.ini', - help='Sets config path') + help='Sets User Defined Config path') args = parser.parse_args(sys.argv[2:]) #configpath = args.config #print(configpath) @@ -231,13 +253,15 @@ class Change_Tool(object): #accept.accept(args.accept, args.config) accept.accept(args) - def sync(self): + def update(self): parser = argparse.ArgumentParser( description='Syncing Between Bugzilla and Taiga') - parser.add_argument('--sync_status', + + parser.add_argument('--update', nargs='+', type=int, help='Syncing between bugzilla and taiga') + parser.add_argument('--config', #dest='configpath', #action='store', @@ -245,7 +269,7 @@ class Change_Tool(object): default='config.ini', help='Sets config path') args = parser.parse_args(sys.argv[2:]) - sync.sync(args) + update.sync(args) """ def config(self): From c89f19d937627ec411225ee01d0d04a63a510e4d Mon Sep 17 00:00:00 2001 From: pac23 Date: Jul 19 2019 11:53:20 +0000 Subject: [PATCH 58/71] working first draft of report automated generation --- diff --git a/main.py b/main.py index e3aa9f5..c81fb5c 100644 --- a/main.py +++ b/main.py @@ -5,7 +5,7 @@ import json import argparse import sys import accept -import sync +import update from tga import taiga_auth from pgure import pagure_auth @@ -257,7 +257,7 @@ The commands are: parser = argparse.ArgumentParser( description='Syncing Between Bugzilla and Taiga') - parser.add_argument('--update', + parser.add_argument('--release', nargs='+', type=int, help='Syncing between bugzilla and taiga') @@ -269,7 +269,8 @@ The commands are: default='config.ini', help='Sets config path') args = parser.parse_args(sys.argv[2:]) - update.sync(args) + #update.sync(args) + update.update(args) """ def config(self): diff --git a/sync.py b/sync.py deleted file mode 100644 index cdf2677..0000000 --- a/sync.py +++ /dev/null @@ -1,110 +0,0 @@ -import requests -import json -import keyring -import os -import configparser -import editor -import bugzilla - -from tga import epics as tgaepic -from tga import issues as tgaissue -from tga import userstory as tgauserstory -from pgure import issues as pgaissues -from bz import bugs as bzbugs -from urllib.parse import urlparse - -def sync(args): - # fvid is fedora version - configpath = args.config - config = configparser.ConfigParser() - config.read(configpath) - fvid = args.sync_status - bzapi = bugzilla.Bugzilla(config['BUGZILLA']['BUGZILLA_URL']) - for x in fvid: - #config.read('config.ini') - - """ - bzapi = bzapi = bugzilla.Bugzilla(URL) - query = bzapi.build_query( - component="Changes Tracking", - status="NEW", - include_fields=["description"]) - #query["status"] = "NEW" - bugs = bzapi.query(query) - print(bugs) - """ - print(x) - try: - r = tgaepic.list_epic(config) - if r.status_code == 200: - data = json.loads(r.content) - #print(data) - for i in data: - print(i['subject']) - if int(i['subject']) == x: - epicid = i['id'] - epicref = i['ref'] - break - - #url = str(config['TAIGA']['TAIGA_URL']) + "/api/v1/issues/userstories? - r = tgaepic.listrelepic_userstory(epicid, config) - if r.status_code == 200: - data = json.loads(r.content) - for i in data: - userstoryid = i['user_story'] - print(userstoryid) - try: - r = tgauserstory.get_us(userstoryid, config) - if r.status_code == 200: - userstorydata = json.loads(r.content) - userstory_version = userstorydata['version'] - userstoryref = userstorydata['ref'] - r = tgauserstory.caget_us(userstoryid, config) - userstorycadata = json.loads(r.content) - bztracker = userstorycadata['attributes_values'][config['TAIGA']['USERSTORY_CA_BUGZILLA_TRACKER']] - bugid = urlparse(bztracker).query.lstrip("id=") - print(bugid) - bug = bzbugs.get_bug(bugid, bzapi, config) - if bug.status == 'MODIFIED': - statusid = config['TAIGA']['USERSTORY_STATUS_TESTABLE'] - elif bug.status == 'ON_QA': - statusid = config['TAIGA']['USERSTORY_STATUS_CODE_COMPLETE'] - #elif bug.status == 'VERIFIED': - #elif bug.status == 'RELEASE_PENDING': - elif bug.status == 'CLOSED': - statusid = config['TAIGA']['USERSTORY_STATUS_ARCHIVED'] - else: - print("failed to fetch bug status") - payload = { - 'status': statusid, - 'version': userstory_version - } - try: - r = tgauserstory.changestatus_userstory(userstoryid, payload, config) - if r.status_code == 200: - print("Sucesfully Synced status from Bugzilla Bug {} to Taiga Userstory {}".format(bug.id, userstoryref)) - else: - print("Check logs for errors,Unable to Sync",r.content, r.status_code) - except requests.exceptions.RequestException as e: - print(e) - except Exception as e: - print(e) - else: - print("Error in fetching user story") - except requests.exceptions.RequestException as e: - print(e) - except Exception as e: - print(e) - else: - print("Unable to fetch epic related user stories,check logs for errors") - else: - print("Unable to Sync Check logs", r.content) - except requests.exceptions.RequestException as e: - print(e) - except Exception as e: - print(e) - -""" -if __name__ == "__main__": - sync() -""" \ No newline at end of file diff --git a/test.html b/test.html new file mode 100644 index 0000000..894f6cc --- /dev/null +++ b/test.html @@ -0,0 +1,700 @@ + + + + Releases//changeset + + + + + + + Fedora People - fedorapeople.org + + + + + +
+ + +
+
+
+ +

Fedora F 32 changeset


+ +

Accepted fedora 32 System Wide Change Proposals

+ + + + +

Test issue for convert to user story test

+

+

Owners

+
  • owners : +
  • +
  • Release Notes owner:
  • +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +

test listing issues dummmy

+

test test test test test

+

Owners

+
  • owners : +
  • +
  • Release Notes owner:
  • +
+
+ + + +

Overwrite test issue

+

test issue

+

Owners

+
  • owners : +
  • +
  • Release Notes owner:
  • +
+
+ + + +

Test of overwrite

+

test of issue and test of issue

+

Owners

+
  • owners : +
  • +
  • Release Notes owner:
  • +
+
+ + + +

OW test

+

new test

+

Owners

+
  • owners : +
  • +
  • Release Notes owner:
  • +
+
+ + + +

OW test

+

test

+

Owners

+
  • owners : +
  • +
  • Release Notes owner:
  • +
+
+ + + +

OW test

+

test

+

Owners

+
  • owners : +
  • +
  • Release Notes owner:
  • +
+
+ + + +

test issue for versions

+

+

Owners

+
  • owners : +
  • +
  • Release Notes owner:
  • +
+
+ + + +

Test Issue for link feed

+

Time:16:15 +Location : Somewhere in Mumbai,India +Objective: Test and Deploy Links +Final Objective: Complete Conversion in Tool +Test: Yes

+

Owners

+
  • owners : +
  • +
  • Release Notes owner:
  • +
+
+ + + +

Test Issue for link feed

+

Time:16:15 +Location : Somewhere in Mumbai,India +Objective: Test and Deploy Links +Final Objective: Complete Conversion in Tool +Test: Yes

+

Owners

+
  • owners : +
  • +
  • Release Notes owner:
  • +
+
+ + + +

Test Issue for link feed

+

Time:16:15 +Location : Somewhere in Mumbai,India +Objective: Test and Deploy Links +Final Objective: Complete Conversion in Tool +Test: Yes

+

Owners

+
  • owners : +
  • +
  • Release Notes owner:
  • +
+
+ + + +

Test Issue for link feed

+

Time:16:15 +Location : Somewhere in Mumbai,India +Objective: Test and Deploy Links +Final Objective: Complete Conversion in Tool +Test: Yes

+

Owners

+
  • owners : +
  • +
  • Release Notes owner:
  • +
+
+ + + +

Test Issue for link feed

+

Time:16:15 +Location : Somewhere in Mumbai,India +Objective: Test and Deploy Links +Final Objective: Complete Conversion in Tool +Test: Yes

+

Owners

+
  • owners : +
  • +
  • Release Notes owner:
  • +
+
+ + + +

Test Issue for link feed

+

Time:16:15 +Location : Somewhere in Mumbai,India +Objective: Test and Deploy Links +Final Objective: Complete Conversion in Tool +Test: Yes

+

Owners

+
  • owners : +
  • +
  • Release Notes owner:
  • +
+
+ + + +

Test Issue for link feed

+

Time:16:15 +Location : Somewhere in Mumbai,India +Objective: Test and Deploy Links +Final Objective: Complete Conversion in Tool +Test: Yes

+

Owners

+
  • owners : +
  • +
  • Release Notes owner:
  • +
+
+ + + +

Test Issue for link feed

+

Time:16:15 +Location : Somewhere in Mumbai,India +Objective: Test and Deploy Links +Final Objective: Complete Conversion in Tool +Test: Yes

+

Owners

+
  • owners : +
  • +
  • Release Notes owner:
  • +
+
+ + + +

Test Issue for link feed

+

Time:16:15 +Location : Somewhere in Mumbai,India +Objective: Test and Deploy Links +Final Objective: Complete Conversion in Tool +Test: Yes

+

Owners

+
  • owners : +
  • +
  • Release Notes owner:
  • +
+
+ + + +

Accepted Fedora F 32 Self Containted Change Proposals

+ + +

+ Test issue for convert to user story test +

+

+ The quick brown fox jumped over the lazy dog +

+

Owners

+
  • + Owner: +
  • +
  • + Release notes owner : +
+ + + + + + +

+ Test issue for convert to user story test +

+

+ The quick brown fox jumped over the lazy dog +

+

Owners

+
  • + Owner: +
  • +
  • + Release notes owner : +
+ + + + +

+ Test issue for convert to user story test +

+

+ The quick brown fox jumped over the lazy dog +

+

Owners

+
  • + Owner: +
  • +
  • + Release notes owner : +
+ + + + +

+ Test issue for convert to user story test +

+

+ The quick brown fox jumped over the lazy dog +

+

Owners

+
  • + Owner: +
  • +
  • + Release notes owner : +
+ + + + +

+ Test issue for convert to user story test +

+

+ The quick brown fox jumped over the lazy dog +

+

Owners

+
  • + Owner: +
  • +
  • + Release notes owner : +
+ + + + +

+ Test issue for convert to user story test +

+

+ The quick brown fox jumped over the lazy dog +

+

Owners

+
  • + Owner: +
  • +
  • + Release notes owner : +
+ + + + +

+ Test issue for convert to user story test +

+

+ The quick brown fox jumped over the lazy dog +

+

Owners

+
  • + Owner: +
  • +
  • + Release notes owner : +
+ + + + +

+ Test issue for convert to user story test +

+

+ The quick brown fox jumped over the lazy dog +

+

Owners

+
  • + Owner: +
  • +
  • + Release notes owner : +
+ + + + +

+ Test issue for convert to user story test +

+

+ The quick brown fox jumped over the lazy dog +

+

Owners

+
  • + Owner: +
  • +
  • + Release notes owner : +
+ + + + +

+ Test issue for convert to user story test +

+

+ The quick brown fox jumped over the lazy dog +

+

Owners

+
  • + Owner: +
  • +
  • + Release notes owner : +
+ + + + +

+ Test issue for convert to user story test +

+

+ The quick brown fox jumped over the lazy dog +

+

Owners

+
  • + Owner: +
  • +
  • + Release notes owner : +
+ + + + +

+ Test issue for convert to user story test +

+

+ The quick brown fox jumped over the lazy dog +

+

Owners

+
  • + Owner: +
  • +
  • + Release notes owner : +
+ + + + +

+ Test issue for convert to user story test +

+

+ The quick brown fox jumped over the lazy dog +

+

Owners

+
  • + Owner: +
  • +
  • + Release notes owner : +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tplate.html b/tplate.html new file mode 100644 index 0000000..958d13b --- /dev/null +++ b/tplate.html @@ -0,0 +1,84 @@ + + + + Releases/{{ fedora_version }}/changeset + + + + + + + Fedora People - fedorapeople.org + + + + + +
+ + +
+
+
+ +

Fedora F {{ fedoraversion }} changeset


+ +

Accepted fedora {{ fedoraversion }} System Wide Change Proposals

+{% for n in changes %} + {% if n['type'] is sameas true %} +

{{ n['title'] }}

+

{{ n['summary'] }}

+

Owners

+
  • owners : {{ n['owners'] }} +
  • +
  • Release Notes owner:
  • +
+
+ {% endif %} +{% endfor %} + +

Accepted Fedora F {{ fedoraversion }} Self Containted Change Proposals

+{% for n in changes %} + {% if n['type'] is sameas false %} +

+ {{ n['title'] }} +

+

+ {{ n['summary'] }} +

+

Owners

+
  • + Owner: {{ n['owners'] }} +
  • +
  • + Release notes owner : {{ n['release_owners'] }} +
+ + {% endif %} +{% endfor %} + + \ No newline at end of file diff --git a/update.py b/update.py new file mode 100644 index 0000000..29b48d0 --- /dev/null +++ b/update.py @@ -0,0 +1,265 @@ +import requests +import json +import keyring +import os +import configparser +import editor +import bugzilla +import lxml.html +import os +import re +import string +import random +import jinja2 +import sys +#sys.setdefaultencoding("utf-8") + +from tga import epics as tgaepic +from tga import issues as tgaissue +from tga import userstory as tgauserstory +from pgure import issues as pgaissues +from bz import bugs as bzbugs +from urllib.parse import urlparse +from collections import OrderedDict + +def sync(x, config): + # fvid is fedora version + configpath = args.config + config = configparser.ConfigParser() + config.read(configpath) + #fvid = args.sync_status + bzapi = bugzilla.Bugzilla(config['BUGZILLA']['BUGZILLA_URL']) + #for x in fvid: + #config.read('config.ini') + + """ + bzapi = bzapi = bugzilla.Bugzilla(URL) + query = bzapi.build_query( + component="Changes Tracking", + status="NEW", + include_fields=["description"]) + #query["status"] = "NEW" + bugs = bzapi.query(query) + print(bugs) + """ + print(x) + try: + r = tgaepic.list_epic(config) + if r.status_code == 200: + data = json.loads(r.content) + #print(data) + for i in data: + print(i['subject']) + if int(i['subject']) == x: + epicid = i['id'] + epicref = i['ref'] + break + + #url = str(config['TAIGA']['TAIGA_URL']) + "/api/v1/issues/userstories? + r = tgaepic.listrelepic_userstory(epicid, config) + if r.status_code == 200: + data = json.loads(r.content) + for i in data: + userstoryid = i['user_story'] + print(userstoryid) + try: + r = tgauserstory.get_us(userstoryid, config) + if r.status_code == 200: + userstorydata = json.loads(r.content) + userstory_version = userstorydata['version'] + userstoryref = userstorydata['ref'] + r = tgauserstory.caget_us(userstoryid, config) + userstorycadata = json.loads(r.content) + bztracker = userstorycadata['attributes_values'][config['TAIGA']['USERSTORY_CA_BUGZILLA_TRACKER']] + bugid = urlparse(bztracker).query.lstrip("id=") + print(bugid) + bug = bzbugs.get_bug(bugid, bzapi, config) + if bug.status == 'MODIFIED': + statusid = config['TAIGA']['USERSTORY_STATUS_TESTABLE'] + elif bug.status == 'ON_QA': + statusid = config['TAIGA']['USERSTORY_STATUS_CODE_COMPLETE'] + #elif bug.status == 'VERIFIED': + #elif bug.status == 'RELEASE_PENDING': + elif bug.status == 'CLOSED': + statusid = config['TAIGA']['USERSTORY_STATUS_ARCHIVED'] + else: + print("failed to fetch bug status") + payload = { + 'status': statusid, + 'version': userstory_version + } + try: + r = tgauserstory.changestatus_userstory(userstoryid, payload, config) + if r.status_code == 200: + print("Sucesfully Synced status from Bugzilla Bug {} to Taiga Userstory {}".format(bug.id, userstoryref)) + else: + print("Check logs for errors,Unable to Sync",r.content, r.status_code) + except requests.exceptions.RequestException as e: + print(e) + except Exception as e: + print(e) + else: + print("Error in fetching user story") + except requests.exceptions.RequestException as e: + print(e) + except Exception as e: + print(e) + else: + print("Unable to fetch epic related user stories,check logs for errors") + else: + print("Unable to Sync Check logs", r.content) + except requests.exceptions.RequestException as e: + print(e) + except Exception as e: + print(e) + +def report(x,config): + try: + r = tgaepic.list_epic(config) + changes = [] + if r.status_code == 200: + data = json.loads(r.content) + #print(data) + for i in data: + print(i['subject']) + if int(i['subject']) == x: + epicid = i['id'] + epicref = i['ref'] + break + + r = tgaepic.listrelepic_userstory(epicid, config) + if r.status_code == 200: + data = json.loads(r.content) + for i in data: + userstoryid = i['user_story'] + print(userstoryid) + try: + r = tgauserstory.get_us(userstoryid, config) + if r.status_code == 200: + userstorydata = json.loads(r.content) + userstory_version = userstorydata['version'] + userstoryref = userstorydata['ref'] + description = userstorydata['description'] + title = userstorydata['subject'] + r = tgauserstory.caget_us(userstoryid, config) + userstorycadata = json.loads(r.content) + bztracker = userstorycadata['attributes_values'][config['TAIGA']['USERSTORY_CA_BUGZILLA_TRACKER']] + summary = userstorycadata['attributes_values'][config['TAIGA']['USERSTORY_CA_SUMMARY']] + #owner = userstorycadata['attributes_values'][config['TAIGA']['USERSTORY_CA_OWNERS']] + email = userstorycadata['attributes_values'][config['TAIGA']['USERSTORY_CA_BUGZILLA_CONTACT']] + target = x + type = userstorycadata['attributes_values'][config['TAIGA']['USERSTORY_CA_SYSTEM_WIDE_CHANGE']] + status = userstorydata['status_extra_info']['name'] + subject = userstorydata['subject'] + print(type, "this is type") + #record['Updated'] = page.get("last updated") + + status = userstorydata['status'] + #changes.append(userstorycadata) + """ + Json Rebuilding is required because + config cant pe passed to the template + and since the user story endpoint only + returns the main userstory and we have + tp call another userstoyr custom attr + endpoint to retrive teh custom atirbutes + all this needs to be clubbed into one json + to be appended to the jinja2 html template + """ + reportjson = {"summary": summary, "contact": email, + "fedora_version": x, "bugzillatracker": bztracker, "description": description, + "type": type, "status": status, "title": subject } + #rjson = json.dumps(reportjson) + """ + types = {'sys_change': [], 'self_change': []} + for n in reportjson: + if n['type'] == True: + types['sys_change'].append(n) + else: + if n['type'] == False: + types['self_change'].append(n) + """ + changes.append(reportjson) + else: + print("Unable to fetch data to generate report, check logs") + except requests.exceptions.RequestException as e: + print(e) + except Exception as e: + print(e) + """ + for n in changes: + #print(n['attributes_values'][config['TAIGA']['USERSTORY_CA_SUMMARY']]) + print(n) + """ + #print(changes) + try: + templateLoader = jinja2.FileSystemLoader(searchpath="./" ) + print("this step first before that") + templateEnv = jinja2.Environment( loader=templateLoader ) + template = templateEnv.get_template("tplate1.html") + print("this step") + templateVars = {'changes': changes, 'fedoraversion': x} + print(templateVars) + outputText = template.render(templateVars) + print(outputText) + with open("test.html", "w") as rhtml: + rhtml.write(outputText) + except Exception as e: + print(e) + else: + print("Failed to fetch data from taiga to generate report") + else: + print("Failed to fetch epics and realted userstories") + except requests.exceptions.RequestException as e: + print(e) + except Exception as e: + print(e) + + + """ + r = tgaepic.listrelepic_userstory(epicid, config) + if r.status_code == 200: + + r = tgauserstory.get_us(userstoryid, config) + if r.status_code == 200: + userstorydata = json.loads(r.content) + userstory_version = userstorydata['version'] + userstoryref = userstorydata['ref'] + r = tgauserstory.caget_us(userstoryid, config) + userstorycadata = json.loads(r.content) + bztracker = userstorycadata['attributes_values'][config['TAIGA']['USERSTORY_CA_BUGZILLA_TRACKER']] + """ + + +def update(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'] + fedora_version = args.release + for x in fedora_version: + try: + status = sync(x, config) + #status = True + if status == True: + print("Succesufully Synced Bugzilla and Taiga status") + print("Generating Report Now .......") + report(x, config) + else: + print("Failed to Sync bugzilla and Taiga Status Check logs") + print("Failed to Generate Report") + except Exception as e: + print(e) + +""" +if __name__ == "__main__": + sync() +""" +""" +https://overiq.com/flask-101/basics-of-jinja-template-language/ +https://www.shellhacks.com/jinja2-check-if-variable-empty-exists-defined-true/ +http://zetcode.com/python/jinja/ +https://medium.com/@mikaelagurney/add-dynamic-components-to-your-html-templates-using-form-s-flask-and-jinja-59b4169ec3e1 +""" \ No newline at end of file From 60e48e4b829576d6ac45e1fc0a3d7434d9b86372 Mon Sep 17 00:00:00 2001 From: pac23 Date: Jul 19 2019 11:53:52 +0000 Subject: [PATCH 59/71] added owners to release notes --- diff --git a/bz/pgba.py b/bz/pgba.py index 7db09a8..606dac2 100644 --- a/bz/pgba.py +++ b/bz/pgba.py @@ -93,7 +93,7 @@ def pgtobz(value, userstoryid, configpath): print("Sucessful Bugzilla Bug Creation") owner = "@" + str(owner) with open("rnotes_issue.txt", "w+") as rnotes_txt: - rnotes_txt.write("{}\n\n[Change Proposal]({})\n".format("standard text here", taiga_issue_link)) + rnotes_txt.write("{}\n\n[Change Proposal]({})\n\n {}".format("standard text here", taiga_issue_link, owner)) editor.edit(filename="rnotes_issue.txt") try: with open("rnotes_issue.txt", "r") as rnotes_txt: From 4f55dcae2b265b6241c6e28fe141bb2c9d552030 Mon Sep 17 00:00:00 2001 From: pac23 Date: Jul 20 2019 10:49:54 +0000 Subject: [PATCH 60/71] added logging functionality --- diff --git a/accept.py b/accept.py index 62f8597..d0ea8a9 100644 --- a/accept.py +++ b/accept.py @@ -106,6 +106,8 @@ def accept(args): service_id = config['TAIGA']['SERVICE_ID'] # service id service_token = config['TAIGA']['SERVICE_TOKEN'] project_id = config['TAIGA']['PROJECT_ID'] + log = config['LOG']['LOCATION'] + setup_logging_to_file(log) value = args.issue for x in value: # iteratingover name space object try: @@ -138,4 +140,5 @@ def accept(args): print(issuel) except Exception as e: print(e, "Unable to accept the Change Proposal") + log_exception(e) diff --git a/bz/bugzilla_auth.py b/bz/bugzilla_auth.py index 5cdb4ab..b654965 100644 --- a/bz/bugzilla_auth.py +++ b/bz/bugzilla_auth.py @@ -34,6 +34,8 @@ def reset(args): service_id = config['BUGZILLA']['SERVICE_ID'] # service id service_token = config['BUGZILLA']['SERVICE_TOKEN'] # service d for auth bz_url = config['BUGZILLA']['BUGZILLA_URL'] # taiga server note + log = config['LOG']['LOCATION'] + setup_logging_to_file(log) print("You User Id and password will be securly store in the Keyring") username = input("Enter your user id for bugzilla: ") password = getpass.getpass("Enter your password for bugzilla: ") @@ -49,3 +51,4 @@ def reset(args): print("Password and api key reset succesfully") except (keyring.errors.PasswordSetError, Exception) as e: print("Failed to reset password & api key", e) + log_exception(e) diff --git a/bz/pgba.py b/bz/pgba.py index 606dac2..1cd4d30 100644 --- a/bz/pgba.py +++ b/bz/pgba.py @@ -130,28 +130,38 @@ def pgtobz(value, userstoryid, configpath): except requests.exceptions.RequestException as e: print("Failed to fetch attributes of the issue") print(e) + log_exception(e) except Exception as e: print(e) + log_exception(e) except requests.exceptions.RequestException as e: print("Failed to fetch attributes of the issue") print(e) + log_exception(e) except Exception as e: print(e) + log_exception(e) except requests.exceptions.RequestException as e: print("Failed to fetch attributes of the issue") print(e) + log_exception(e) except Exception as e: print(e) + log_exception(e) else: print("Cant fetch attributes from Taiga") except requests.exceptions.RequestException as e: print("Failed to fetch attributes of the issue") print(e) + log_exception(e) except Exception as e: print(e) + log_exception(e) except requests.exceptions.RequestException as e: print("Failed to fetch attributes of the issue") print(e) + log_exception(e) except Exception as e: - print(e) + print(e) + log_exception(e) diff --git a/config.ini b/config.ini index a7f21b2..be9a071 100644 --- a/config.ini +++ b/config.ini @@ -76,3 +76,6 @@ PORT = 465 SMTP_SERVER = smtp.gmail.com ; TEST = yes ; 1892835 + +[LOG] +LOCATION = "main.log" \ No newline at end of file diff --git a/mail/climail.py b/mail/climail.py index 30eafad..ba969c5 100644 --- a/mail/climail.py +++ b/mail/climail.py @@ -55,6 +55,8 @@ def mails(args): service_id = config['EMAIL']['SERVICE_ID'] sender = config['EMAIL']['SENDER_EMAIL_ID'] reciver = config['EMAIL']['LIST'] + log = config['LOG']['LOCATION'] + setup_logging_to_file(log) print(args) value = args.ml for x in value: @@ -102,11 +104,14 @@ def mails(args): print("Mail was not sent check logs for errors") except Exception as e: print(e) + log_exception(e) else: print("check logs") except requests.exceptions.RequestException as e: print(e) + log_exception(e) else: print("unable to send emails check logs") except requests.exceptions.RequestException as e: print(e) + log_exception(e) diff --git a/mail/mailauth.py b/mail/mailauth.py index 23df271..45c695a 100644 --- a/mail/mailauth.py +++ b/mail/mailauth.py @@ -28,3 +28,4 @@ def reset(args): print("Password reset succesfully") except (keyring.errors.PasswordSetError, Exception) as e: print("Failed to reset password", e) + log_exception(e) diff --git a/mail/maillist.py b/mail/maillist.py index 79fa0ed..e0c84a6 100644 --- a/mail/maillist.py +++ b/mail/maillist.py @@ -91,3 +91,4 @@ def email_send(subject, replyto, config): return True except Exception as e: print(e) + log_exception(e) diff --git a/pgure/fesco.py b/pgure/fesco.py index 73dac8d..8caaa17 100644 --- a/pgure/fesco.py +++ b/pgure/fesco.py @@ -27,6 +27,8 @@ def fesissue(args): service_token = config['TAIGA']['SERVICE_TOKEN'] project_id = config['TAIGA']['PROJECT_ID'] value = args.fesco + log = config['LOG']['LOCATION'] + setup_logging_to_file(log) for x in value: # iteratingover name space object try: r = tgaissue.get_issue(x, config) # x is user story refrence id @@ -95,13 +97,17 @@ def fesissue(args): print("Check logs for errors",json.loads(r.content)) except requests.exceptions.RequestException as e: print(e) + log_exception(e) except Exception as e: print(e) + log_exception(e) else: print("Unable to post to fesco") except requests.exceptions.RequestException as e: print(e) + log_exception(e) else: print("Unable to fetch details from taiga for issue creation") except requests.exceptions.RequestException as e: print(e) + log_exception(e) diff --git a/pgure/issues.py b/pgure/issues.py index 9b8131c..86e8162 100644 --- a/pgure/issues.py +++ b/pgure/issues.py @@ -31,8 +31,10 @@ def list_issue(config): return r except requests.exceptions.RequestException as e: print(e) + log_exception(e) except Exception as e: print(e) + log_exception(e) def get_issue(issueid, config): @@ -55,8 +57,10 @@ def get_issue(issueid, config): return r except requests.exceptions.RequestException as e: print(e) + log_exception(e) except Exception as e: print(e) + log_exception(e) def post_issue(payload, repo, config): @@ -81,5 +85,7 @@ def post_issue(payload, repo, config): return r except requests.exceptions.RequestException as e: print(e) + log_exception(e) except Exception as e: - print(e) \ No newline at end of file + print(e) + log_exception(e) \ No newline at end of file diff --git a/pgure/pagure_auth.py b/pgure/pagure_auth.py index 3d5d547..6654f62 100644 --- a/pgure/pagure_auth.py +++ b/pgure/pagure_auth.py @@ -15,6 +15,8 @@ def reset(args): print("Your auth token will be securly store in the Keyring") # username = input("Enter your user id for taiga: ") service_id = config['PAGURE']['SERVICE_ID'] + log = config['LOG']['LOCATION'] + setup_logging_to_file(log) #repo_name = input("Enter the repo name you want to set api key for: ") fescotoken = getpass.getpass("Enter your token for" + ' ' + "fesco" + ' ' "repository: ") releasetoken = getpass.getpass("Enter your token for" + ' ' + "release-notes" + ' ' "repository: ") @@ -27,4 +29,5 @@ def reset(args): except (keyring.errors.PasswordSetError, Exception) as e: print("Failed to reset token") print(e) + log_exception(e) # print(e + "Contact the developers asap") diff --git a/tga/convert.py b/tga/convert.py index 76dbed4..dfc6036 100644 --- a/tga/convert.py +++ b/tga/convert.py @@ -36,6 +36,8 @@ def convert(value, configpath): service_token = config['TAIGA']['SERVICE_TOKEN'] project_id = config['TAIGA']['PROJECT_ID'] taiga_url = config['TAIGA']['TAIGA_URL'] + log = config['LOG']['LOCATION'] + setup_logging_to_file(log) #value = args.taiga for x in value: try: @@ -208,25 +210,32 @@ def convert(value, configpath): print("Unnsucessful to map to epics,change user story status to accepted and issue status to processed") except requests.exceptions.RequestException as e: print(e) + log_exception(e) except Exception as e: print(e) + log_exception(e) else: print("Unsuccesful Conversion") else: print("Unsuccesful conversion") except requests.exceptions.RequestException as e: print(e) + log_exception(e) except Exception as e: - print(e) + print(e) + log_exception(e) else: print("Unsuccesful Conversion") except requests.exceptions.RequestException as e: print("Failed to fetch attributes of the issue") print(e) + log_exception(e) else: print("Unable to Convert Issue,Check logs and contact the developer", json.loads(r.content)) except Exception as e: print(e) + log_exception(e) except requests.exceptions.RequestException as e: print(e) + log_exception(e) diff --git a/tga/epics.py b/tga/epics.py index 69a0a9b..042ada6 100644 --- a/tga/epics.py +++ b/tga/epics.py @@ -48,8 +48,10 @@ def list_epic(config): return r except requests.exceptions.RequestException as e: print(e) + log_exception(e) except Exception as e: print(e) + log_exception(e) def post_relatedus(USERSTORY_id, epicid, epicref, config): @@ -75,8 +77,10 @@ def post_relatedus(USERSTORY_id, epicid, epicref, config): return r except requests.exceptions.RequestException as e: print(e) + log_exception(e) except Exception as e: print(e) + log_exception(e) def listrelepic_userstory(epicid, config): #url = str(config['TAIGA']['TAIGA_URL']) + "/api/v1/userstories?project=" + str(config['TAIGA']['PROJECT_ID']) + "&epic=" + epicid @@ -95,5 +99,7 @@ def listrelepic_userstory(epicid, config): return r except requests.exceptions.RequestException as e: print(e) + log_exception(e) except Exception as e: - print(e) \ No newline at end of file + print(e) + log_exception(e) \ No newline at end of file diff --git a/tga/issues.py b/tga/issues.py index 1ff6f6f..eaf7fc4 100644 --- a/tga/issues.py +++ b/tga/issues.py @@ -78,13 +78,17 @@ def list_issue(args): print(r.content) except requests.exceptions.RequestException as e: print(e) + log_exception(e) except Exception as e: print(e) + log_exception(e) except Exception as e: print(e) + log_exception(e) def get_issue(x, config): + try: """ config = configparser.ConfigParser() @@ -105,8 +109,10 @@ def get_issue(x, config): return url, r except requests.exceptions.RequestException as e: print(e) + log_exception(e) except Exception as e: print(e) + log_exception(e) def caget_issue(x, config): """ @@ -131,8 +137,10 @@ def caget_issue(x, config): return r except requests.exceptions.RequestException as e: print(e) + log_exception(e) except Exception as e: print(e) + log_exception(e) def changestatus_issue(x, payload, config): @@ -161,8 +169,10 @@ def changestatus_issue(x, payload, config): return r except requests.exceptions.RequestException as e: print(e) + log_exception(e) except Exception as e: print(e) + log_exception(e) def edit_issue(x, id, config): #url = str(config['TAIGA']['TAIGA_URL']) + "/api/v1/issues?project=" + config['TAIGA']['PROJECT_ID'] + "&status=" + str(config['TAIGA']['ISSUE_STATUS_NEW']) @@ -183,5 +193,7 @@ def edit_issue(x, id, config): return r except requests.exceptions.RequestException as e: print(e) + log_exception(e) except Exception as e: - print(e) \ No newline at end of file + print(e) + log_exception(e) \ No newline at end of file diff --git a/tga/taiga_auth.py b/tga/taiga_auth.py index 3716499..d772c92 100644 --- a/tga/taiga_auth.py +++ b/tga/taiga_auth.py @@ -39,6 +39,8 @@ def refresh_token(args): configpath = args.config config = configparser.ConfigParser() config.read(configpath) + log = config['LOG']['LOCATION'] + setup_logging_to_file(log) headers = { 'Content-Type': 'application/json', } @@ -76,14 +78,18 @@ def refresh_token(args): print("auth error") except requests.exceptions.RequestException as e: print(e) + log_exception(e) except Exception as e: print(e) + log_exception(e) def reset(args): configpath = args.config config = configparser.ConfigParser() config.read(configpath) + log = config['LOG']['LOCATION'] + setup_logging_to_file(log) headers = { 'Content-Type': 'application/json', } @@ -108,6 +114,8 @@ def reset(args): print("Password reset succesfully") except (keyring.errors.PasswordSetError, Exception) as e: print("Failed to reset password") + log_exception(e) except Exception as e: print(e) + log_exception(e) diff --git a/tga/userstory.py b/tga/userstory.py index e3cdb64..901d8f0 100644 --- a/tga/userstory.py +++ b/tga/userstory.py @@ -76,10 +76,13 @@ def list_us(args): except requests.exceptions.RequestException as e: print(e) print(r.content) + log_exception(e) except Exception as e: print(e) + log_exception(e) except Exception as e: print(e) + log_exception(e) def get_us(usid, config): @@ -104,8 +107,10 @@ def get_us(usid, config): return r except requests.exceptions.RequestException as e: print(e) + log_exception(e) except Exception as e: print(e) + log_exception(e) def caget_us(usid, config): @@ -122,8 +127,10 @@ def caget_us(usid, config): return r except requests.exceptions.RequestException as e: print(e) + log_exception(e) except Exception as e: print(e) + log_exception(e) def post_us(x, config): @@ -145,8 +152,10 @@ def post_us(x, config): return r except requests.exceptions.RequestException as e: print(e) + log_exception(e) except Exception as e: print(e) + log_exception(e) def post_usca(x, id, config): @@ -176,8 +185,10 @@ def post_usca(x, id, config): return r except requests.exceptions.RequestException as e: print(e) + log_exception(e) except Exception as e: print(e) + log_exception(e) def changestatus_userstory(x, payload, config): @@ -207,8 +218,10 @@ def changestatus_userstory(x, payload, config): return r except requests.exceptions.RequestException as e: print(e) + log_exception(e) except Exception as e: print(e) + log_exception(e) def listrelepic_userstory(epicid, config): @@ -221,8 +234,10 @@ def listrelepic_userstory(epicid, config): return r except requests.exceptions.RequestException as e: print(e) + log_exception(e) except Exception as e: print(e) + log_exception(e) """ curl -X GET \ -H "Content-Type: application/json" \ diff --git a/update.py b/update.py index 29b48d0..7b841e9 100644 --- a/update.py +++ b/update.py @@ -21,12 +21,13 @@ from pgure import issues as pgaissues from bz import bugs as bzbugs from urllib.parse import urlparse from collections import OrderedDict +from logger import setup_logging_to_file, log_exception def sync(x, config): # fvid is fedora version - configpath = args.config - config = configparser.ConfigParser() - config.read(configpath) + #configpath = args.config + #config = configparser.ConfigParser() + #config.read(configpath) #fvid = args.sync_status bzapi = bugzilla.Bugzilla(config['BUGZILLA']['BUGZILLA_URL']) #for x in fvid: @@ -96,124 +97,135 @@ def sync(x, config): print("Check logs for errors,Unable to Sync",r.content, r.status_code) except requests.exceptions.RequestException as e: print(e) + log_exception(e) except Exception as e: print(e) + log_exception(e) else: print("Error in fetching user story") except requests.exceptions.RequestException as e: print(e) + log_exception(e) except Exception as e: print(e) + log_exception(e) else: print("Unable to fetch epic related user stories,check logs for errors") else: print("Unable to Sync Check logs", r.content) except requests.exceptions.RequestException as e: print(e) + log_exception(e) except Exception as e: print(e) + log_exception(e) def report(x,config): try: - r = tgaepic.list_epic(config) - changes = [] - if r.status_code == 200: - data = json.loads(r.content) - #print(data) - for i in data: - print(i['subject']) - if int(i['subject']) == x: - epicid = i['id'] - epicref = i['ref'] - break - - r = tgaepic.listrelepic_userstory(epicid, config) + r = tgaepic.list_epic(config) + changes = [] if r.status_code == 200: data = json.loads(r.content) + #print(data) for i in data: - userstoryid = i['user_story'] - print(userstoryid) + print(i['subject']) + if int(i['subject']) == x: + epicid = i['id'] + epicref = i['ref'] + break + + r = tgaepic.listrelepic_userstory(epicid, config) + if r.status_code == 200: + data = json.loads(r.content) + for i in data: + userstoryid = i['user_story'] + print(userstoryid) + try: + r = tgauserstory.get_us(userstoryid, config) + if r.status_code == 200: + userstorydata = json.loads(r.content) + userstory_version = userstorydata['version'] + userstoryref = userstorydata['ref'] + description = userstorydata['description'] + title = userstorydata['subject'] + r = tgauserstory.caget_us(userstoryid, config) + userstorycadata = json.loads(r.content) + bztracker = userstorycadata['attributes_values'][config['TAIGA']['USERSTORY_CA_BUGZILLA_TRACKER']] + summary = userstorycadata['attributes_values'][config['TAIGA']['USERSTORY_CA_SUMMARY']] + #owner = userstorycadata['attributes_values'][config['TAIGA']['USERSTORY_CA_OWNERS']] + email = userstorycadata['attributes_values'][config['TAIGA']['USERSTORY_CA_BUGZILLA_CONTACT']] + target = x + type = userstorycadata['attributes_values'][config['TAIGA']['USERSTORY_CA_SYSTEM_WIDE_CHANGE']] + status = userstorydata['status_extra_info']['name'] + subject = userstorydata['subject'] + print(type, "this is type") + #record['Updated'] = page.get("last updated") + + status = userstorydata['status'] + #changes.append(userstorycadata) + """ + Json Rebuilding is required because + config cant pe passed to the template + and since the user story endpoint only + returns the main userstory and we have + tp call another userstoyr custom attr + endpoint to retrive teh custom atirbutes + all this needs to be clubbed into one json + to be appended to the jinja2 html template + """ + reportjson = {"summary": summary, "contact": email, + "fedora_version": x, "bugzillatracker": bztracker, "description": description, + "type": type, "status": status, "title": subject } + #rjson = json.dumps(reportjson) + """ + types = {'sys_change': [], 'self_change': []} + for n in reportjson: + if n['type'] == True: + types['sys_change'].append(n) + else: + if n['type'] == False: + types['self_change'].append(n) + """ + changes.append(reportjson) + else: + print("Unable to fetch data to generate report, check logs") + except requests.exceptions.RequestException as e: + print(e) + log_exception(e) + except Exception as e: + print(e) + log_exception(e) + """ + for n in changes: + #print(n['attributes_values'][config['TAIGA']['USERSTORY_CA_SUMMARY']]) + print(n) + """ + #print(changes) try: - r = tgauserstory.get_us(userstoryid, config) - if r.status_code == 200: - userstorydata = json.loads(r.content) - userstory_version = userstorydata['version'] - userstoryref = userstorydata['ref'] - description = userstorydata['description'] - title = userstorydata['subject'] - r = tgauserstory.caget_us(userstoryid, config) - userstorycadata = json.loads(r.content) - bztracker = userstorycadata['attributes_values'][config['TAIGA']['USERSTORY_CA_BUGZILLA_TRACKER']] - summary = userstorycadata['attributes_values'][config['TAIGA']['USERSTORY_CA_SUMMARY']] - #owner = userstorycadata['attributes_values'][config['TAIGA']['USERSTORY_CA_OWNERS']] - email = userstorycadata['attributes_values'][config['TAIGA']['USERSTORY_CA_BUGZILLA_CONTACT']] - target = x - type = userstorycadata['attributes_values'][config['TAIGA']['USERSTORY_CA_SYSTEM_WIDE_CHANGE']] - status = userstorydata['status_extra_info']['name'] - subject = userstorydata['subject'] - print(type, "this is type") - #record['Updated'] = page.get("last updated") - - status = userstorydata['status'] - #changes.append(userstorycadata) - """ - Json Rebuilding is required because - config cant pe passed to the template - and since the user story endpoint only - returns the main userstory and we have - tp call another userstoyr custom attr - endpoint to retrive teh custom atirbutes - all this needs to be clubbed into one json - to be appended to the jinja2 html template - """ - reportjson = {"summary": summary, "contact": email, - "fedora_version": x, "bugzillatracker": bztracker, "description": description, - "type": type, "status": status, "title": subject } - #rjson = json.dumps(reportjson) - """ - types = {'sys_change': [], 'self_change': []} - for n in reportjson: - if n['type'] == True: - types['sys_change'].append(n) - else: - if n['type'] == False: - types['self_change'].append(n) - """ - changes.append(reportjson) - else: - print("Unable to fetch data to generate report, check logs") - except requests.exceptions.RequestException as e: - print(e) + templateLoader = jinja2.FileSystemLoader(searchpath="./" ) + print("this step first before that") + templateEnv = jinja2.Environment( loader=templateLoader ) + template = templateEnv.get_template("tplate1.html") + print("this step") + templateVars = {'changes': changes, 'fedoraversion': x} + print(templateVars) + outputText = template.render(templateVars) + print(outputText) + with open("test.html", "w") as rhtml: + rhtml.write(outputText) except Exception as e: print(e) - """ - for n in changes: - #print(n['attributes_values'][config['TAIGA']['USERSTORY_CA_SUMMARY']]) - print(n) - """ - #print(changes) - try: - templateLoader = jinja2.FileSystemLoader(searchpath="./" ) - print("this step first before that") - templateEnv = jinja2.Environment( loader=templateLoader ) - template = templateEnv.get_template("tplate1.html") - print("this step") - templateVars = {'changes': changes, 'fedoraversion': x} - print(templateVars) - outputText = template.render(templateVars) - print(outputText) - with open("test.html", "w") as rhtml: - rhtml.write(outputText) - except Exception as e: - print(e) + log_exception(e) + else: + print("Failed to fetch data from taiga to generate report") else: - print("Failed to fetch data from taiga to generate report") - else: - print("Failed to fetch epics and realted userstories") + print("Failed to fetch epics and realted userstories") except requests.exceptions.RequestException as e: print(e) + log_exception(e) except Exception as e: print(e) + log_exception(e) """ @@ -238,6 +250,8 @@ def update(args): service_id = config['TAIGA']['SERVICE_ID'] # service id service_token = config['TAIGA']['SERVICE_TOKEN'] project_id = config['TAIGA']['PROJECT_ID'] + log = config['LOG']['LOCATION'] + setup_logging_to_file(log) fedora_version = args.release for x in fedora_version: try: @@ -252,6 +266,7 @@ def update(args): print("Failed to Generate Report") except Exception as e: print(e) + log_exception(e) """ if __name__ == "__main__": From 5876caf52e8789ea0fd5f5d32a9440a8baca3dbd Mon Sep 17 00:00:00 2001 From: pac23 Date: Jul 25 2019 18:41:14 +0000 Subject: [PATCH 61/71] add logging to more modules --- diff --git a/accept.py b/accept.py index d0ea8a9..613f325 100644 --- a/accept.py +++ b/accept.py @@ -11,7 +11,7 @@ from tga import convert from pgure import issues as pgaissues from bz import bugs as bzbugz from bz import pgba - +from logger import setup_logging_to_file, log_exception """ def accept(value, configpath): diff --git a/bz/bugzilla_auth.py b/bz/bugzilla_auth.py index b654965..58fc083 100644 --- a/bz/bugzilla_auth.py +++ b/bz/bugzilla_auth.py @@ -7,6 +7,8 @@ import binascii import getpass import configparser +from logger import setup_logging_to_file, log_exception + """" config = configparser.ConfigParser() config.read('config.ini') diff --git a/bz/pgba.py b/bz/pgba.py index 1cd4d30..d77b4da 100644 --- a/bz/pgba.py +++ b/bz/pgba.py @@ -4,12 +4,15 @@ import json import keyring import configparser import editor +import bugzilla + from tga import epics as tgaepic from tga import issues as tgaissue from tga import userstory as tgauserstory from pgure import issues as pgaissues from bz import bugs as bzbugs -import bugzilla +from logger import setup_logging_to_file, log_exception + def pgtobz(value, userstoryid, configpath): diff --git a/mail/climail.py b/mail/climail.py index ba969c5..1b0a38d 100644 --- a/mail/climail.py +++ b/mail/climail.py @@ -10,6 +10,7 @@ import editor from mail import maillist from tga import issues +from logger import setup_logging_to_file, log_exception """ diff --git a/mail/mailauth.py b/mail/mailauth.py index 45c695a..6bffa19 100644 --- a/mail/mailauth.py +++ b/mail/mailauth.py @@ -4,6 +4,7 @@ import getpass import configparser import binascii +from logger import setup_logging_to_file, log_exception """ config = configparser.ConfigParser() config.read('config.ini') diff --git a/mail/maillist.py b/mail/maillist.py index e0c84a6..014b09c 100644 --- a/mail/maillist.py +++ b/mail/maillist.py @@ -10,7 +10,7 @@ from email import encoders from email.mime.base import MIMEBase from email.mime.multipart import MIMEMultipart from email.mime.text import MIMEText - +from logger import setup_logging_to_file, log_exception """ config = configparser.ConfigParser() config.read('config.ini') diff --git a/pgure/fesco.py b/pgure/fesco.py index 8caaa17..1426ec9 100644 --- a/pgure/fesco.py +++ b/pgure/fesco.py @@ -8,6 +8,7 @@ from tga import epics as tgaepic from tga import issues as tgaissue from tga import userstory as tgauserstory from pgure import issues as pgaissues +from logger import setup_logging_to_file, log_exception """ if config['TAIGA']['TEST'] == 'yes': diff --git a/pgure/pagure_auth.py b/pgure/pagure_auth.py index 6654f62..f107ca8 100644 --- a/pgure/pagure_auth.py +++ b/pgure/pagure_auth.py @@ -7,6 +7,7 @@ import binascii import getpass import configparser +from logger import setup_logging_to_file, log_exception def reset(args): configpath = args.config diff --git a/tga/convert.py b/tga/convert.py index dfc6036..52e7d6c 100644 --- a/tga/convert.py +++ b/tga/convert.py @@ -6,6 +6,7 @@ import configparser from tga import epics as tgaepic from tga import issues as tgaissue from tga import userstory as tgauserstory +from logger import setup_logging_to_file, log_exception """ config = configparser.ConfigParser() From 1c42f82f36917517a6267097d3c190656c65802d Mon Sep 17 00:00:00 2001 From: pac23 Date: Jul 25 2019 18:42:29 +0000 Subject: [PATCH 62/71] add create issue from tool --- diff --git a/main.py b/main.py index c81fb5c..8e5a86f 100644 --- a/main.py +++ b/main.py @@ -13,10 +13,11 @@ from bz import bugzilla_auth from tga import issues as tgaissue from tga import userstory as tguserstory from tga import convert +from tga import createprop from mail import climail from mail import mailauth from pgure import fesco - +from logger import setup_logging_to_file, log_exception class Change_Tool(object): def __init__(self): @@ -272,6 +273,15 @@ The commands are: #update.sync(args) update.update(args) + def create(self): + parser = argparse.ArgumentParser( + description='File a Change proposal from the cli') + parser.add_argument('--config', + default='config.ini', + help='Sets config path') + args = parser.parse_args(sys.argv[2:]) + createprop.create(args) + """ def config(self): parser = argparse.ArgumentParser( diff --git a/tga/createprop.py b/tga/createprop.py new file mode 100644 index 0000000..7a3483a --- /dev/null +++ b/tga/createprop.py @@ -0,0 +1,143 @@ +import os +import requests +import json +import keyring +import configparser +import logger +import editor +import sys + +from tga import epics as tgaepic +from tga import issues as tgaissue +from tga import userstory as tgauserstory +from logger import setup_logging_to_file, log_exception + +def create(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'] + taiga_url = config['TAIGA']['TAIGA_URL'] + log = config['LOG']['LOCATION'] + setup_logging_to_file(log) + title = input("Enter the title of the issue: ") + description = input("Enter the Description of the issue: ") + change_type = input("System Wide Change ? Yes/No : ") + link_releng = input("Enter the link to releng ticket : ") + summary = input("Summary of the issue: ") + bugzilla = input("Bugzilla Email adress: ") + approval = input("Does this change proposal require approval ? Yes or No ? : ") + owners = input("Enter the FAS ID of the Owner: ") + deadline = input(" Enter Contingency Deadline , 1-BranchPoint, 2-BetaFreeze, 3-Final Freeze: ") + massrebuild = input("Is Mass rebuild required ? Yes or No ? : ") + policy_change = input("Is policy_change required ? Yes/No : ") + modified_deliverables = input("Does this create or remove something ? Yes/No : ") + fedora_version = input("Input the Fedora-Version: ") + change_subtype = input("Input The Change Type 1-Bug, 2-Question, 3- Enhancement: ") + servity = input("Input the servity of the issue 1-Normal, 2-Wishlist, 3-Minor, 4-Important, 5-Critical : ") + priority = input("Input the priority type 1-Normal, 2-Low, 3-High : ") + with open("post_isssue.txt", "w+") as pissue_txt: + pissue_txt.write("Description: {} \n ".format(description)) + editor.edit(filename="post_isssue.txt") + try: + if change_subtype == str(1): + change_subtype = config['TAIGA']['ISSUE_TYPE_BUG'] + elif change_subtype == str(2): + change_subtype = config['TAIGA']['ISSUE_TYPE_QUESTION'] + elif change_subtype == str(3): + change_subtype = config['TAIGA']['ISSUE_TYPE_ENHANCEMENT'] + else: + print("error in change type input") + + if servity == str(1): + servity = confg['TAIGA']['ISSUE_SERVITY_NORMAL'] + elif servity == str(2): + servity = config['TAIGA']['ISSUE_SERVITY_WISHLIST'] + elif servity == str(3): + servity = config['TAIGA']['ISSUE_SERVITY_MINOR'] + elif servity == str(4): + servity = config['TAIGA']['ISSUE_SERVITY_IMPORTANT'] + elif servity == str(5): + servity = config['TAIGA']['ISSUE_SERVITY_CRITICAL'] + else: + print("error in issue servity input") + + if priority == str(1): + priority = config['TAIGA']['ISSUE_PRIORITIES_NORMAL'] + elif priority == str(2): + priority = config['TAIGA']['ISSUE_PRIORITIES_LOW'] + elif priority == str(3): + priority = config['TAIGA']['ISSUE_PRIORITIES_HIGH'] + else: + print("Error in priority input") + + if change_type == "Yes": + change_type = True + elif change_type == "No": + change_type = False + + if approval == "Yes": + approval == True + elif approval == "No": + approval == False + + if massrebuild == "Yes": + massrebuild == True + elif massrebuild == "No": + massrebuild == False + + if policy_change == "Yes": + policy_change == True + elif policy_change == "No": + policy_change == False + + if modified_deliverables == "Yes": + modified_deliverables == True + elif modified_deliverables == "No": + modified_deliverables == False + + with open("post_isssue.txt", "r") as pissue_txt: + description = pissue_txt.read() + payload = { + "subject": title, + "description": description, + "project": config['TAIGA']['PROJECT_ID'], + "servity": servity, + "priority": priority, + "status": config['TAIGA']['ISSUE_STATUS_NEW'], + "type": change_subtype + } + r = tgaissue.post_issue(payload, config) + if r.status_code == 200: + issuedata = josn.loads(r.content) + ref = issuedata['ref'] + id = issuedata['id'] + payload = { + "attributes_values": { + config['TAIGA']['ISSUE_CA_SYSTEM_WIDE_CHANGE']: change_type, + config['TAIGA']['ISSUE_CA_SYSTEM_SUMMARY']: summary, + config['TAIGA']['ISSUE_CA_SYSTEM_BUGZILLA_CONTACT']: bugzilla, + config['TAIGA']['ISSUE_CA_TRADEMARK_APPROVAL']: approval, + config['TAIGA']['ISSUE_CA_OWNERS']: owners, + config['TAIGA']['ISSUE_CA_MASS_REBUILD']: massrebuild, + config['TAIGA']['ISSUE_CA_POLICY_CHANGE']: policy_change, + config['TAIGA']['ISSUE_CA_MODIFIES_DELIVERABLES']: modified_deliverables, + config['TAIGA']['ISSUE_CA_RELENG_TICKET']: link_releng + } + } + r = tgaissue.capatch_issue(id, payload, config) + if r.status_code == 200: + print("Succesfully Created Issue") + else: + print("Unable to create issue check log for errors") + else: + print("Unable to create issue check log for errors") + except requests.exceptions.RequestException as e: + print(e) + log_exception(e) + except Exception as e: + print(e) + log_exception(e) + diff --git a/tga/issues.py b/tga/issues.py index eaf7fc4..496434b 100644 --- a/tga/issues.py +++ b/tga/issues.py @@ -4,7 +4,7 @@ import keyring import requests from prettytable import PrettyTable - +from logger import setup_logging_to_file, log_exception """ config = configparser.ConfigParser() config.read('config.ini') @@ -142,6 +142,28 @@ def caget_issue(x, config): print(e) log_exception(e) +def capatch_issue(x, payload, config): + try: + headers = { + 'Content-Type': 'application/json', + 'Authorization': 'Bearer {0}'.format(keyring.get_password(config['TAIGA']['SERVICE_TOKEN'], "taiga_token")) + # 'Authorization': 'Bearer {0}'.format(str(123)) + } + print(x) + id_url = str(config['TAIGA']['TAIGA_URL']) + "/api/v1/issues/custom-attributes-values/" + str(x) + r = request.patch( + id_url, + headers=headers, + data=json.dumps(payload) + ) + return r + except requests.exceptions.RequestException as e: + print(e) + log_exception(e) + except Exception as e: + print(e) + log_exception(e) + def changestatus_issue(x, payload, config): """ @@ -177,7 +199,7 @@ def changestatus_issue(x, payload, config): def edit_issue(x, id, config): #url = str(config['TAIGA']['TAIGA_URL']) + "/api/v1/issues?project=" + config['TAIGA']['PROJECT_ID'] + "&status=" + str(config['TAIGA']['ISSUE_STATUS_NEW']) try: - url = 'https://api.taiga.io/api/v1/issues/' + str(id) + url = str(config['TAIGA']['TAIGA_URL']) + "api/v1/issues/" + str(id) headers = { 'Content-Type': 'application/json', 'Authorization': 'Bearer {0}'.format(keyring.get_password(config['TAIGA']['SERVICE_TOKEN'], "taiga_token")) @@ -196,4 +218,22 @@ def edit_issue(x, id, config): log_exception(e) except Exception as e: print(e) + log_exception(e) + +def post_issue(x, config): + try: + url = str(config['TAIGA']['TAIGA_URL']) + "api/v1/issues/" + headers = { + 'Content-Type': 'application/json', + 'Authorization': 'Bearer {0}'.format(keyring.get_password(config['TAIGA']['SERVICE_TOKEN'], "taiga_token")) + } + r = request.post( + url, + data=json.dumps(x), + headers=headers + ) + print(json.loads(r.content)) + return r + except Exception as e: + print(e) log_exception(e) \ No newline at end of file diff --git a/update.py b/update.py index 7b841e9..f6a15a9 100644 --- a/update.py +++ b/update.py @@ -111,6 +111,7 @@ def sync(x, config): log_exception(e) else: print("Unable to fetch epic related user stories,check logs for errors") + else: print("Unable to Sync Check logs", r.content) except requests.exceptions.RequestException as e: From 216eb8b52a7f1b4bfff06015d9240e08811e0cbf Mon Sep 17 00:00:00 2001 From: pac23 Date: Jul 25 2019 18:43:08 +0000 Subject: [PATCH 63/71] add init file --- diff --git a/__init__.py b/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/__init__.py From 69761ccbdad7613b332ff4fa899604482bf3de6c Mon Sep 17 00:00:00 2001 From: pac23 Date: Jul 25 2019 18:43:23 +0000 Subject: [PATCH 64/71] add template final --- diff --git a/tplate1.html b/tplate1.html new file mode 100644 index 0000000..a99d7c6 --- /dev/null +++ b/tplate1.html @@ -0,0 +1,81 @@ + + + + Releases/{{ fedora_version }}/changeset + + + + + + + Fedora People - fedorapeople.org + + + + + +
+ + +
+
+
+ +Fedora{{fedora-version }} chaneset </t> + +<h2> Accepted fedora {{ fedora-version}} System Wide Change Proposals +{% for n in changes %} + {% if n[type] == "True" %} + <h4> {{ n['title'] }} </h3> + <p> {{ n['summary'] }} </p> + <ul><li>owners : {{ n['owners'] }} </li> + <li> Release Notes owner: </li><ul> + <ul><li> + Tracking Bug : <a href="{{ Bugzilla }}"> + </a></li> + <li> + Status : {{ n[status] }} + </li></ul> + {% endif %} +{% endfor %} + +<h2>Accepted Fedora {{ fedora-version }} Self Containted Change Proposals </h2> +{% for n in changes %} + {% if n[type] == "False" %} + <h4> + {{ n['title'] }} + </h4> + <p> + {{ n['summary'] }} + </p> + <h4> Owners </h4> + <ul><li> + Owner: {{ n['owners'] }} + </li> + <li> + Release notes owner : {{ n['release_owners'] }} + </li></ul> + <ul><li> + Tracking Bug : <a href= " {{ Bugzilla }} "> + </a></li> + <li> + Status : {{ Change_Status }} + </li></ul> + {% endif %} +{% endfor %} +</body> +</html> \ No newline at end of file From 780f5951fe8dc2ad2db2c2b982ecaafa758b1d7c Mon Sep 17 00:00:00 2001 From: pac23 <manasmangaonkar@gmail.com> Date: Jul 25 2019 18:43:52 +0000 Subject: [PATCH 65/71] add releng in fesco ticket --- diff --git a/pgure/fesco.py b/pgure/fesco.py index 1426ec9..01f7c0f 100644 --- a/pgure/fesco.py +++ b/pgure/fesco.py @@ -68,7 +68,7 @@ def fesissue(args): maillist_dsc_list = "random" owner = "@" + str(owner) with open("fesco_issue.txt", "w+") as pg_txt: - pg_txt.write("{}\n\n * [Change Proposal]({})\n * [devel-announce post]({})\n * [devel list discussion]({})\n * owner:{}\n".format(summary, taiga_issue_link, maillist_link, maillist_dsc_list, owner)) + pg_txt.write("{}\n\n * [Change Proposal]({})\n * [devel-announce post]({})\n * [devel list discussion]({})\n * [Rel eng Proposal]({})\n * owner:{}\n".format(summary, taiga_issue_link, maillist_link, maillist_dsc_list, relengticket ,owner)) editor.edit(filename="fesco_issue.txt") try: with open("fesco_issue.txt", "r") as pg_txt: From fb9bf9fe1d4cc6a1c3322459f9acd9ee9fe094fa Mon Sep 17 00:00:00 2001 From: pac23 <manasmangaonkar@gmail.com> Date: Jul 25 2019 18:44:13 +0000 Subject: [PATCH 66/71] add servility,priority to config. --- diff --git a/config.ini b/config.ini index be9a071..d2c7134 100644 --- a/config.ini +++ b/config.ini @@ -53,6 +53,19 @@ USERSTORY_CA_POLICY_CHANGE = 21934 USERSTORY_CA_MODIFIES_DELIVERABLES = 21935 USERSTORY_CA_ISSUE_LINK = 22140 +ISSUE_PRIORITIES_LOW = 979360 +ISSUE_PRIORITIES_NORMAL = 979361 +ISSUE_PRIORITIES_HIGH = 979362 + +ISSUE_SERVITY_WISHLIST = 1627044 +ISSUE_SERVITY_MINOR = 1627045 +ISSUE_SERVITY_NORMAL = 1627046 +ISSUE_SERVITY_IMPORTANT = 1627047 +ISSUE_SERVITY_CRITICAL = 1627048 + +ISSUE_TYPE_BUG = 983893 +ISSUE_TYPE_QUESTION = 983894 +ISSUE_TYPE_ENHANCEMENT = 983895 [PAGURE] SERVICE_ID = pagure From eb1a296287df17af8cfba6cbe451bda07d9c23f8 Mon Sep 17 00:00:00 2001 From: pac23 <manasmangaonkar@gmail.com> Date: Jul 29 2019 15:39:36 +0000 Subject: [PATCH 67/71] add logger class --- diff --git a/logger.py b/logger.py new file mode 100644 index 0000000..5b1afe7 --- /dev/null +++ b/logger.py @@ -0,0 +1,28 @@ +import sys +import traceback +import logging + +def setup_logging_to_file(filename): + logging.basicConfig( filename=filename, + filemode='a', + level=logging.DEBUG, + format= '%(asctime)s - %(levelname)s - %(message)s', + ) + +def extract_function_name(): + """Extracts failing function name from Traceback + http://stackoverflow.com/questions/2380073/\ + how-to-identify-what-function-call-raise-an-exception-in-python + """ + tb = sys.exc_info()[-1] + stk = traceback.extract_tb(tb, 1) + fname = stk[0][3] + return fname + +def log_exception(e): + logging.error( + "Function {function_name} raised {exception_class} ({exception_docstring}): {exception_message}".format( + function_name = extract_function_name(), #this is optional + exception_class = e.__class__, + exception_docstring = e.__doc__, + exception_message = e.message)) From a3c6fd26ad0b34c5ff3f90dd9e053d510b72281f Mon Sep 17 00:00:00 2001 From: pac23 <manasmangaonkar@gmail.com> Date: Jul 30 2019 07:38:19 +0000 Subject: [PATCH 68/71] print cleanup --- diff --git a/accept.py b/accept.py index 613f325..18a1c49 100644 --- a/accept.py +++ b/accept.py @@ -111,7 +111,7 @@ def accept(args): value = args.issue for x in value: # iteratingover name space object try: - print(x) + #print(x) """ The conversion of X to string below is because to maintin indivual convert @@ -124,7 +124,7 @@ def accept(args): """ issuel = [] issuel.append(x) - print(issuel) + #print(issuel) userstoryid, conversion = convert.convert(issuel, configpath) if conversion == True: print("Sucessfully Converted Issue to User story") diff --git a/bz/bugs.py b/bz/bugs.py index 1345cf4..35b7c2c 100644 --- a/bz/bugs.py +++ b/bz/bugs.py @@ -26,7 +26,7 @@ def post_bug(createinfo, bzapi, config): if not bzapi.logged_in: print("This example requires cached login credentials for %s" % url) bzapi.interactive_login() - print(createinfo) + #print(createinfo) newbug = bzapi.createbug(createinfo) #print(newbug) return newbug @@ -51,7 +51,7 @@ def post_bug(createinfo, bzapi, config): def get_bug(bugid, bzapi, config): if not bzapi.logged_in: bzapi.interactive_login() - print(bugid) + #print(bugid) bug = bzapi.getbug(bugid) return bug """ diff --git a/bz/pgba.py b/bz/pgba.py index d77b4da..6424fb6 100644 --- a/bz/pgba.py +++ b/bz/pgba.py @@ -26,10 +26,10 @@ def pgtobz(value, userstoryid, configpath): for x in value: # iteratingover name space object try: issueurl, r = tgaissue.get_issue(x, config) # x is user story refrence id - print(r) + #print(r) if r.status_code == 200: data = json.loads(r.content) - print(data, "this is user story data") + #print(data, "this is user story data") details = data['description'] subject = data['subject'] taiga_issue_id = data['id'] @@ -52,11 +52,11 @@ def pgtobz(value, userstoryid, configpath): system_wide_change = data['attributes_values']['11370'] relengticket = data['attributes_values']['11371'] fedora_version = data['attributes_values']['11383'] - print(bugzilla_id) - print("this step") + #print(bugzilla_id) + #print("this step") bzid = list(bugzilla_id.split(', ')) - print(bzid) - print(bugzilla_id, " This is bugzilla_id") + #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" @@ -110,10 +110,10 @@ def pgtobz(value, userstoryid, configpath): 'title': title, 'issue_content': issue_text } - print(title, payload) + #print(title, payload) repo = config['PAGURE']['RELEASE_NOTES_REPO'] r = pgaissues.post_issue(payload, repo, config) - print(r) + #print(r) if r.status_code == 200: print("Sucessful creation of issue on pagure release notes") return True diff --git a/mail/climail.py b/mail/climail.py index 1b0a38d..4afffe3 100644 --- a/mail/climail.py +++ b/mail/climail.py @@ -58,13 +58,13 @@ def mails(args): reciver = config['EMAIL']['LIST'] log = config['LOG']['LOCATION'] setup_logging_to_file(log) - print(args) + #print(args) value = args.ml for x in value: #for x in value: #ref = input("input the issue no you want to announce: ") try: - print(x) + #print(x) r = issues.get_issue(x, config) if r.status_code == 200: data = json.loads(r.content) diff --git a/mail/maillist.py b/mail/maillist.py index 014b09c..e510dc4 100644 --- a/mail/maillist.py +++ b/mail/maillist.py @@ -48,13 +48,13 @@ def email_send(subject, replyto, config): The answer below the selected/chosen answer """ reciver_emaillist = json.loads(config.get("EMAIL", "LIST")) - print(type(reciver_emaillist)) + #print(type(reciver_emaillist)) #reciver_email = ['manas.man95@gmail.com', 'ttim3886@gmail.com'] #reciver_email = reciver_email.split(',') reciver_email = ', '.join(reciver_emaillist) #reciver_email = reciver - print(type(reciver_email)) - print(reciver_email) + #print(type(reciver_email)) + #print(reciver_email) #reciver_email = ', '.join(reciver) #print(reciver_email) # Enter receiver address """ @@ -66,20 +66,20 @@ def email_send(subject, replyto, config): """ username = keyring.get_password(service_id, "email_username") password = keyring.get_password(service_id, username) - print(password, "this is pass") + #print(password, "this is pass") try: msg = MIMEMultipart() msg['To'] = reciver_emails msg['From'] = username msg['Subject'] = subject - print("this step") + #print("this step") if replyto == True: msg.add_header('reply-to', reciver_email) elif replyto == False: msg.add_header('reply-to', reciver_emaillist[0]) with open("mail.txt", "r") as m_text: data = m_text.read()#.replace('\n', '') - print(data) + #print(data) msg.attach(MIMEText(data, "plain")) # This message is sent from Python.""" context = ssl.create_default_context() diff --git a/pgure/fesco.py b/pgure/fesco.py index 01f7c0f..9035469 100644 --- a/pgure/fesco.py +++ b/pgure/fesco.py @@ -35,7 +35,7 @@ def fesissue(args): 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") + #print(data, "this is user story data") details = data['description'] subject = data['subject'] taiga_issue_id = data['id'] @@ -58,10 +58,10 @@ def fesissue(args): system_wide_change = data['attributes_values']['11370'] relengticket = data['attributes_values']['11371'] fedora_version = data['attributes_values']['11383'] - print("this step") + #print("this step") bzid = list(bugzilla_id.split(', ')) - print(bzid) - print(bugzilla_id, " This is bugzilla_id") + #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" @@ -78,15 +78,15 @@ def fesissue(args): elif system_wide_change == False: syschange = "Self-Contained Change" title = "F" + str(fedora_version) + ' ' + str(syschange) + ':' + str(subject) - print(issue_text) + #print(issue_text) payload = { 'title': title, 'issue_content': issue_text } - print(title, payload) + #print(title, payload) repo = config['PAGURE']['FESCO_REPO'] r = pgaissues.post_issue(payload, repo, config) - print(r) + #print(r) if r.status_code == 200: payload = { 'status': config['TAIGA']['ISSUE_STATUS_READY_FOR_FESCO'], diff --git a/pgure/issues.py b/pgure/issues.py index 86e8162..6203ca0 100644 --- a/pgure/issues.py +++ b/pgure/issues.py @@ -72,11 +72,11 @@ def post_issue(payload, repo, config): 'Content-Type': 'application/json', 'Authorization': 'token {0}'.format(keyring.get_password(config['PAGURE']['SERVICE_ID'], repo)) } - print(headers) + #print(headers) url = str(config['PAGURE']['API_URL']) + repo + '/new_issue' #print(data) # debug only - print(url) - print(payload) + #print(url) + #print(payload) r = requests.post( url, data=json.dumps(payload), diff --git a/tga/convert.py b/tga/convert.py index 52e7d6c..0af1f18 100644 --- a/tga/convert.py +++ b/tga/convert.py @@ -42,7 +42,7 @@ def convert(value, configpath): #value = args.taiga for x in value: try: - print(x,"this is x") + #print(x,"this is x") issueurl, r = tgaissue.get_issue(x, config) # gets the issue if r.status_code == 200: data = json.loads(r.content) @@ -52,10 +52,10 @@ def convert(value, configpath): issue_id = data['id'] issue_ref = data['ref'] issue_version = data['version'] - print(issue_version, "this is issue version") - print("this is issue version") # fetch the id as well + #print(issue_version, "this is issue version") + #print("this is issue version") # fetch the id as well #print(issue_id) - print("Step 1") + #print("Step 1") """ try: Because issue id is required to get custom attributes @@ -77,8 +77,8 @@ def convert(value, configpath): r = tgaissue.caget_issue(issue_id, config) if r.status_code == 200: data = json.loads(r.content) - print(r.content) - print(data, "step 2") + #print(r.content) + #print(data, "step 2") #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'][config['TAIGA']['ISSUE_CA_SUMMARY']] # ['11372'] @@ -92,10 +92,10 @@ def convert(value, configpath): system_wide_change = data['attributes_values'][config['TAIGA']['ISSUE_CA_SYSTEM_WIDE_CHANGE']]#['11370'] relengticket = data['attributes_values'][config['TAIGA']['ISSUE_CA_RELENG_TICKET']]#['11371'] fedora_version = data['attributes_values'][config['TAIGA']['ISSUE_CA_VERSION']]#['11383'] - print(fedora_version) + #print(fedora_version) #print("summary", summary) #print(bugzilla_id) - print("Fetched Custom Attributes") + #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 @@ -123,12 +123,12 @@ def convert(value, configpath): data = json.loads(r.content) #print(r.status_code) if r.status_code == 201: - print("step 3") + #print("step 3") data = json.loads(r.content) userstoryid = data['id'] userstoryref = data['ref'] userstory_version = data['version'] - print(id) + #print(id) issueurl = str(config['TAIGA']['PROJECT_WEB_URL']) + str(config['TAIGA']['PROJECT_WEB_NAME']) +'/issue/'+ str(issue_ref) payload = { "attributes_values": { @@ -149,10 +149,10 @@ def convert(value, configpath): }, "version": userstory_version } - print(payload) + #print(payload) r = tgauserstory.post_usca(payload, userstoryid, config) - print(json.loads(r.content)) - print(r.status_code) + #print(json.loads(r.content)) + #print(r.status_code) if r.status_code == 200: print("Sucessfully mapped issue custom attirbutes to userstory") try: @@ -166,7 +166,7 @@ def convert(value, configpath): break r = tgaepic.post_relatedus(userstoryid, epicid, epicref, config) - print(r.content, r.status_code) + #print(r.content, r.status_code) if r.status_code == 201: data = json.loads(r.content) print("Sucessfully mapped epics") @@ -175,12 +175,12 @@ def convert(value, configpath): 'version': userstory_version } r = tgauserstory.changestatus_userstory(userstoryid, payload, config) - print(r.content,r.status_code) + #print(r.content,r.status_code) if r.status_code == 200: userstoryurl = str(config['TAIGA']['PROJECT_WEB_URL']) + str(config['TAIGA']['PROJECT_WEB_NAME']) +'/us/'+ str(userstoryref) issue_version = issue_version # + 1 - print(type(issue_version)) - print(issue_version) + #print(type(issue_version)) + #print(issue_version) payload = { 'version': issue_version, "comment": userstoryurl @@ -196,8 +196,8 @@ def convert(value, configpath): 'version': issue_version } r = tgaissue.changestatus_issue(issue_id, payload, config) - print(r.status_code) - print(r.content) + #print(r.status_code) + #print(r.content) if r.status_code == 200: print("Sucessfully closed issue") return userstoryid, True diff --git a/tga/epics.py b/tga/epics.py index 042ada6..e3d1554 100644 --- a/tga/epics.py +++ b/tga/epics.py @@ -40,7 +40,7 @@ def list_epic(config): 'Authorization': 'Bearer {0}'.format(keyring.get_password(config['TAIGA']['SERVICE_TOKEN'], "taiga_token")) } url = str(config['TAIGA']['TAIGA_URL']) + "/api/v1/epics?project=" + str(config['TAIGA']['PROJECT_ID']) - print(url) + #print(url) r = requests.get( url, headers=headers diff --git a/tga/issues.py b/tga/issues.py index 496434b..6c0c467 100644 --- a/tga/issues.py +++ b/tga/issues.py @@ -37,7 +37,7 @@ def list_issue(args): config = configparser.ConfigParser() config.read(configpath) url = str(config['TAIGA']['TAIGA_URL']) + "/api/v1/issues?project=" + config['TAIGA']['PROJECT_ID'] + "&status=" + str(config['TAIGA']['ISSUE_STATUS_NEW']) - print(url) # Debug only + #print(url) # Debug only headers = { 'Content-Type': 'application/json', 'Authorization': 'Bearer {0}'.format(keyring.get_password(config['TAIGA']['SERVICE_TOKEN'], "taiga_token")) @@ -53,19 +53,19 @@ def list_issue(args): table.field_names = ["refrence no", "subject", "fedora-version"] data = json.loads(r.content) for item in data: - print(item) + #print(item) due_date = item['due_date'] issueid = item['id'] issueref= item['ref'] subject = item['subject'] version = item['version'] - print(issueref) + #print(issueref) r = caget_issue(issueid, config) if r.status_code == 200: cadata = json.loads(r.content) version = cadata['attributes_values'][config['TAIGA']['ISSUE_CA_VERSION']] #['11383'] else: - print("Error fetching Fedora Version") + print("Error fetching Fedora Version,check logs for errors") """ for item in data['owner_extra_info']: print(item) @@ -75,7 +75,7 @@ def list_issue(args): print(table) else: print("Unable to fetch list check logs") - print(r.content) + #print(r.content) except requests.exceptions.RequestException as e: print(e) log_exception(e) @@ -100,8 +100,8 @@ def get_issue(x, config): # 'Authorization': 'Bearer {0}'.format(str(123)) } url = str(config['TAIGA']['TAIGA_URL']) + "/api/v1/issues/by_ref?ref=" + str(x) + "&project=" + str(config['TAIGA']['PROJECT_ID']) - print(headers) - print(url) # debug/dev env only + #print(headers) + #print(url) # debug/dev env only r = requests.get( url, headers=headers @@ -126,9 +126,9 @@ def caget_issue(x, config): 'Authorization': 'Bearer {0}'.format(keyring.get_password(config['TAIGA']['SERVICE_TOKEN'], "taiga_token")) # 'Authorization': 'Bearer {0}'.format(str(123)) } - print(x) + #print(x) id_url = str(config['TAIGA']['TAIGA_URL']) + "/api/v1/issues/custom-attributes-values/" + str(x) # x is issue id - print(id_url) + #print(id_url) try: r = requests.get( id_url, @@ -149,7 +149,7 @@ def capatch_issue(x, payload, config): 'Authorization': 'Bearer {0}'.format(keyring.get_password(config['TAIGA']['SERVICE_TOKEN'], "taiga_token")) # 'Authorization': 'Bearer {0}'.format(str(123)) } - print(x) + #print(x) id_url = str(config['TAIGA']['TAIGA_URL']) + "/api/v1/issues/custom-attributes-values/" + str(x) r = request.patch( id_url, @@ -211,7 +211,7 @@ def edit_issue(x, id, config): data=json.dumps(x), headers=headers ) - print(json.loads(r.content)) + #print(json.loads(r.content)) return r except requests.exceptions.RequestException as e: print(e) @@ -232,7 +232,7 @@ def post_issue(x, config): data=json.dumps(x), headers=headers ) - print(json.loads(r.content)) + #print(json.loads(r.content)) return r except Exception as e: print(e) diff --git a/tga/taiga_auth.py b/tga/taiga_auth.py index d772c92..c6d748a 100644 --- a/tga/taiga_auth.py +++ b/tga/taiga_auth.py @@ -49,20 +49,20 @@ def refresh_token(args): project_id = config['TAIGA']['PROJECT_ID'] taiga_url = config['TAIGA']['TAIGA_URL'] username = keyring.get_password(service_id, "taiga_username") - print(username) # debug only + #print(username) # debug only payload = { 'type': 'normal', 'username': username, 'password': keyring.get_password(service_id, username) } - print(payload) # only for debugging + #print(payload) # only for debugging try: r = requests.post( str(taiga_url) + "/api/v1/auth", data=json.dumps(payload), headers=headers) - print(r.status_code) + #print(r.status_code) if r.status_code == 200: """ with open('auth.txt', 'w') as a_file: @@ -72,8 +72,9 @@ def refresh_token(args): keyring.set_password(service_token, "taiga_token", r.json()['auth_token']) print("succesful authentication") except (keyring.errors.PasswordSetError, Exception) as e: - print("Failed to set auth token") - print(e) + print("Failed to set auth token,check log for errors") + #print(e) + log_exception(e) elif r.status_code == 400: print("auth error") except requests.exceptions.RequestException as e: @@ -113,7 +114,7 @@ def reset(args): password = binascii.hexlify(os.urandom(20)) # ranomising pass to avoid sneak memory attacks print("Password reset succesfully") except (keyring.errors.PasswordSetError, Exception) as e: - print("Failed to reset password") + print("Failed to reset password check log for errors") log_exception(e) except Exception as e: print(e) diff --git a/tga/userstory.py b/tga/userstory.py index 901d8f0..350fe98 100644 --- a/tga/userstory.py +++ b/tga/userstory.py @@ -39,17 +39,17 @@ def list_us(args): 'Authorization': 'Bearer {0}'.format(keyring.get_password(config['TAIGA']['SERVICE_TOKEN'], "taiga_token")) # 'Authorization': 'Bearer {0}'.format(str(123)) } - print(headers) + #print(headers) url = str(config['TAIGA']['TAIGA_URL']) + "/api/v1/userstories?project=" + str(config['TAIGA']['PROJECT_ID']) + "&status=" + str(config['TAIGA']['USERSTORY_STATUS_NEW']) #url = "https://api.taiga.io/api/v1/issues?project=325667\&status=2283176" - print(url) # Debug only + #print(url) # Debug only try: r = requests.get( url, headers=headers ) if r.status_code == 200: - print(r.status_code) + #print(r.status_code) table = PrettyTable() table.field_names = ["refrence no", "subject", "fedora-version"] data = json.loads(r.content) @@ -70,12 +70,12 @@ def list_us(args): """ table.add_row([USERSTORY_ref, subject, version]) #print(USERSTORY_id, USERSTORY_ref owner) - print(table) + #print(table) else: - print(r.content) + print("check logs for error,unable to process") except requests.exceptions.RequestException as e: print(e) - print(r.content) + #print(r.content) log_exception(e) except Exception as e: print(e) @@ -99,7 +99,7 @@ def get_us(usid, config): #url = str(config['TAIGA']['TAIGA_URL']) + "/api/v1/userstories/by_ref?ref=" + str(refusid) + "\&project=" + str(config['TAIGA']['PROJECT_ID']) #url = "https://api.taiga.io/api/v1/issues?project=325667\&status=2283176" url = str(config['TAIGA']['TAIGA_URL']) + "/api/v1/userstories/" + str(usid) - print(url) # debug only + #print(url) # debug only r = requests.get( url, headers=headers @@ -181,7 +181,7 @@ def post_usca(x, id, config): data=json.dumps(x), headers=headers ) - print(json.loads(r.content)) + #print(json.loads(r.content)) return r except requests.exceptions.RequestException as e: print(e) diff --git a/update.py b/update.py index f6a15a9..1ce1c7f 100644 --- a/update.py +++ b/update.py @@ -50,7 +50,7 @@ def sync(x, config): data = json.loads(r.content) #print(data) for i in data: - print(i['subject']) + #print(i['subject']) if int(i['subject']) == x: epicid = i['id'] epicref = i['ref'] @@ -62,7 +62,7 @@ def sync(x, config): data = json.loads(r.content) for i in data: userstoryid = i['user_story'] - print(userstoryid) + #print(userstoryid) try: r = tgauserstory.get_us(userstoryid, config) if r.status_code == 200: @@ -73,7 +73,7 @@ def sync(x, config): userstorycadata = json.loads(r.content) bztracker = userstorycadata['attributes_values'][config['TAIGA']['USERSTORY_CA_BUGZILLA_TRACKER']] bugid = urlparse(bztracker).query.lstrip("id=") - print(bugid) + #print(bugid) bug = bzbugs.get_bug(bugid, bzapi, config) if bug.status == 'MODIFIED': statusid = config['TAIGA']['USERSTORY_STATUS_TESTABLE'] @@ -129,7 +129,7 @@ def report(x,config): data = json.loads(r.content) #print(data) for i in data: - print(i['subject']) + #print(i['subject']) if int(i['subject']) == x: epicid = i['id'] epicref = i['ref'] @@ -140,7 +140,7 @@ def report(x,config): data = json.loads(r.content) for i in data: userstoryid = i['user_story'] - print(userstoryid) + #print(userstoryid) try: r = tgauserstory.get_us(userstoryid, config) if r.status_code == 200: @@ -159,7 +159,7 @@ def report(x,config): type = userstorycadata['attributes_values'][config['TAIGA']['USERSTORY_CA_SYSTEM_WIDE_CHANGE']] status = userstorydata['status_extra_info']['name'] subject = userstorydata['subject'] - print(type, "this is type") + #print(type, "this is type") #record['Updated'] = page.get("last updated") status = userstorydata['status'] @@ -204,14 +204,14 @@ def report(x,config): #print(changes) try: templateLoader = jinja2.FileSystemLoader(searchpath="./" ) - print("this step first before that") + #print("this step first before that") templateEnv = jinja2.Environment( loader=templateLoader ) template = templateEnv.get_template("tplate1.html") - print("this step") + #print("this step") templateVars = {'changes': changes, 'fedoraversion': x} - print(templateVars) + #print(templateVars) outputText = template.render(templateVars) - print(outputText) + #print(outputText) with open("test.html", "w") as rhtml: rhtml.write(outputText) except Exception as e: From b68af0bf262316a8358a74b034991edca5a0e694 Mon Sep 17 00:00:00 2001 From: pac23 <manasmangaonkar@gmail.com> Date: Aug 20 2019 11:40:04 +0000 Subject: [PATCH 69/71] added check for already converted proposals --- diff --git a/tga/convert.py b/tga/convert.py index 0af1f18..e708876 100644 --- a/tga/convert.py +++ b/tga/convert.py @@ -44,7 +44,7 @@ def convert(value, configpath): try: #print(x,"this is x") issueurl, r = tgaissue.get_issue(x, config) # gets the issue - if r.status_code == 200: + if r.status_code == 200 : data = json.loads(r.content) print(data, "this is issue data") details = data['description'] @@ -77,148 +77,151 @@ def convert(value, configpath): r = tgaissue.caget_issue(issue_id, config) if r.status_code == 200: data = json.loads(r.content) - #print(r.content) - #print(data, "step 2") - #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'][config['TAIGA']['ISSUE_CA_SUMMARY']] # ['11372'] - bugzilla_id = data['attributes_values'][config['TAIGA']['ISSUE_CA_BUGZILLA_CONTACT']] # ['11373'] - approval_required = data['attributes_values'][config['TAIGA']['ISSUE_CA_TRADEMARK_APPROVAL']] #['11374'] - owners = data['attributes_values'][config['TAIGA']['ISSUE_CA_OWNERS']]#['11375'] - contingency_deadline = data['attributes_values'][config['TAIGA']['ISSUE_CA_CONTINGENCY']]#['11376'] - mass_rebuild = data['attributes_values'][config['TAIGA']['ISSUE_CA_MASS_REBUILD']]#['11377'] - policy_change = data['attributes_values'][config['TAIGA']['ISSUE_CA_POLICY_CHANGE']]#['11378'] - modifies_deliverables = data['attributes_values'][config['TAIGA']['ISSUE_CA_MODIFIES_DELIVERABLES']]#['11379'] - system_wide_change = data['attributes_values'][config['TAIGA']['ISSUE_CA_SYSTEM_WIDE_CHANGE']]#['11370'] - relengticket = data['attributes_values'][config['TAIGA']['ISSUE_CA_RELENG_TICKET']]#['11371'] - fedora_version = data['attributes_values'][config['TAIGA']['ISSUE_CA_VERSION']]#['11383'] - #print(fedora_version) - #print("summary", summary) - #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': project_id, - 'description': details, - 'subject': subject - } - #print(payload) - r = tgauserstory.post_us(payload, config) - #print(json.loads(r.content)) - data = json.loads(r.content) - #print(r.status_code) - if r.status_code == 201: - #print("step 3") - data = json.loads(r.content) - userstoryid = data['id'] - userstoryref = data['ref'] - userstory_version = data['version'] - #print(id) - issueurl = str(config['TAIGA']['PROJECT_WEB_URL']) + str(config['TAIGA']['PROJECT_WEB_NAME']) +'/issue/'+ str(issue_ref) + if data['status'] == config['TAIGA']['ISSUE_STATUS_PROCESSED'] + print("Already processed") + else: + #print(r.content) + #print(data, "step 2") + #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'][config['TAIGA']['ISSUE_CA_SUMMARY']] # ['11372'] + bugzilla_id = data['attributes_values'][config['TAIGA']['ISSUE_CA_BUGZILLA_CONTACT']] # ['11373'] + approval_required = data['attributes_values'][config['TAIGA']['ISSUE_CA_TRADEMARK_APPROVAL']] #['11374'] + owners = data['attributes_values'][config['TAIGA']['ISSUE_CA_OWNERS']]#['11375'] + contingency_deadline = data['attributes_values'][config['TAIGA']['ISSUE_CA_CONTINGENCY']]#['11376'] + mass_rebuild = data['attributes_values'][config['TAIGA']['ISSUE_CA_MASS_REBUILD']]#['11377'] + policy_change = data['attributes_values'][config['TAIGA']['ISSUE_CA_POLICY_CHANGE']]#['11378'] + modifies_deliverables = data['attributes_values'][config['TAIGA']['ISSUE_CA_MODIFIES_DELIVERABLES']]#['11379'] + system_wide_change = data['attributes_values'][config['TAIGA']['ISSUE_CA_SYSTEM_WIDE_CHANGE']]#['11370'] + relengticket = data['attributes_values'][config['TAIGA']['ISSUE_CA_RELENG_TICKET']]#['11371'] + fedora_version = data['attributes_values'][config['TAIGA']['ISSUE_CA_VERSION']]#['11383'] + #print(fedora_version) + #print("summary", summary) + #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 = { - "attributes_values": { - config['TAIGA']['USERSTORY_CA_SYSTEM_WIDE_CHANGE']: system_wide_change, - config['TAIGA']['USERSTORY_CA_SUMMARY']: summary, - config['TAIGA']['USERSTORY_CA_RELENG_TICKET']: relengticket, - config['TAIGA']['USERSTORY_CA_TRADEMARK_APPROVAL']: approval_required, - #config['TAIGA']['USERSTORY_CA_OWNERS']: owners, - config['TAIGA']['USERSTORY_CA_FESCO_TICKET']: 'random', - config['TAIGA']['USERSTORY_CA_BUGZILLA_TRACKER']: 'random', - config['TAIGA']['USERSTORY_CA_BUGZILLA_CONTACT']: bugzilla_id, - config['TAIGA']['USERSTORY_CA_RELEASE_NOTES']: 'random', - config['TAIGA']['USERSTORY_CA_CONTINGENCY']: contingency_deadline, - config['TAIGA']['USERSTORY_CA_MASS_REBUILD']: mass_rebuild, - config['TAIGA']['USERSTORY_CA_POLICY_CHANGE']: policy_change, - config['TAIGA']['USERSTORY_CA_MODIFIES_DELIVERABLES']: modifies_deliverables, - config['TAIGA']['USERSTORY_CA_ISSUE_LINK']: issueurl - }, - "version": userstory_version + 'project': project_id, + 'description': details, + 'subject': subject } #print(payload) - r = tgauserstory.post_usca(payload, userstoryid, config) + r = tgauserstory.post_us(payload, config) #print(json.loads(r.content)) + data = json.loads(r.content) #print(r.status_code) - if r.status_code == 200: - print("Sucessfully mapped issue custom attirbutes to userstory") - try: - r = tgaepic.list_epic(config) - data = json.loads(r.content) - if r.status_code == 200: - for i in data: - if i['subject'] == str(fedora_version): - epicid = i['id'] - epicref = i['ref'] - break - - r = tgaepic.post_relatedus(userstoryid, epicid, epicref, config) - #print(r.content, r.status_code) - if r.status_code == 201: + if r.status_code == 201: + #print("step 3") + data = json.loads(r.content) + userstoryid = data['id'] + userstoryref = data['ref'] + userstory_version = data['version'] + #print(id) + issueurl = str(config['TAIGA']['PROJECT_WEB_URL']) + str(config['TAIGA']['PROJECT_WEB_NAME']) +'/issue/'+ str(issue_ref) + payload = { + "attributes_values": { + config['TAIGA']['USERSTORY_CA_SYSTEM_WIDE_CHANGE']: system_wide_change, + config['TAIGA']['USERSTORY_CA_SUMMARY']: summary, + config['TAIGA']['USERSTORY_CA_RELENG_TICKET']: relengticket, + config['TAIGA']['USERSTORY_CA_TRADEMARK_APPROVAL']: approval_required, + #config['TAIGA']['USERSTORY_CA_OWNERS']: owners, + config['TAIGA']['USERSTORY_CA_FESCO_TICKET']: 'random', + config['TAIGA']['USERSTORY_CA_BUGZILLA_TRACKER']: 'random', + config['TAIGA']['USERSTORY_CA_BUGZILLA_CONTACT']: bugzilla_id, + config['TAIGA']['USERSTORY_CA_RELEASE_NOTES']: 'random', + config['TAIGA']['USERSTORY_CA_CONTINGENCY']: contingency_deadline, + config['TAIGA']['USERSTORY_CA_MASS_REBUILD']: mass_rebuild, + config['TAIGA']['USERSTORY_CA_POLICY_CHANGE']: policy_change, + config['TAIGA']['USERSTORY_CA_MODIFIES_DELIVERABLES']: modifies_deliverables, + config['TAIGA']['USERSTORY_CA_ISSUE_LINK']: issueurl + }, + "version": userstory_version + } + #print(payload) + r = tgauserstory.post_usca(payload, userstoryid, config) + #print(json.loads(r.content)) + #print(r.status_code) + if r.status_code == 200: + print("Sucessfully mapped issue custom attirbutes to userstory") + try: + r = tgaepic.list_epic(config) data = json.loads(r.content) - print("Sucessfully mapped epics") - payload = { - 'status': config['TAIGA']['USERSTORY_STATUS_ACCEPTED'], - 'version': userstory_version - } - r = tgauserstory.changestatus_userstory(userstoryid, payload, config) - #print(r.content,r.status_code) if r.status_code == 200: - userstoryurl = str(config['TAIGA']['PROJECT_WEB_URL']) + str(config['TAIGA']['PROJECT_WEB_NAME']) +'/us/'+ str(userstoryref) - issue_version = issue_version # + 1 - #print(type(issue_version)) - #print(issue_version) + for i in data: + if i['subject'] == str(fedora_version): + epicid = i['id'] + epicref = i['ref'] + break + + r = tgaepic.post_relatedus(userstoryid, epicid, epicref, config) + #print(r.content, r.status_code) + if r.status_code == 201: + data = json.loads(r.content) + print("Sucessfully mapped epics") payload = { - 'version': issue_version, - "comment": userstoryurl - } - r = tgaissue.edit_issue(payload, issue_id, config) - if r.status_code == 200: - data = json.loads(r.content) - issue_version = data['version'] - print("Sucessfully converted issue to user story") - issue_version = issue_version #+1 + 'status': config['TAIGA']['USERSTORY_STATUS_ACCEPTED'], + 'version': userstory_version + } + r = tgauserstory.changestatus_userstory(userstoryid, payload, config) + #print(r.content,r.status_code) + if r.status_code == 200: + userstoryurl = str(config['TAIGA']['PROJECT_WEB_URL']) + str(config['TAIGA']['PROJECT_WEB_NAME']) +'/us/'+ str(userstoryref) + issue_version = issue_version # + 1 + #print(type(issue_version)) + #print(issue_version) payload = { - 'status': config['TAIGA']['ISSUE_STATUS_PROCESSED'], - 'version': issue_version - } - r = tgaissue.changestatus_issue(issue_id, payload, config) - #print(r.status_code) - #print(r.content) - if r.status_code == 200: - print("Sucessfully closed issue") - return userstoryid, True + 'version': issue_version, + "comment": userstoryurl + } + r = tgaissue.edit_issue(payload, issue_id, config) + if r.status_code == 200: + data = json.loads(r.content) + issue_version = data['version'] + print("Sucessfully converted issue to user story") + issue_version = issue_version #+1 + payload = { + 'status': config['TAIGA']['ISSUE_STATUS_PROCESSED'], + 'version': issue_version + } + r = tgaissue.changestatus_issue(issue_id, payload, config) + #print(r.status_code) + #print(r.content) + if r.status_code == 200: + print("Sucessfully closed issue") + return userstoryid, True + else: + print("Unsuccesful at closing issue,check logs") else: - print("Unsuccesful at closing issue,check logs") + print("Unable to map Issue url to user story attributes") else: - print("Unable to map Issue url to user story attributes") + print("Converted User story,copied attributes mapped epics,faliure to change status to accepted") else: - print("Converted User story,copied attributes mapped epics,faliure to change status to accepted") - else: - print("Unnsucessful to map to epics,change user story status to accepted and issue status to processed") - except requests.exceptions.RequestException as e: - print(e) - log_exception(e) - except Exception as e: - print(e) - log_exception(e) + print("Unnsucessful to map to epics,change user story status to accepted and issue status to processed") + except requests.exceptions.RequestException as e: + print(e) + log_exception(e) + except Exception as e: + print(e) + log_exception(e) + else: + print("Unsuccesful Conversion") else: - print("Unsuccesful Conversion") - else: - print("Unsuccesful conversion") + print("Unsuccesful conversion") except requests.exceptions.RequestException as e: print(e) log_exception(e) From 6a1c56623d438efa28db9f1c11463cae900e6c2b Mon Sep 17 00:00:00 2001 From: pac23 <manasmangaonkar@gmail.com> Date: Aug 20 2019 11:41:16 +0000 Subject: [PATCH 70/71] updated config for final board --- diff --git a/config.ini b/config.ini index d2c7134..5ecced9 100644 --- a/config.ini +++ b/config.ini @@ -8,50 +8,50 @@ TAIGA_SITE_ISSUE_URL = https://tree.taiga.io/project/pac_23-test-changes-tracker PROJECT_WEB_URL = https://tree.taiga.io/project/ PROJECT_WEB_NAME = pac_23-test-changes-tracker-kanban -ISSUE_STATUS_NEW = 2283176 -ISSUE_STATUS_NEEDS_INFO = 2283180 -ISSSUE_STATUS_ACCEPTED = 2302390 -ISSUE_STATUS_ANNOUNCED = 2302389 -ISSUE_STATUS_READY_FOR_WRANGLER = 2283232 -ISSUE_STATUS_READY_FOR_FESCO = 2295359 -ISSUE_STATUS_PROCESSED = 2283182 -USERSTORY_STATUS_NEW = 1952887 -USERSTORY_STATUS_ANNOUNCED = 1952888 -USERSTORY_STATUS_R_FESCO = 1952889 -USERSTORY_STATUS_ACCEPTED = 1952891 -USERSTORY_STATUS_ARCHIVED = 1952890 -USERSTORY_STATUS_CODE_COMPLETE = 1892839 -USERSTORY_STATUS_TESTABLE = 1952932 +ISSUE_STATUS_NEW = 254 +ISSUE_STATUS_NEEDS_INFO = 255 +ISSSUE_STATUS_ACCEPTED = 295 +ISSUE_STATUS_ANNOUNCED = 258 +ISSUE_STATUS_READY_FOR_WRANGLER = 256 +ISSUE_STATUS_READY_FOR_FESCO = 259 +ISSUE_STATUS_PROCESSED = 257 +USERSTORY_STATUS_NEW = 235 +USERSTORY_STATUS_ANNOUNCED = 267 +USERSTORY_STATUS_R_FESCO = 266 +USERSTORY_STATUS_ACCEPTED = 231 +USERSTORY_STATUS_ARCHIVED = 232 +USERSTORY_STATUS_CODE_COMPLETE = 233 +USERSTORY_STATUS_TESTABLE = 234 -ISSUE_CA_SYSTEM_WIDE_CHANGE = 11370 -ISSUE_CA_SUMMARY = 11372 -ISSUE_CA_BUGZILLA_CONTACT = 11373 -ISSUE_CA_RELENG_TICKET = 11371 -ISSUE_CA_TRADEMARK_APPROVAL = 11374 -ISSUE_CA_OWNERS = 11375 -ISSUE_CA_FESCO_TICKET = 534454574 -ISSUE_CA_BUGZILLA_TRACKER = 21930 -ISSUE_CA_RELEASE_NOTES = 21931 -ISSUE_CA_CONTINGENCY = 11376 -ISSUE_CA_MASS_REBUILD = 11377 -ISSUE_CA_POLICY_CHANGE = 11378 -ISSUE_CA_MODIFIES_DELIVERABLES = 11379 -ISSUE_CA_VERSION = 11383 -ISSUE_CA_USERSTORY_LINK = 11431 -USERSTORY_CA_SYSTEM_WIDE_CHANGE = 21923 -USERSTORY_CA_SUMMARY = 21924 -USERSTORY_CA_BUGZILLA_CONTACT = 21925 -USERSTORY_CA_RELENG_TICKET = 21926 -USERSTORY_CA_TRADEMARK_APPROVAL = 21927 -USERSTORY_CA_OWNERS = 21928 -USERSTORY_CA_FESCO_TICKET = 21929 -USERSTORY_CA_BUGZILLA_TRACKER = 21930 -USERSTORY_CA_RELEASE_NOTES = 21931 -USERSTORY_CA_CONTINGENCY = 21932 -USERSTORY_CA_MASS_REBUILD = 21933 -USERSTORY_CA_POLICY_CHANGE = 21934 -USERSTORY_CA_MODIFIES_DELIVERABLES = 21935 -USERSTORY_CA_ISSUE_LINK = 22140 +ISSUE_CA_SYSTEM_WIDE_CHANGE = 18 +ISSUE_CA_SUMMARY = 20 +ISSUE_CA_BUGZILLA_CONTACT = 21 +ISSUE_CA_RELENG_TICKET = 19 +ISSUE_CA_TRADEMARK_APPROVAL = 22 +ISSUE_CA_OWNERS = 23 +ISSUE_CA_FESCO_TICKET = 30 +ISSUE_CA_BUGZILLA_TRACKER = 31 +ISSUE_CA_RELEASE_NOTES = 32 +ISSUE_CA_CONTINGENCY = 24 +ISSUE_CA_MASS_REBUILD = 25 +ISSUE_CA_POLICY_CHANGE = 26 +ISSUE_CA_MODIFIES_DELIVERABLES = 27 +ISSUE_CA_VERSION = 28 +ISSUE_CA_USERSTORY_LINK = 29 +USERSTORY_CA_SYSTEM_WIDE_CHANGE = 24 +USERSTORY_CA_SUMMARY = 25 +USERSTORY_CA_BUGZILLA_CONTACT = 26 +USERSTORY_CA_RELENG_TICKET = 27 +USERSTORY_CA_TRADEMARK_APPROVAL = 28 +USERSTORY_CA_OWNERS = 29 +USERSTORY_CA_FESCO_TICKET = 30 +USERSTORY_CA_BUGZILLA_TRACKER = 31 +USERSTORY_CA_RELEASE_NOTES = 32 +USERSTORY_CA_CONTINGENCY = 33 +USERSTORY_CA_MASS_REBUILD = 34 +USERSTORY_CA_POLICY_CHANGE = 35 +USERSTORY_CA_MODIFIES_DELIVERABLES = 26 +USERSTORY_CA_ISSUE_LINK = 37 ISSUE_PRIORITIES_LOW = 979360 ISSUE_PRIORITIES_NORMAL = 979361 From 89b77fbb517d624bda5715a803cd90b91a16277b Mon Sep 17 00:00:00 2001 From: pac23 <manasmangaonkar@gmail.com> Date: Aug 21 2019 17:23:51 +0000 Subject: [PATCH 71/71] moving around some test data --- diff --git a/config_depre.ini b/config_depre.ini deleted file mode 100644 index d8276f6..0000000 --- a/config_depre.ini +++ /dev/null @@ -1,82 +0,0 @@ -[TAIGA] -SERVICE_ID = taiga -SERVICE_TOKEN = taiga_auth -PROJECT_ID = 325667 -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/ -ISSUE_STATUS_NEW = 21 -ISSUE_STATUS_NEEDS_INFO = 22 -ISSUE_STATUS_READY_FOR_WRANGLER = 12 -ISSUE_STATUS_PROCESSED = 24 -ISSUE_CA_VERSION = 25 -US_STATUS_ANNOUNCED = 25 -US_STATUS_R_FESCO = 30 -US_STATUS_ACCEPTED = 31 -US_STATUS_ARCHIVED = 32 -US_STATUS_CODE_COMPLETE = 33 -US_STATUS_TESTABLE = 34 - -TEST_ISSUE_STATUS_NEW = 2283176 -TEST_ISSUE_STATUS_NEEDS_INFO = 2283180 -TEST_ISSUE_STATUS_READY_FOR_WRANGLER = 2283232 -TEST_ISSUE_STATUS_PROCESSED = 2283182 -TEST_US_STATUS_NEW = 1952887 -TEST_US_STATUS_ANNOUNCED = 1952888 -TEST_US_STATUS_R_FESCO = 1952889 -TEST_US_STATUS_ACCEPTED = 1952891 -TEST_US_STATUS_ARCHIVED = 1952890 -TEST_US_STATUS_CODE_COMPLETE = 1892839 -TEST_US_STATUS_TESTABLE = 1952932 - -TEST_ISSUE_CA_SYSTEM_WIDE_CHANGE = 11370 -TEST_ISSUE_CA_SUMMARY = 11372 -TEST_ISSUE_CA_BUGZILLA_CONTACT = 11373 -TEST_ISSUE_CA_RELENG_TICKET = 11371 -TEST_ISSUE_CA_TRADEMARK_APPROVAL = 11374 -TEST_ISSUE_CA_OWNERS = 11375 -TEST_ISSUE_CA_FESCO_TICKET = 534454574 -TEST_ISSUE_CA_BUGZILLA_TRACKER = 21930 -TEST_ISSUE_CA_RELEASE_NOTES = 21931 -TEST_ISSUE_CA_CONTINGENCY = 11376 -TEST_ISSUE_CA_MASS_REBUILD = 11377 -TEST_ISSUE_CA_POLICY_CHANGE = 11378 -TEST_ISSUE_CA_MODIFIES_DELIVERABLES = 11379 -TEST_ISSUE_CA_VERSION = 11383 -TEST_US_CA_SYSTEM_WIDE_CHANGE = 21923 -TEST_US_cA_SUMMARY = 21924 -TEST_US_CA_BUGZILLA_CONTACT = 21925 -TEST_US_CA_RELENG_TICKET = 21926 -TEST_US_CA_TRADEMARK_APPROVAL = 21927 -TEST_US_CA_OWNERS = 21928 -TEST_US_CA_FESCO_TICKET = 21929 -TEST_US_cA_BUGZILLA_TRACKER = 21930 -TEST_US_CA_RELEASE_NOTES = 21931 -TEST_US_CA_CONTINGENCY = 21932 -TEST_US_CA_MASS_REBUILD = 21933 -TEST_US_CA_POLICY_CHANGE = 21934 -TEST_US_CA_MODIFIES_DELIVERABLES = 21935 -TEST = yes - -[PAGURE] -SERVICE_ID = pagure - -[BUGZILLA] -SERVICE_ID = bugzilla -SERVICE_TOKEN = bugzilla_auth -project_id = 315827 # for test only -DEFAULT_BUGZILLA_URL = https://bugzilla.redhat.com/ -CUSTOM_BUGZILLA_URL = https://bugzilla.redhat.com/ -TEST = no - -[EMAIL] -SERVICE_ID = email -DEFAULT_EMAIL_ID = bcotton@redhat.org -CUSTOM_EMAIL_ID = manasmangaonkar@gmail.com -TEST_LIST: ["manas.man95@gmail.com","bcotton@redhat.org"] -LIST: [devel@lists.fedoraproject.org,devel-announce@lists.fedoraproject.org] -PORT = 465 -SMTP_SERVER = smtp.gmail.com -TEST = yes -# 1892835 - diff --git a/config_load.py b/config_load.py deleted file mode 100644 index b2b55e7..0000000 --- a/config_load.py +++ /dev/null @@ -1,34 +0,0 @@ -from configparser import SafeConfigParser -import os - - -class Config: - """Interact with configuration variables.""" - - configParser = SafeConfigParser() - configFilePath = (os.path.join(os.getcwd(), 'config.ini')) - - @classmethod - def initialize(cls, new_config): - """Start config by reading config.ini.""" - cls.configParser.read(cls.configFilePath) - - @classmethod - def taiga(cls, key): - """Get taiga values from config.ini.""" - return cls.configParser.get('TAIGA', key) - - @classmethod - def pagure(cls, key): - """Get pagure values from config.ini.""" - return cls.configParser.get('PAGURE', key) - - @classmethod - def bugzilla(cls, key): - """Get bugzilla values from config.ini""" - return cls.configParser.get('BUGZILLA', key) - - @classmethod - def email(cls, key): - """Get bugzilla values from config.ini""" - return cls.configParser.get('EMAIL', key) diff --git a/logger.py b/logger.py deleted file mode 100644 index 5b1afe7..0000000 --- a/logger.py +++ /dev/null @@ -1,28 +0,0 @@ -import sys -import traceback -import logging - -def setup_logging_to_file(filename): - logging.basicConfig( filename=filename, - filemode='a', - level=logging.DEBUG, - format= '%(asctime)s - %(levelname)s - %(message)s', - ) - -def extract_function_name(): - """Extracts failing function name from Traceback - http://stackoverflow.com/questions/2380073/\ - how-to-identify-what-function-call-raise-an-exception-in-python - """ - tb = sys.exc_info()[-1] - stk = traceback.extract_tb(tb, 1) - fname = stk[0][3] - return fname - -def log_exception(e): - logging.error( - "Function {function_name} raised {exception_class} ({exception_docstring}): {exception_message}".format( - function_name = extract_function_name(), #this is optional - exception_class = e.__class__, - exception_docstring = e.__doc__, - exception_message = e.message)) diff --git a/test.html b/test.html deleted file mode 100644 index 894f6cc..0000000 --- a/test.html +++ /dev/null @@ -1,700 +0,0 @@ - -<html> - <head> - <title>Releases//changeset - - - - - - - Fedora People - fedorapeople.org - - - - - -
- - -
-
-
- -

Fedora F 32 changeset


- -

Accepted fedora 32 System Wide Change Proposals

- - - - -

Test issue for convert to user story test

-

-

Owners

-
  • owners : -
  • -
  • Release Notes owner:
  • -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - -

test listing issues dummmy

-

test test test test test

-

Owners

-
  • owners : -
  • -
  • Release Notes owner:
  • -
-
- - - -

Overwrite test issue

-

test issue

-

Owners

-
  • owners : -
  • -
  • Release Notes owner:
  • -
-
- - - -

Test of overwrite

-

test of issue and test of issue

-

Owners

-
  • owners : -
  • -
  • Release Notes owner:
  • -
-
- - - -

OW test

-

new test

-

Owners

-
  • owners : -
  • -
  • Release Notes owner:
  • -
-
- - - -

OW test

-

test

-

Owners

-
  • owners : -
  • -
  • Release Notes owner:
  • -
-
- - - -

OW test

-

test

-

Owners

-
  • owners : -
  • -
  • Release Notes owner:
  • -
-
- - - -

test issue for versions

-

-

Owners

-
  • owners : -
  • -
  • Release Notes owner:
  • -
-
- - - -

Test Issue for link feed

-

Time:16:15 -Location : Somewhere in Mumbai,India -Objective: Test and Deploy Links -Final Objective: Complete Conversion in Tool -Test: Yes

-

Owners

-
  • owners : -
  • -
  • Release Notes owner:
  • -
-
- - - -

Test Issue for link feed

-

Time:16:15 -Location : Somewhere in Mumbai,India -Objective: Test and Deploy Links -Final Objective: Complete Conversion in Tool -Test: Yes

-

Owners

-
  • owners : -
  • -
  • Release Notes owner:
  • -
-
- - - -

Test Issue for link feed

-

Time:16:15 -Location : Somewhere in Mumbai,India -Objective: Test and Deploy Links -Final Objective: Complete Conversion in Tool -Test: Yes

-

Owners

-
  • owners : -
  • -
  • Release Notes owner:
  • -
-
- - - -

Test Issue for link feed

-

Time:16:15 -Location : Somewhere in Mumbai,India -Objective: Test and Deploy Links -Final Objective: Complete Conversion in Tool -Test: Yes

-

Owners

-
  • owners : -
  • -
  • Release Notes owner:
  • -
-
- - - -

Test Issue for link feed

-

Time:16:15 -Location : Somewhere in Mumbai,India -Objective: Test and Deploy Links -Final Objective: Complete Conversion in Tool -Test: Yes

-

Owners

-
  • owners : -
  • -
  • Release Notes owner:
  • -
-
- - - -

Test Issue for link feed

-

Time:16:15 -Location : Somewhere in Mumbai,India -Objective: Test and Deploy Links -Final Objective: Complete Conversion in Tool -Test: Yes

-

Owners

-
  • owners : -
  • -
  • Release Notes owner:
  • -
-
- - - -

Test Issue for link feed

-

Time:16:15 -Location : Somewhere in Mumbai,India -Objective: Test and Deploy Links -Final Objective: Complete Conversion in Tool -Test: Yes

-

Owners

-
  • owners : -
  • -
  • Release Notes owner:
  • -
-
- - - -

Test Issue for link feed

-

Time:16:15 -Location : Somewhere in Mumbai,India -Objective: Test and Deploy Links -Final Objective: Complete Conversion in Tool -Test: Yes

-

Owners

-
  • owners : -
  • -
  • Release Notes owner:
  • -
-
- - - -

Test Issue for link feed

-

Time:16:15 -Location : Somewhere in Mumbai,India -Objective: Test and Deploy Links -Final Objective: Complete Conversion in Tool -Test: Yes

-

Owners

-
  • owners : -
  • -
  • Release Notes owner:
  • -
-
- - - -

Accepted Fedora F 32 Self Containted Change Proposals

- - -

- Test issue for convert to user story test -

-

- The quick brown fox jumped over the lazy dog -

-

Owners

-
  • - Owner: -
  • -
  • - Release notes owner : -
- - - - - - -

- Test issue for convert to user story test -

-

- The quick brown fox jumped over the lazy dog -

-

Owners

-
  • - Owner: -
  • -
  • - Release notes owner : -
- - - - -

- Test issue for convert to user story test -

-

- The quick brown fox jumped over the lazy dog -

-

Owners

-
  • - Owner: -
  • -
  • - Release notes owner : -
- - - - -

- Test issue for convert to user story test -

-

- The quick brown fox jumped over the lazy dog -

-

Owners

-
  • - Owner: -
  • -
  • - Release notes owner : -
- - - - -

- Test issue for convert to user story test -

-

- The quick brown fox jumped over the lazy dog -

-

Owners

-
  • - Owner: -
  • -
  • - Release notes owner : -
- - - - -

- Test issue for convert to user story test -

-

- The quick brown fox jumped over the lazy dog -

-

Owners

-
  • - Owner: -
  • -
  • - Release notes owner : -
- - - - -

- Test issue for convert to user story test -

-

- The quick brown fox jumped over the lazy dog -

-

Owners

-
  • - Owner: -
  • -
  • - Release notes owner : -
- - - - -

- Test issue for convert to user story test -

-

- The quick brown fox jumped over the lazy dog -

-

Owners

-
  • - Owner: -
  • -
  • - Release notes owner : -
- - - - -

- Test issue for convert to user story test -

-

- The quick brown fox jumped over the lazy dog -

-

Owners

-
  • - Owner: -
  • -
  • - Release notes owner : -
- - - - -

- Test issue for convert to user story test -

-

- The quick brown fox jumped over the lazy dog -

-

Owners

-
  • - Owner: -
  • -
  • - Release notes owner : -
- - - - -

- Test issue for convert to user story test -

-

- The quick brown fox jumped over the lazy dog -

-

Owners

-
  • - Owner: -
  • -
  • - Release notes owner : -
- - - - -

- Test issue for convert to user story test -

-

- The quick brown fox jumped over the lazy dog -

-

Owners

-
  • - Owner: -
  • -
  • - Release notes owner : -
- - - - -

- Test issue for convert to user story test -

-

- The quick brown fox jumped over the lazy dog -

-

Owners

-
  • - Owner: -
  • -
  • - Release notes owner : -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/tplate.html b/tplate.html deleted file mode 100644 index 958d13b..0000000 --- a/tplate.html +++ /dev/null @@ -1,84 +0,0 @@ - - - - Releases/{{ fedora_version }}/changeset - - - - - - - Fedora People - fedorapeople.org - - - - - -
- - -
-
-
- -

Fedora F {{ fedoraversion }} changeset


- -

Accepted fedora {{ fedoraversion }} System Wide Change Proposals

-{% for n in changes %} - {% if n['type'] is sameas true %} -

{{ n['title'] }}

-

{{ n['summary'] }}

-

Owners

-
  • owners : {{ n['owners'] }} -
  • -
  • Release Notes owner:
  • -
-
- {% endif %} -{% endfor %} - -

Accepted Fedora F {{ fedoraversion }} Self Containted Change Proposals

-{% for n in changes %} - {% if n['type'] is sameas false %} -

- {{ n['title'] }} -

-

- {{ n['summary'] }} -

-

Owners

-
  • - Owner: {{ n['owners'] }} -
  • -
  • - Release notes owner : {{ n['release_owners'] }} -
- - {% endif %} -{% endfor %} - - \ No newline at end of file diff --git a/tplate1.html b/tplate1.html deleted file mode 100644 index a99d7c6..0000000 --- a/tplate1.html +++ /dev/null @@ -1,81 +0,0 @@ - - - - Releases/{{ fedora_version }}/changeset - - - - - - - Fedora People - fedorapeople.org - - - - - -
- - -
-
-
- -Fedora{{fedora-version }} chaneset </t> - -<h2> Accepted fedora {{ fedora-version}} System Wide Change Proposals -{% for n in changes %} - {% if n[type] == "True" %} - <h4> {{ n['title'] }} </h3> - <p> {{ n['summary'] }} </p> - <ul><li>owners : {{ n['owners'] }} </li> - <li> Release Notes owner: </li><ul> - <ul><li> - Tracking Bug : <a href="{{ Bugzilla }}"> - </a></li> - <li> - Status : {{ n[status] }} - </li></ul> - {% endif %} -{% endfor %} - -<h2>Accepted Fedora {{ fedora-version }} Self Containted Change Proposals </h2> -{% for n in changes %} - {% if n[type] == "False" %} - <h4> - {{ n['title'] }} - </h4> - <p> - {{ n['summary'] }} - </p> - <h4> Owners </h4> - <ul><li> - Owner: {{ n['owners'] }} - </li> - <li> - Release notes owner : {{ n['release_owners'] }} - </li></ul> - <ul><li> - Tracking Bug : <a href= " {{ Bugzilla }} "> - </a></li> - <li> - Status : {{ Change_Status }} - </li></ul> - {% endif %} -{% endfor %} -</body> -</html> \ No newline at end of file