From 976562a7d7a77bcea12110dc7b006dcd18cd9302 Mon Sep 17 00:00:00 2001 From: Mariatta Wijaya Date: Fri, 1 Jun 2018 21:48:22 -0700 Subject: [PATCH 1/2] [don't merge] Just to test the bot. --- black_out/tasks.py | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/black_out/tasks.py b/black_out/tasks.py index d96f980..e595064 100644 --- a/black_out/tasks.py +++ b/black_out/tasks.py @@ -8,17 +8,15 @@ app = celery.Celery("black_out") -app.conf.update( - BROKER_URL=os.environ["REDIS_URL"], CELERY_RESULT_BACKEND=os.environ["REDIS_URL"] -) +app.conf.update(BROKER_URL=os.environ["REDIS_URL"], CELERY_RESULT_BACKEND=os.environ["REDIS_URL"]) @app.task(rate_limit="1/m") def setup_repo(): - repo_name = os.environ.get("GH_REPO_NAME") - repo_full_name = os.environ.get("GH_REPO_FULL_NAME") - os.mkdir("repo_checkout") + repo_name = os.environ.get('GH_REPO_NAME') + repo_full_name = os.environ.get('GH_REPO_FULL_NAME') + os.mkdir('repo_checkout') os.chdir("repo_checkout") print(f"Setting up {repo_name} repository, cloning from {repo_full_name}") @@ -27,7 +25,7 @@ def setup_repo(): full_name = os.environ.get("GH_FULL_NAME") subprocess.check_output( [ - "git", + 'git', "clone", f"https://{os.environ.get('GH_AUTH')}:x-oauth-basic@github.com/{repo_full_name}.git", ] @@ -58,7 +56,8 @@ def initiate_black_task(issue_number, issue_creator): 7. git branch -D issue-NNNN-initialize-black """ # cd to the checked out repo, if not already there - if "repo_checkout" in os.listdir("."): + if "repo_checkout" \ + in os.listdir("."): os.chdir("repo_checkout") os.chdir(f"./{os.environ.get('GH_REPO_NAME')}") @@ -147,10 +146,13 @@ def black_pr_task(pr_number, pr_author, pr_diff_url): util.delete_branch(branch_name) -class InitRepoStep(bootsteps.StartStopStep): +class InitRepoStep( + bootsteps.StartStopStep, +): def start(self, c): print("Initialize the repository.") setup_repo() -app.steps["worker"].add(InitRepoStep) +app.steps["worker"].add( + InitRepoStep) From c952ab6ceb3102347b0723ae3302f75fffedbd81 Mon Sep 17 00:00:00 2001 From: mariatta-bot Date: Sun, 3 Jun 2018 18:25:11 -0700 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=90=8D=F0=9F=8C=9A=F0=9F=A4=96=20Form?= =?UTF-8?q?atted=20using=20`black`.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- black_out/tasks.py | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/black_out/tasks.py b/black_out/tasks.py index e595064..d96f980 100644 --- a/black_out/tasks.py +++ b/black_out/tasks.py @@ -8,15 +8,17 @@ app = celery.Celery("black_out") -app.conf.update(BROKER_URL=os.environ["REDIS_URL"], CELERY_RESULT_BACKEND=os.environ["REDIS_URL"]) +app.conf.update( + BROKER_URL=os.environ["REDIS_URL"], CELERY_RESULT_BACKEND=os.environ["REDIS_URL"] +) @app.task(rate_limit="1/m") def setup_repo(): - repo_name = os.environ.get('GH_REPO_NAME') - repo_full_name = os.environ.get('GH_REPO_FULL_NAME') - os.mkdir('repo_checkout') + repo_name = os.environ.get("GH_REPO_NAME") + repo_full_name = os.environ.get("GH_REPO_FULL_NAME") + os.mkdir("repo_checkout") os.chdir("repo_checkout") print(f"Setting up {repo_name} repository, cloning from {repo_full_name}") @@ -25,7 +27,7 @@ def setup_repo(): full_name = os.environ.get("GH_FULL_NAME") subprocess.check_output( [ - 'git', + "git", "clone", f"https://{os.environ.get('GH_AUTH')}:x-oauth-basic@github.com/{repo_full_name}.git", ] @@ -56,8 +58,7 @@ def initiate_black_task(issue_number, issue_creator): 7. git branch -D issue-NNNN-initialize-black """ # cd to the checked out repo, if not already there - if "repo_checkout" \ - in os.listdir("."): + if "repo_checkout" in os.listdir("."): os.chdir("repo_checkout") os.chdir(f"./{os.environ.get('GH_REPO_NAME')}") @@ -146,13 +147,10 @@ def black_pr_task(pr_number, pr_author, pr_diff_url): util.delete_branch(branch_name) -class InitRepoStep( - bootsteps.StartStopStep, -): +class InitRepoStep(bootsteps.StartStopStep): def start(self, c): print("Initialize the repository.") setup_repo() -app.steps["worker"].add( - InitRepoStep) +app.steps["worker"].add(InitRepoStep)