diff --git a/Core/src/org/sleuthkit/autopsy/ingest/IngestJobSettings.java b/Core/src/org/sleuthkit/autopsy/ingest/IngestJobSettings.java index 3809dbc233..7e3af2691e 100644 --- a/Core/src/org/sleuthkit/autopsy/ingest/IngestJobSettings.java +++ b/Core/src/org/sleuthkit/autopsy/ingest/IngestJobSettings.java @@ -290,9 +290,8 @@ public class IngestJobSettings { try (NbObjectInputStream in = new NbObjectInputStream(new FileInputStream(settingsFile.getAbsolutePath()))) { settings = (IngestModuleIngestJobSettings) in.readObject(); } catch(NullPointerException ex){ - try { - // Reading serialized Jython module settings using NbObjectInputStream.readObject throws a NullPointerException - PythonObjectInputStream in = new PythonObjectInputStream(new FileInputStream(settingsFile.getAbsolutePath())); + try (PythonObjectInputStream in = new PythonObjectInputStream(new FileInputStream(settingsFile.getAbsolutePath()))) { + // Reading serialized Jython module settings using NbObjectInputStream.readObject throws a NullPointerException settings = (IngestModuleIngestJobSettings) in.readObject(); } catch( IOException | ClassNotFoundException exception) { String warning = NbBundle.getMessage(IngestJobSettings.class, "IngestJobSettings.moduleSettingsLoad.warning", factory.getModuleDisplayName(), this.context); //NON-NLS @@ -320,9 +319,10 @@ public class IngestJobSettings { */ private String getModuleSettingsFilePath(IngestModuleFactory factory) { String fileName = factory.getClass().getCanonicalName() + IngestJobSettings.MODULE_SETTINGS_FILE_EXT; - //Check if it's a python module class. + // Check if it's a python module class. + // In case of python module class, remove the from the fileName. if(fileName.startsWith("org.python.proxies.")) - fileName = fileName.replaceAll("[$][\\d]+.settings", ".settings"); + fileName = fileName.replaceAll("[$][\\d]+.settings$", "\\$.settings"); Path path = Paths.get(this.moduleSettingsFolderPath, fileName); return path.toAbsolutePath().toString(); } diff --git a/Core/src/org/sleuthkit/autopsy/python/JythonModuleLoader.java b/Core/src/org/sleuthkit/autopsy/python/JythonModuleLoader.java index 771b19d035..860a2eaaa4 100755 --- a/Core/src/org/sleuthkit/autopsy/python/JythonModuleLoader.java +++ b/Core/src/org/sleuthkit/autopsy/python/JythonModuleLoader.java @@ -112,9 +112,10 @@ public final class JythonModuleLoader { // Execute the script and create an instance of the desired class. interpreter.execfile(script.getAbsolutePath()); + // Importing the appropriate class from the Py Script which contains multiple classes. + interpreter.exec("from " + script.getName().replaceAll(".py", "") + " import " + className); interpreter.exec("obj = " + className + "()"); //NON-NLS - // Returns an INSTANCE of interfaceClass. Causes problem. T obj = interpreter.get("obj", interfaceClass); //NON-NLS // Remove the directory where the Python script resides from the Python