traffic: delete empty temp directories
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>
Fri, 19 Oct 2018 03:25:06 +0000 (16:25 +1300)
committerDouglas Bagnall <dbagnall@samba.org>
Tue, 8 Jan 2019 22:55:32 +0000 (23:55 +0100)
even if someone asked to keep the temporary data, they don't want
to see 5000 empty directries. Non-empty directories will remain.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
script/traffic_replay

index e267935b9dd7f5c324c043fbb9a1ccf84b6e1e1c..dd6e9037ce5a1b603c1ea712e734ce740425a72f 100755 (executable)
@@ -387,6 +387,15 @@ def main():
     if not opts.preserve_tempdir:
         logger.info("Removing temporary directory")
         shutil.rmtree(tempdir)
-
+    else:
+        # delete the empty directories anyway. There are thousands of
+        # them and they're EMPTY.
+        for d in os.listdir(tempdir):
+            if d.startswith('conversation-'):
+                path = os.path.join(tempdir, d)
+                try:
+                    os.rmdir(path)
+                except OSError as e:
+                    logger.info("not removing %s (%s)" % (path, e))
 
 main()