mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-17 18:17:43 +00:00
Importing appropriate classes from the Py Script
This commit is contained in:
parent
dd6d665ce6
commit
d4cc1384c0
@ -290,9 +290,8 @@ public class IngestJobSettings {
|
|||||||
try (NbObjectInputStream in = new NbObjectInputStream(new FileInputStream(settingsFile.getAbsolutePath()))) {
|
try (NbObjectInputStream in = new NbObjectInputStream(new FileInputStream(settingsFile.getAbsolutePath()))) {
|
||||||
settings = (IngestModuleIngestJobSettings) in.readObject();
|
settings = (IngestModuleIngestJobSettings) in.readObject();
|
||||||
} catch(NullPointerException ex){
|
} catch(NullPointerException ex){
|
||||||
try {
|
try (PythonObjectInputStream in = new PythonObjectInputStream(new FileInputStream(settingsFile.getAbsolutePath()))) {
|
||||||
// Reading serialized Jython module settings using NbObjectInputStream.readObject throws a NullPointerException
|
// Reading serialized Jython module settings using NbObjectInputStream.readObject throws a NullPointerException
|
||||||
PythonObjectInputStream in = new PythonObjectInputStream(new FileInputStream(settingsFile.getAbsolutePath()));
|
|
||||||
settings = (IngestModuleIngestJobSettings) in.readObject();
|
settings = (IngestModuleIngestJobSettings) in.readObject();
|
||||||
} catch( IOException | ClassNotFoundException exception) {
|
} catch( IOException | ClassNotFoundException exception) {
|
||||||
String warning = NbBundle.getMessage(IngestJobSettings.class, "IngestJobSettings.moduleSettingsLoad.warning", factory.getModuleDisplayName(), this.context); //NON-NLS
|
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) {
|
private String getModuleSettingsFilePath(IngestModuleFactory factory) {
|
||||||
String fileName = factory.getClass().getCanonicalName() + IngestJobSettings.MODULE_SETTINGS_FILE_EXT;
|
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 <instance number> from the fileName.
|
||||||
if(fileName.startsWith("org.python.proxies."))
|
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);
|
Path path = Paths.get(this.moduleSettingsFolderPath, fileName);
|
||||||
return path.toAbsolutePath().toString();
|
return path.toAbsolutePath().toString();
|
||||||
}
|
}
|
||||||
|
@ -112,9 +112,10 @@ public final class JythonModuleLoader {
|
|||||||
|
|
||||||
// Execute the script and create an instance of the desired class.
|
// Execute the script and create an instance of the desired class.
|
||||||
interpreter.execfile(script.getAbsolutePath());
|
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
|
interpreter.exec("obj = " + className + "()"); //NON-NLS
|
||||||
|
|
||||||
// Returns an INSTANCE of interfaceClass. Causes problem.
|
|
||||||
T obj = interpreter.get("obj", interfaceClass); //NON-NLS
|
T obj = interpreter.get("obj", interfaceClass); //NON-NLS
|
||||||
|
|
||||||
// Remove the directory where the Python script resides from the Python
|
// Remove the directory where the Python script resides from the Python
|
||||||
|
Loading…
x
Reference in New Issue
Block a user