Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
mbargull committed May 21, 2018
1 parent 7cbd142 commit 77f5f72
Showing 1 changed file with 8 additions and 23 deletions.
31 changes: 8 additions & 23 deletions bld.py
Original file line number Diff line number Diff line change
@@ -1,41 +1,26 @@
from __future__ import print_function

from functools import partial
from os.path import exists
import subprocess
import sys
from time import sleep

from conda.common.io import captured
from conda_build.cli.main_build import main
import conda_build.utils

_rm_rf = conda_build.utils.rm_rf


def rm_rf(path, config=None):
with captured() as c:
check_call = subprocess.check_call
_check_call = subprocess.check_call
def check_call(ps_open_args, *args, **kwargs):
if isinstance(ps_open_args, str):
ps_open_args = ps_open_args.replace('rd /s /q', 'del /F/S/Q')
print('>>>>>> running monkeypatched call:', ps_open_args, file=sys.stderr)
return _check_call(ps_open_args, *args, **kwargs)
try:
subprocess.check_call = partial(
check_call, stdout=sys.stdout, stderr=sys.stderr, close_fds=False,
)
subprocess.check_call = check_call
_rm_rf(path, config=config)
except OSError:
pass
finally:
subprocess.check_call = check_call
for output, stream in ((c.stdout, sys.stdout), (c.stderr, sys.stderr)):
if output:
print(
*(
line for line in output.splitlines()
if not line.endswith(' - Access is denied.')
),
sep='\n', file=stream)
if exists(path):
sleep(0.1)
_rm_rf(path, config=config)
subprocess.check_call = _check_call


conda_build.utils.rm_rf = rm_rf
Expand Down

0 comments on commit 77f5f72

Please sign in to comment.