test-bugzilla-files/test-bugzilla-files.py |   12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

New commits:
commit ff73b7b3c312b9da1e7fa929b32200859061edac
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Tue Dec 13 20:06:11 2022 +0000
Commit:     Caolán McNamara <caol...@redhat.com>
CommitDate: Wed Dec 14 10:41:52 2022 +0000

    remove exported files immediately after no longer need them
    
    to avoid Gigs of files eating up space during a run
    
    Change-Id: I91b7babd25131691f38258221ee4918cc943d445
    Reviewed-on: https://gerrit.libreoffice.org/c/dev-tools/+/144107
    Tested-by: Caolán McNamara <caol...@redhat.com>
    Reviewed-by: Caolán McNamara <caol...@redhat.com>

diff --git a/test-bugzilla-files/test-bugzilla-files.py 
b/test-bugzilla-files/test-bugzilla-files.py
index 16d337e0..22216137 100644
--- a/test-bugzilla-files/test-bugzilla-files.py
+++ b/test-bugzilla-files/test-bugzilla-files.py
@@ -375,7 +375,8 @@ def exportDoc(xDoc, filterName, validationCommand, 
filename, connection, timer):
     props = [ ("FilterName", filterName) ]
     saveProps = tuple([mkPropertyValue(name, value) for (name, value) in 
props])
     # note: avoid empty path segments in the url!
-    fileURL = "file://" + os.path.normpath(os.environ["CRASHTESTDATA"] + 
"/current/" + filename)
+    filePath = os.path.normpath(os.environ["CRASHTESTDATA"] + "/current/" + 
filename)
+    fileURL = "file://" + filePath
     t = None
     try:
         args = [connection]
@@ -404,19 +405,24 @@ def exportDoc(xDoc, filterName, validationCommand, 
filename, connection, timer):
 
     print("xDoc.storeToURL " + fileURL + " " + filterName + "\n")
     if validationCommand:
-        validationCommandWithURL = validationCommand + " " + fileURL[7:]
+        validationCommandWithURL = validationCommand + " " + filePath
         print(validationCommandWithURL)
         try:
             output = str(subprocess.check_output(validationCommandWithURL, 
shell=True, timeout=600), encoding='utf-8')
             print(output)
             if ("Error" in output) or ("error" in output):
                 print("Error validating file")
-                validLog = open(fileURL[7:]+".log", "w")
+                validLog = open(filePath+".log", "w")
                 validLog.write(output)
                 validLog.close()
         except subprocess.CalledProcessError:
             pass # ignore that exception
 
+    try:
+        os.remove(filePath)
+    except:
+        pass
+
 def getODFunDiffCommand():
     return os.environ["HOME"] + "/source/bin/odfundiff-exe"
 

Reply via email to