Error generting reports in python

I have tried a few modules that generate reports on both Autopsy 4.16 and 4.17 both they keep giving an error. An example is when I run the reportmodule.py report located https://github.com/sleuthkit/autopsy/blob/develop/pythonExamples/reportmodule.py.

The error seems to be when it is joining the basereportdir with the report file. Looking at the logs the error is as follows
File “C:\Users\emeu\AppData\Roaming\autopsy\python_modules\sample report\ReportModule.py”, line 98, in generateReport
fileName = os.path.join(baseReportDir, self.getRelativeFilePath())
File “C:\Program Files\Autopsy-4.17.0\autopsy\modules\ext\jython-standalone-2.7.0.jar\Lib\ntpath.py”, line 96, in join
TypeError: object of type ‘org.sleuthkit.autopsy.report.GeneralReportSettings’ has no len()

Another error that occurs is when I use Mark McKinnon’s SPAI HTML report module…

File “C:\Users\emeu\AppData\Roaming\autopsy\python_modules\SPAI_Model_Report_Module\SPAIModelReportModule.py”, line 343, in generateReport
self.create_index_file(report_dir)
UnboundLocalError: local variable ‘report_dir’ referenced before assignment

These errors doesn’t occur in versions 4.15 and earlier…

Any advice would be appreciated

Try this

Uncomment/uncomment the report_dir below when Autopsy 4.16 goes live.

try:

report_dir = os.path.join(baseReportDir.getReportDirectoryPath(), “Report”)

report_dir = os.path.join(baseReportDir, “Report”)
os.mkdir(report_dir)
except:
self.log(Level.INFO, “Could not create base report dir”)

That is what I found for the error in the SPAI report. I just have not pushed up the fix to github yet. If you run it under 4.15 then it will work like it use to. If you are planing on switching between versions for some reason there is code you can put in to select code based on version number.

Thanks Mark

That worked perfectly