Change in ...osmo-python-tests[master]: remove_tmpdir(): Support recursion / sub-directories

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

laforge gerrit-no-reply at lists.osmocom.org
Wed Jul 15 19:48:47 UTC 2020


laforge has submitted this change. ( https://gerrit.osmocom.org/c/python/osmo-python-tests/+/19267 )

Change subject: remove_tmpdir(): Support recursion / sub-directories
......................................................................

remove_tmpdir(): Support recursion / sub-directories

The existing code assumed that tmpdir only contained regular files,
not an entire hierarchy of files with sub-directories or the like.

In case sub-directories exist, the current code fails as follows:

line 176, in test_all_apps
    remove_tmpdir(tmpdir)
  File "/usr/local/lib/python3.5/dist-packages/osmopython-0.2.0-py3.5.egg/EGG-INFO/scripts/osmotestconfig.py", line 142, in remove_tmpdir
    os.unlink(os.path.join(tmpdir, f))
IsADirectoryError: [Errno 21] Is a directory: 'writtenconfig/ericsson'

Change-Id: I896b99032d94ba0cdd340a8eed7c7b625661ad69
---
M scripts/osmotestconfig.py
1 file changed, 2 insertions(+), 4 deletions(-)

Approvals:
  Jenkins Builder: Verified
  pespin: Looks good to me, but someone else must approve
  fixeria: Looks good to me, but someone else must approve
  laforge: Looks good to me, approved



diff --git a/scripts/osmotestconfig.py b/scripts/osmotestconfig.py
index 3c96ca6..8b3bb84 100755
--- a/scripts/osmotestconfig.py
+++ b/scripts/osmotestconfig.py
@@ -15,6 +15,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 import os
 import os.path
+import shutil
 import time
 import sys, shutil, stat
 import tempfile
@@ -137,10 +138,7 @@
 
 
 def remove_tmpdir(tmpdir):
-    files = os.listdir(tmpdir)
-    for f in files:
-        os.unlink(os.path.join(tmpdir, f))
-    os.rmdir(tmpdir)
+    shutil.rmtree(tmpdir)
 
 
 def check_configs_tested(basedir, app_configs, ignore_configs):

-- 
To view, visit https://gerrit.osmocom.org/c/python/osmo-python-tests/+/19267
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: python/osmo-python-tests
Gerrit-Branch: master
Gerrit-Change-Id: I896b99032d94ba0cdd340a8eed7c7b625661ad69
Gerrit-Change-Number: 19267
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <laforge at osmocom.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <axilirator at gmail.com>
Gerrit-Reviewer: fixeria <vyanitskiy at sysmocom.de>
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-Reviewer: pespin <pespin at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200715/276e020f/attachment.htm>


More information about the gerrit-log mailing list