From 9427e959f3ae3b3c932e70c8d9f2d74c5b2e976b Mon Sep 17 00:00:00 2001 From: Tony Kelman Date: Wed, 7 Feb 2018 17:27:22 -0800 Subject: [PATCH 1/2] Add an onerror handler to shutil.rmtree calls Should avoid errors such as `PermissionError: [WinError 5] Access is denied: 'C:\\Users\\akelman\\AppData\\Local\\Temp\\tmpu3fwwzf4\\botocore-feedstock\\.git\\objects\\pack\\pack-75b2092341bff03adcd15b32b752762b5801440f.idx'` --- tick_my_feedstocks.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tick_my_feedstocks.py b/tick_my_feedstocks.py index cf3aa56..412fca7 100644 --- a/tick_my_feedstocks.py +++ b/tick_my_feedstocks.py @@ -85,6 +85,7 @@ import os import re import shutil +import stat import tempfile from base64 import b64encode from collections import defaultdict @@ -547,7 +548,7 @@ def regenerate_fork(fork): if not r.is_dirty(): # No changes made during regeneration. # Clean up and return - shutil.rmtree(working_dir) + shutil.rmtree(working_dir, onerror=remove_readonly) return False commit_msg = \ @@ -558,10 +559,15 @@ def regenerate_fork(fork): author=Actor(fork.owner.login, fork.owner.email)) r.git.push() - shutil.rmtree(working_dir) + shutil.rmtree(working_dir, onerror=remove_readonly) return True +def remove_readonly(func, path, excinfo): + os.chmod(path, stat.S_IWRITE) + func(path) + + def tick_feedstocks(gh_password=None, gh_user=None, no_regenerate=False, From 0511c945b2fb8a82e33063c5ee62fbafc456dc8d Mon Sep 17 00:00:00 2001 From: Tony Kelman Date: Fri, 9 Feb 2018 10:14:34 -0800 Subject: [PATCH 2/2] move the conda_smithy imports --- tick_my_feedstocks.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tick_my_feedstocks.py b/tick_my_feedstocks.py index 412fca7..9345933 100644 --- a/tick_my_feedstocks.py +++ b/tick_my_feedstocks.py @@ -90,8 +90,6 @@ from base64 import b64encode from collections import defaultdict from collections import namedtuple -import conda_smithy -import conda_smithy.configure_feedstock from git import Actor from git import Repo from github import Github @@ -537,6 +535,9 @@ def regenerate_fork(fork): :param github.Repository.Repository fork: fork of conda-forge feedstock :return: `bool` -- True if regenerated, false otherwise """ + import conda_smithy + import conda_smithy.configure_feedstock + # Would need me to pass gh_user, gh_password # subprocess.run(["./renderer.sh", gh_user, gh_password, fork.name])