cancel
Showing results for 
Search instead for 
Did you mean: 

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

SOLVED
Highlighted
New Contributor

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?

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Manager

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

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.

<<


Sonya Mihaljova
Community and Education Specialist

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️

View solution in original post

6 REPLIES 6
Highlighted
Staff

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

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.

Best,
Justin Kim
Highlighted
New Contributor

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

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?

Highlighted
Staff

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

try following some of the instructions on this page

https://support.smartbear.com/testcomplete/docs/reference/options/engines/packer.html

hkim5_0-1602860125779.png

 

Best,
Justin Kim
Highlighted
New Contributor

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

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

Highlighted
Staff

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

I think the only thing left to do is to file for a support ticket

Best,
Justin Kim
Highlighted
Community Manager

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

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.

<<


Sonya Mihaljova
Community and Education Specialist

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️

View solution in original post

New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors