Tickets: https://fedorahosted.org/freeipa/ticket/3801 https://fedorahosted.org/freeipa/ticket/4417 Design: https://fedorahosted.org/bind-dyndb-ldap/wiki/BIND9/Design/DNSSEC Reviewed-By: Jan Cholasta <jcholast@redhat.com> Reviewed-By: David Kupka <dkupka@redhat.com>
24 lines
524 B
Python
24 lines
524 B
Python
#!/usr/bin/python
|
|
#
|
|
# Copyright (C) 2014 FreeIPA Contributors see COPYING for license
|
|
#
|
|
|
|
import errno
|
|
import shutil
|
|
import tempfile
|
|
|
|
class TemporaryDirectory(object):
|
|
def __init__(self, root):
|
|
self.root = root
|
|
|
|
def __enter__(self):
|
|
self.name = tempfile.mkdtemp(dir=self.root)
|
|
return self.name
|
|
|
|
def __exit__(self, exc_type, exc_value, traceback):
|
|
try:
|
|
shutil.rmtree(self.name)
|
|
except OSError as e:
|
|
if e.errno != errno.ENOENT:
|
|
raise
|