Forum Discussion

jhunter_dps's avatar
jhunter_dps
Occasional Contributor
4 years ago
Solved

slPacker Pack Method Throwing "Unable to pack the files" Error

I am attempting to compress the .mht file of a test run's log results and attach it to an email and I am attempting to use the slPacker object as a means to do it, however when I attempt to run the "pack" method, I am getting an error thrown saying "Unable to pack the files". Here is the context for how I am using the method below:

 

workDir = Project.Path + "\\Test_Export\\"

archivePath = Project.Path + "\\Compressed_Results\\" + "Compressed_Test_Results.zip"

testResults = workDir + TEST_DLS_SmokeTestVersion_" + "x" + ".mht"

if (Log.SaveResultsAs(testResults, lsMHT)):

    slPacker.Pack(testResults, workDir, archivePath)

 

Would anyone be able to point me in the right direction for how to get this method working?

  • Here's the solution from the support case that worked:

     

    >>

    To resolve this issue, please change the first two lines to the following:

     

    workDir = Project.ConfigPath + "ExportedResults\\"
    packedResults = Project.ConfigPath + "CompressedResults\\"


    Afterwards, the test will pack without issue.


    The reason the file is not getting packed is because when the first two lines are "\\Exp" and "\\Com", the project path becomes:

     

    ProjectPath\\\\Exp


    Which is not a valid path. When the log is exported afterwards, the path then becomes:

     

    ProjectPath\\\\ExportedResultsTest_DLS


    Which is also not a valid path. Because of this, the results are placed in the project folder. TestComplete tries to export the results of an empty folder to a folder called:

     

    ProjectPath\\\\CompressedResults


    Which doesn't exist as well. This is why the error was occurring. Putting the slashes after the names will create valid folder names which should resolve all of these issues.

    <<

6 Replies

  • Try this:

    def PackResults():
    
      workDir = Project.Path + "\\Test_Export\\"
      packedResults = Project.Path + "\\Compressed_Results\\"
      #testResults = workDir + "TEST_DLS_SmokeTestVersion_" + "x" + ".mht"
    
      # Clears the previous results
      aqFileSystem.DeleteFolder(workDir, True)
      aqFileSystem.DeleteFolder(packedResults, True)
    
      aqFileSystem.CreateFolder(packedResults)
      aqFileSystem.CreateFolder(workDir)
    
      # Exports the results
      fileName = workDir + "TEST_DLS_SmokeTestVersion_" + "x" + ".mht"
      Log.SaveResultsAs(fileName, 2)
    
      # Gets the list of files to pack
      fileList = slPacker.GetFileListFromFolder(workDir)
    
      # Specifies the name of the archive
      archivePath = packedResults + "CompressedResults"
    
      # Packes the resutls
      if (slPacker.Pack(fileList, workDir, archivePath)):
        Log.Message("Files compressed successfully.")

    all i did was pretty much just replace the arguments you provided with the code snippet from https://support.smartbear.com/testcomplete/docs/reference/program-objects/slpacker/pack.html

    Now I also think the code you have may work, you are missing a single double quote (") at the beginning of TEST_DLS_SmokeTestVersion_ as you are defining the testResults str variable.

  • jhunter_dps's avatar
    jhunter_dps
    Occasional Contributor

    Hello:

    I implemented the code you wrote above and the issue with the packing method is still occurring unfortunately. Is there a way to see where exactly the pack method might be encountering the problem?

  • jhunter_dps's avatar
    jhunter_dps
    Occasional Contributor

    I have followed the steps listed above about selecting the internal zip method for the script configuration and unfortunately am still having the issues.

      • sonya_m's avatar
        sonya_m
        SmartBear Alumni (Retired)

        Here's the solution from the support case that worked:

         

        >>

        To resolve this issue, please change the first two lines to the following:

         

        workDir = Project.ConfigPath + "ExportedResults\\"
        packedResults = Project.ConfigPath + "CompressedResults\\"


        Afterwards, the test will pack without issue.


        The reason the file is not getting packed is because when the first two lines are "\\Exp" and "\\Com", the project path becomes:

         

        ProjectPath\\\\Exp


        Which is not a valid path. When the log is exported afterwards, the path then becomes:

         

        ProjectPath\\\\ExportedResultsTest_DLS


        Which is also not a valid path. Because of this, the results are placed in the project folder. TestComplete tries to export the results of an empty folder to a folder called:

         

        ProjectPath\\\\CompressedResults


        Which doesn't exist as well. This is why the error was occurring. Putting the slashes after the names will create valid folder names which should resolve all of these issues.

        <<