mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-17 18:17:43 +00:00
Merge pull request #4389 from APriestman/4454_pythonModule
4454 Removed custom ingest settings from python example
This commit is contained in:
commit
67acecc42d
@ -89,6 +89,7 @@ This section lists some helpful tips that we have found. These are all now in t
|
||||
- We haven't found a good way to debug while running inside of Autopsy. So, logging becomes critical. You need to go through a bunch of steps to get the logger to display your module name. See the sample module for a log() method that does all of this for you.
|
||||
- When you name the file with your Python module in it, restrict its name to letters, numbers, and underscore (_).
|
||||
- Python modules using external libraries which load native code (SciPy, NumPy, etc.) are currently NOT supported. RuntimeError will be thrown.
|
||||
- If your module needs ingest job settings, you must use the GenericIngestModuleJobSettings class instead of making a custom IngestModuleIngestJobSettings class
|
||||
|
||||
|
||||
\section mod_dev_py_distribute Distribution
|
||||
|
@ -48,6 +48,7 @@ from org.sleuthkit.autopsy.casemodule import Case
|
||||
from org.sleuthkit.autopsy.casemodule.services import Services
|
||||
from org.sleuthkit.autopsy.ingest import DataSourceIngestModule
|
||||
from org.sleuthkit.autopsy.ingest import FileIngestModule
|
||||
from org.sleuthkit.autopsy.ingest import GenericIngestModuleJobSettings
|
||||
from org.sleuthkit.autopsy.ingest import IngestMessage
|
||||
from org.sleuthkit.autopsy.ingest import IngestModule
|
||||
from org.sleuthkit.autopsy.ingest.IngestModule import IngestModuleException
|
||||
@ -82,16 +83,17 @@ class SampleFileIngestModuleWithUIFactory(IngestModuleFactoryAdapter):
|
||||
|
||||
# TODO: Update class name to one that you create below
|
||||
def getDefaultIngestJobSettings(self):
|
||||
return SampleFileIngestModuleWithUISettings()
|
||||
return GenericIngestModuleJobSettings()
|
||||
|
||||
# TODO: Keep enabled only if you need ingest job-specific settings UI
|
||||
def hasIngestJobSettingsPanel(self):
|
||||
return True
|
||||
|
||||
# TODO: Update class names to ones that you create below
|
||||
# Note that you must use GenericIngestModuleJobSettings instead of making a custom settings class.
|
||||
def getIngestJobSettingsPanel(self, settings):
|
||||
if not isinstance(settings, SampleFileIngestModuleWithUISettings):
|
||||
raise IllegalArgumentException("Expected settings argument to be instanceof SampleIngestModuleSettings")
|
||||
if not isinstance(settings, GenericIngestModuleJobSettings):
|
||||
raise IllegalArgumentException("Expected settings argument to be instanceof GenericIngestModuleJobSettings")
|
||||
self.settings = settings
|
||||
return SampleFileIngestModuleWithUISettingsPanel(self.settings)
|
||||
|
||||
@ -124,7 +126,7 @@ class SampleFileIngestModuleWithUI(FileIngestModule):
|
||||
# TODO: Add any setup code that you need here.
|
||||
def startUp(self, context):
|
||||
# As an example, determine if user configured a flag in UI
|
||||
if self.local_settings.getFlag():
|
||||
if self.local_settings.getSetting("flag") == "true":
|
||||
self.log(Level.INFO, "flag is set")
|
||||
else:
|
||||
self.log(Level.INFO, "flag is not set")
|
||||
@ -144,25 +146,6 @@ class SampleFileIngestModuleWithUI(FileIngestModule):
|
||||
def shutDown(self):
|
||||
pass
|
||||
|
||||
# Stores the settings that can be changed for each ingest job
|
||||
# All fields in here must be serializable. It will be written to disk.
|
||||
# TODO: Rename this class
|
||||
class SampleFileIngestModuleWithUISettings(IngestModuleIngestJobSettings):
|
||||
serialVersionUID = 1L
|
||||
|
||||
def __init__(self):
|
||||
self.flag = False
|
||||
|
||||
def getVersionNumber(self):
|
||||
return serialVersionUID
|
||||
|
||||
# TODO: Define getters and settings for data you want to store from UI
|
||||
def getFlag(self):
|
||||
return self.flag
|
||||
|
||||
def setFlag(self, flag):
|
||||
self.flag = flag
|
||||
|
||||
|
||||
# UI that is shown to user for each ingest job so they can configure the job.
|
||||
# TODO: Rename this
|
||||
@ -187,9 +170,9 @@ class SampleFileIngestModuleWithUISettingsPanel(IngestModuleIngestJobSettingsPan
|
||||
# TODO: Update this for your UI
|
||||
def checkBoxEvent(self, event):
|
||||
if self.checkbox.isSelected():
|
||||
self.local_settings.setFlag(True)
|
||||
self.local_settings.setSetting("flag", "true")
|
||||
else:
|
||||
self.local_settings.setFlag(False)
|
||||
self.local_settings.setSetting("flag", "false")
|
||||
|
||||
# TODO: Update this for your UI
|
||||
def initComponents(self):
|
||||
@ -199,7 +182,7 @@ class SampleFileIngestModuleWithUISettingsPanel(IngestModuleIngestJobSettingsPan
|
||||
|
||||
# TODO: Update this for your UI
|
||||
def customizeComponents(self):
|
||||
self.checkbox.setSelected(self.local_settings.getFlag())
|
||||
self.checkbox.setSelected(self.local_settings.getSetting("flag") == "true")
|
||||
|
||||
# Return the settings used
|
||||
def getSettings(self):
|
||||
|
Loading…
x
Reference in New Issue
Block a user