I need to pass path of subdirectory of a temporary directory to another function.
Real scenario:
User will upload a zip or tar archive then it will be extracted inside a temporary directory, now I need the path of that extracted directory.
is there a way to get path of a subdirectory in case we couldn't known the name of that directory? Here's what I'm doing in code;
views.py
if form.is_valid():
deployment = TarWithDocker()
deployment.name = form.cleaned_data['name']
deployment.user = request.user
deployment.archive = form.cleaned_data['archive']
deployment.save()
tmpdir = tempfile.mkdtemp()
saved_umask = os.umask(0o077)
path = os.path.join(tmpdir)
arpath = deployment.archive.path
patoolib.extract_archive(arpath, outdir=path)
client = docker.from_env()
dirp = os.path.join(path)
client.images.build(path=# Here i need to pass sub path of directory of temp dir #}
, gzip=False, tag='newdep')
os.umask(saved_umask)
shutil.rmtree(tmpdir)
Help me, please! Thanks in Advance!