diff --git a/GoogleAPI.py b/GoogleAPI.py index 9722747..1235faa 100644 --- a/GoogleAPI.py +++ b/GoogleAPI.py @@ -31,15 +31,10 @@ def get_credentials(): # Gets valid user credentials from disk. return credentials -def send_message(sender, to, commiter_name, subject, xdelta_link): +def send_message(sender, to, subject, xdelta_link, message_text): - message_text = """ -Hi {}, -here is your xdelta patch : -{} -""".format(commiter_name, xdelta_link) credentials = get_credentials() #print (credentials) diff --git a/RepoFunctions.py b/RepoFunctions.py index a6c1529..16f31e3 100644 --- a/RepoFunctions.py +++ b/RepoFunctions.py @@ -2,6 +2,7 @@ import os import requests import json import subprocess +import pandas as pd def get_Releases(org, repo_name, latest=False): @@ -29,3 +30,38 @@ def refresh_repo(repo_name): ["git", "pull"], cwd=base_path ) + +def get_pull_requests(org, repo_name): + api_url = "https://api.github.com/repos/{}/{}/pulls?state=all".format(org, repo_name) + + header = { + "Accept":"application/vnd.github.v3+json" + } + + res = requests.get(api_url) + json_res = json.loads(res.text) + + #Taking Top 5 PR + top5 = json_res[0:5] + + return top5 + +def get_pull_requests_message(org, repo_name): + + #Get Datas + top5_prs = get_pull_requests(org, repo_name) + + message ='Here are the PRs recently : ' + + for pr in top5_prs: + + message = message + "
" + message += '{} - {} by {} ... {}'.format(pr['created_at'], pr['title'], pr['user']['login'], pr['_links']['html']['href']) + + return message + + + + + + \ No newline at end of file diff --git a/ToolsTales_Executable.py b/ToolsTales_Executable.py index 65c133b..27f36d7 100644 --- a/ToolsTales_Executable.py +++ b/ToolsTales_Executable.py @@ -186,6 +186,10 @@ if __name__ == "__main__": game_name = args.game tales_instance = getTalesInstance(game_name) + org = 'SymphoniaLauren' + repo_name = 'Tales-of-Rebirth' + + #Utility function if args.action == "utility": @@ -199,24 +203,32 @@ if __name__ == "__main__": if args.action == "pack": #RepoFunctions.refresh_repo("PythonLib") - RepoFunctions.refresh_repo("Tales-Of-Rebirth") + RepoFunctions.refresh_repo(repo_name) if args.file == "SLPS": #SLPS tales_instance.pack_Menu_File("../Data/Tales-Of-Rebirth/Disc/Original/SLPS_254.50") - ApacheAutomate.apache_job(['SLPS_254.50'], "Tales-Of-Rebirth") + ApacheAutomate.apache_job(['SLPS_254.50'], repo_name) xdelta_name = "../Data/Tales-Of-Rebirth/Disc/New/Tales-Of-Rebirth_patch.xdelta" - generate_xdelta_patch("Tales-Of-Rebirth", xdelta_name) + generate_xdelta_patch(repo_name, xdelta_name) file_link = GoogleAPI.upload_xdelta(xdelta_name, "Stewie") #Need to add user for the folder - GoogleAPI.send_message('fortiersteven1@gmail.com', 'fortiersteven1@gmail.com', "Stewie", game_name + " Patch", file_link) + message_text = """ +Hi {}, + +here is your xdelta patch : +{} +""".format('fortiersteven1@gmail.com', file_link) + + message_text = message_text + "
" + RepoFunctions.get_pull_requests_message(org, repo_name) + GoogleAPI.send_message('fortiersteven1@gmail.com', 'fortiersteven1@gmail.com', game_name + " Patch", file_link, message_text) diff --git a/__pycache__/ApacheAutomate.cpython-38.pyc b/__pycache__/ApacheAutomate.cpython-38.pyc index b6b764c..7aa62bf 100644 Binary files a/__pycache__/ApacheAutomate.cpython-38.pyc and b/__pycache__/ApacheAutomate.cpython-38.pyc differ diff --git a/__pycache__/GoogleAPI.cpython-38.pyc b/__pycache__/GoogleAPI.cpython-38.pyc index 57082b4..98d1621 100644 Binary files a/__pycache__/GoogleAPI.cpython-38.pyc and b/__pycache__/GoogleAPI.cpython-38.pyc differ diff --git a/__pycache__/RepoFunctions.cpython-38.pyc b/__pycache__/RepoFunctions.cpython-38.pyc index 0a420d2..a0747a8 100644 Binary files a/__pycache__/RepoFunctions.cpython-38.pyc and b/__pycache__/RepoFunctions.cpython-38.pyc differ diff --git a/__pycache__/ToolsTOR.cpython-38.pyc b/__pycache__/ToolsTOR.cpython-38.pyc index 01dc51b..24b84b4 100644 Binary files a/__pycache__/ToolsTOR.cpython-38.pyc and b/__pycache__/ToolsTOR.cpython-38.pyc differ diff --git a/__pycache__/ToolsTales.cpython-38.pyc b/__pycache__/ToolsTales.cpython-38.pyc index 0c9a196..b43e7fc 100644 Binary files a/__pycache__/ToolsTales.cpython-38.pyc and b/__pycache__/ToolsTales.cpython-38.pyc differ