autobuild-run: prepare_build(): ignore directories in dldir
PATCH 1/1 autobuild-run: prepare_build(): ignore directories in dldir
With the change to use subdirs in dldir, prepare_build may end up trying to remove a non-empty subdir, causing an exception:
Process Process-1:
Traceback (most recent call last):
File "/usr/lib64/python2.7/multiprocessing/process.py", line 258, in _bootstrap
self.run()
File "/usr/lib64/python2.7/multiprocessing/process.py", line 114, in run
self._target(*self._args, **self._kwargs) File "/home/peko/buildroot-test/scripts/autobuild-run", line 627, in run_instance
ret = prepare_build(**kwargs)
File "/home/peko/buildroot-test/scripts/autobuild-run", line 301, in prepare_build
os.remove(os.path.join(dldir, f))
OSError: [Errno 21] Is a directory: 'instance-0/dl/mtools'
We only want to delete individual download files, so drop directories from the list of removal candidates.
--- scripts/autobuild-run | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
scripts/autobuild-run +3 -1
@@ -293,7 +293,9 @@ def prepare_build(**kwargs): # regularly re-download files to check that their upstream # location is still correct. for i in range(0, 5): - flist = os.listdir(dldir) + # ignore directories + flist = [f for f in os.listdir(dldir) + if os.path.isfile(os.path.join(dldir, f))] if not flist: break f = flist[randint(0, len(flist) - 1)]
Signature · 1 line
2.11.0
PATCH 1/1 autobuild-run: prepare_build(): ignore directories in dldir
Hello,
Quoted 28 lines · Peter Korsgaard
With the change to use subdirs in dldir,
prepare_buildmay end up trying to remove a non-empty subdir, causing an exception:Process Process-1:
Traceback (most recent call last):
File "/usr/lib64/python2.7/multiprocessing/process.py", line 258, in_bootstrapself.run() File "/usr/lib64/python2.7/multiprocessing/process.py", line 114, in run self._target(*self._args, **self._kwargs)File "
/home/peko/buildroot-test/scripts/autobuild-run", line 627, inrun_instance
ret =prepare_build(**kwargs)
File "/home/peko/buildroot-test/scripts/autobuild-run", line 301, inprepare_build
os.remove(os.path.join(dldir, f))
OSError: [Errno 21] Is a directory: 'instance-0/dl/mtools'We only want to delete individual download files, so drop directories from the list of removal candidates.
Signed-off-by Peter Korsgaard <[email protected]>--- scripts/autobuild-run | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)scripts/autobuild-run +0
-0
scripts/autobuild-run def prepare_build(**kwargs): · line 301
Quoted 10 lines
scripts/autobuild-run +3
-1@@ -293,7 +293,9 @@ def prepare_build(**kwargs): # regularly re-download files to check that their upstream # location is still correct. for i in range(0, 5): - flist = os.listdir(dldir) + # ignore directories + flist = [f for f in os.listdir(dldir) + if os.path.isfile(os.path.join(dldir, f))] if not flist: break f = flist[randint(0, len(flist) - 1)]
But this is not going to remove files in sub-directories I believe, and therefore it no longer does the job it is supposed to do. I believe we need to switch to os.walk() to walk down in the sub-directories, no ?
Best regards,
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons) Embedded Linux and Kernel engineering https://bootlin.com
PATCH 1/1 autobuild-run: prepare_build(): ignore directories in dldir
Quoted 38 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Thomas" == Thomas Petazzoni <[email protected]> writes:
Hello,
Quoted 34 lines · Peter Korsgaard
With the change to use subdirs in dldir,
prepare_buildmay end up trying to remove a non-empty subdir, causing an exception:Process Process-1:
Traceback (most recent call last):
File "/usr/lib64/python2.7/multiprocessing/process.py", line 258, in_bootstrapself.run()
File "/usr/lib64/python2.7/multiprocessing/process.py", line 114, in runself._target(*self._args, **self._kwargs)
File "/home/peko/buildroot-test/scripts/autobuild-run", line 627, inrun_instanceret =prepare_build(**kwargs)
File "/home/peko/buildroot-test/scripts/autobuild-run", line 301, inprepare_buildos.remove(os.path.join(dldir, f))
OSError: [Errno 21] Is a directory: 'instance-0/dl/mtools'We only want to delete individual download files, so drop directories from the list of removal candidates.
Signed-off-by Peter Korsgaard <[email protected]>---
scripts/autobuild-run| 4 +++-1 file changed, 3 insertions(+), 1 deletion(-)scripts/autobuild-run +0
-0@@ -293,7 +293,9 @@ def prepare_build(**kwargs): # regularly re-download files to check that their upstream # location is still correct.for i in
range(0, 5):scripts/autobuild-run +2
-1- flist = os.listdir(dldir) + # ignore directories + flist = [f for f in os.listdir(dldir)
Quoted 8 lines
Quoted 4 lines
+ if
os.path.isfile(os.path.join(dldir, f))]
if not flist:
break
f = flist[randint(0, len(flist) - 1)]But this is not going to remove files in sub-directories I believe, and therefore it no longer does the job it is supposed to do. I believe we need to switch to
os.walk()to walk down in the sub-directories, no ?
Ehh, you're right. For some reason I was convinced listdir would recurse.
So something like:
flist = [map(lambda f: os.path.join(r, f), f) for (r, d, f) in os.walk(dldir)]
I'll do a test and resend.
Signature · 1 line
Bye, Peter Korsgaard