Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an onerror handler to shutil.rmtree calls #19

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions tick_my_feedstocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,11 @@
import os
import re
import shutil
import stat
import tempfile
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
Expand Down Expand Up @@ -536,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])

Expand All @@ -547,7 +549,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 = \
Expand All @@ -558,10 +560,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,
Expand Down