def _startRecoveryInThred(self, status): FileExtractorCore.startSearch(status) self._mytimer.Stop() now = time.time() self._timeAllTogether += (now - self.startTime) self._updateValuesRecovery(None) self.FindWindowById(wx.ID_FORWARD).Enable() self.FindWindowById(wx.ID_BACKWARD).Enable()
def _putFiletypeOptionsContent(self): panel_top = wx.Panel(self.panel_swap, -1) label_signatures = wxStaticText (panel_top, -1 , "Select file types enabled by default") try: #self.signaturelist.Reparent(panel_top) oldList = self.signaturelist self.signaturelist = wxCheckListBox(panel_top, -1, style = wxLC_REPORT|wxSUNKEN_BORDER) self.signaturelist.Set(self.sigcontent) for i in range(len(self.sigcontent)): self.signaturelist.Check(i, oldList.IsChecked(i)) except AttributeError, msg: self.signaturelist = wxCheckListBox(panel_top, -1, style = wxLC_REPORT|wxSUNKEN_BORDER) thesignatures = FileExtractorCore.getAvailableSignatures() self.sigDict = {} for sig in thesignatures: name = sig[signatures.name] self.sigDict[name] = sig self.sigcontent = self.sigDict.keys() self.signaturelist.Set(self.sigcontent) st = getSettings().getValue('signatues_off') d = {} if st: for x in st.split('|'): d[x.strip()] = x.strip() for i in range(0, len(self.sigcontent)): if d.has_key(self.signaturelist.GetString(i)): self.signaturelist.Check(i, false) else: self.signaturelist.Check(i)
def startCLI(argv): """ Starts the CLI application An L{ExecutionSettings} object is intialised and passed to the method L{handleArguments}, which assigns the appropriate values. Afterwards, the FileExtractor core is initialised and started with the given source file. @param argv: List of arguments processed by the application (CL arguments) """ ret, status = handleArguments(argv) if ret==0: sys.exit() if ret == 1: signatures.printSignatures(status.settings.getActiveSignatures()) sys.exit() if FileExtractorCore.init(status) < 0: sys.exit() printHeader(status) signs, counter = FileExtractorCore.startSearch(status) printResults(signs, counter, status.getRunTimeForNumber(0))
def _startFileRecovery(self): location_img = tools.determineAbsPath( os.path.join(FESettings.getSettings().getValue("ig_output_dir"), FESettings.getSettings().getValue("ig_output_filename"))) if self._page1.if_dir.GetValue() == "Working Directory": location_dest = tools.determineAbsPath("./") else: location_dest = tools.determineAbsPath(self._page1.if_dir.GetValue()) self.settings = ExecutionSettings(sourceFiles = [location_img], signatures = signatures.getCopyOfAllSignauteres(), output_frequency = 2300, output_level = 0, dest_folder = location_dest) self.status = ExecutionStatus(self.settings) self.startTime = time.time() if FileExtractorCore.init(self.status) < 0: print "Error on initialisation" thread.start_new_thread(self._startRecoveryInThred,(self.status,)) self._mytimer = wx.Timer(self, _TIMER_ID1) self._mytimer.Start(1000, 0) wx.EVT_TIMER(self, _TIMER_ID1, self._updateValuesRecovery)
def __init__(self, parent, ID, title): """ Instantiate a FileExtractorFrame. A wxFrame will be created with the size L{wxSize}(600,400). The position is default position, indicated by the keyword wxDefaultPosition. The events for the buttons and menu items are registered as well. After execution of this constructor your application should initialise the help dialog using 'L{initHelp}()' and display the frame 'frame.Show()' / 'app.SetTopWindow(frame). When using the provided application class (L{FileExtractorSimpleApp}), these steps are done by the module. Keyword arguments: @param parent: The parent window (passed to super class constructor L{wxPython.wx.wxFrame.__init__}) @type parent: L{wxPython.wx.wxFrame} @param ID: The id of the wxControl (passed to super class constructor L{wxPython.wx.wxFrame.__init__}) @type ID: C{int} @param title: The title of the frame (passed to super class constructor L{wxPython.wx.wxFrame.__init__}) @type title: C{String} """ import wx wx.InitAllImageHandlers() # load settings from FESettings import getSettings getSettings().load() wxFrame.__init__(self, parent, ID, title, wxDefaultPosition, wxSize(600, 500)) from FESettings import getSettings if getSettings().getValue('output_dir'): self.dest_folder = getSettings().getValue('output_dir') else: self.dest_folder = "./" self.CreateStatusBar() self.SetStatusText("FileExtractor initialised ...") appLogo = wx.Icon(os.path.join(FESettings.PATH_ICONS, "fileextractor.png"), wx.BITMAP_TYPE_PNG); self.SetIcon(appLogo) panel_outer = wxPanel(self, -1) panel_left = wxPanel(panel_outer, -1) panel_right = wxPanel(panel_outer, -1) label_sources = wxStaticText (panel_left, -1 , "Source File(s)") self.filelist = wxListBox(panel_left, -1, style = wxLC_REPORT|wxSUNKEN_BORDER) self.content = [] self.filelist.Set(self.content) panel_buttons = wxPanel(panel_left, -1) #b1 = wxButton(panel_buttons, _ID_B_ADD, "Add") #b2 = wxButton(panel_buttons, _ID_B_REMOVE, "Remove") panel_fill = wxPanel(panel_buttons, -1) bmAdd = wx.Bitmap(os.path.join(FESettings.PATH_ICONS, "edit_add.png"), wx.BITMAP_TYPE_PNG); b1 = wxBitmapButton(panel_buttons, _ID_B_ADD, bmAdd, size=(30,25)) bmRem = wx.Bitmap(os.path.join(FESettings.PATH_ICONS, "edit_remove.png"), wx.BITMAP_TYPE_PNG); b2 = wxBitmapButton(panel_buttons, _ID_B_REMOVE, bmRem, size=(30,25)) box = wxBoxSizer(wxHORIZONTAL) box.Add(panel_fill, 1, wxALIGN_CENTER | wxEXPAND) box.Add(b1, 1, wxALIGN_CENTER ) box.Add(b2, 1, wxALIGN_CENTER ) panel_buttons.SetAutoLayout(True) panel_buttons.SetSizer(box) panel_buttons.Layout() bmLogo = wx.Bitmap(os.path.join(FESettings.PATH_ICONS, "felogo2.png"), wx.BITMAP_TYPE_PNG); sbmLogo = wxStaticBitmap(panel_left, 567, bmLogo, size = (250, 140)) panel_fill = wxPanel(panel_left, -1) #panel_fill1 = wxPanel(panel_left, -1) box = wxBoxSizer(wxVERTICAL) box.Add(label_sources, 1, wxALIGN_CENTER_VERTICAL | wxALIGN_CENTER_HORIZONTAL) box.Add(self.filelist, 6, wxEXPAND) box.Add(panel_buttons, 2, wxEXPAND ) #| wxALIGN_CENTER_VERTICAL) box.Add(panel_fill, 1, wxEXPAND) box.Add(sbmLogo, 8, wxALIGN_CENTER_VERTICAL | wxALIGN_CENTER_HORIZONTAL) panel_left.SetAutoLayout(True) panel_left.SetSizer(box) panel_left.Layout() # and now the right panel label_signatures = wxStaticText (panel_right, -1 , "Select File Types") self.signaturelist = wxCheckListBox(panel_right, -1, style = wxLC_REPORT|wxSUNKEN_BORDER) thesignatures = FileExtractorCore.getAvailableSignatures() self.sigDict = {} for sig in thesignatures: name = sig[signatures.name] self.sigDict[name] = sig self.sigcontent = self.sigDict.keys() self.signaturelist.Set(self.sigcontent) ## for i in range(0, len(self.sigcontent)): ## self.signaturelist.Check(i) st = getSettings().getValue('signatues_off') d = {} if st: for x in st.split('|'): d[x.strip()] = x.strip() for i in range(0, len(self.sigcontent)): if d.has_key(self.signaturelist.GetString(i)): self.signaturelist.Check(i, false) else: self.signaturelist.Check(i) bmInfo = wx.Bitmap(os.path.join(FESettings.PATH_ICONS, "info.png"), wx.BITMAP_TYPE_PNG); bInfo = wxBitmapButton(panel_right, _ID_B_INFO, bmInfo, size=(60,20)) #bInfo = wxButton(panel_right, _ID_B_INFO, "Info") label_outputdir = wxStaticText (panel_right, -1, "Output Directory") panel_dir = wxPanel(panel_right, -1) if getSettings().getValue('output_dir'): self.if_dir = wxTextCtrl(panel_dir, -1, getSettings().getValue('output_dir')) else: self.if_dir = wxTextCtrl(panel_dir, -1, 'Working Directory') self.if_dir.SetEditable(false) #bChooseDir = wxButton(panel_dir, _ID_B_DIR, "Change Directory") bmDir = wx.Bitmap(os.path.join(FESettings.PATH_ICONS, "browse.png"), wx.BITMAP_TYPE_PNG); panel_fill = wxPanel(panel_dir, -1) bChooseDir = wxBitmapButton(panel_dir, _ID_B_DIR, bmDir, size=(30,30)) box = wxBoxSizer(wxHORIZONTAL) box.Add(self.if_dir, 16, wxALIGN_CENTER) box.Add(panel_fill, 1, wxALIGN_CENTER) box.Add(bChooseDir, 3, wxALIGN_CENTER) panel_dir.SetAutoLayout(True) panel_dir.SetSizer(box) panel_dir.Layout() ## pFill1 = wxPanel(panel_right, -1) pFill2 = wxPanel(panel_right, -1) pFill3 = wxPanel(panel_right, -1) panel_start = wxPanel(panel_right, -1) panel_fills1 = wxPanel(panel_start, -1) ## panel_fills2 = wxPanel(panel_start, -1) bmStart = wx.Bitmap(os.path.join(FESettings.PATH_ICONS, "start4.png"), wx.BITMAP_TYPE_PNG); bStartSearch = wxBitmapButton(panel_start, _ID_B_START, bmStart, size=(105,22)) #bStartSearch = wxButton(panel_start, _ID_B_START, "Start Search") boxs = wxBoxSizer(wxHORIZONTAL) boxs.Add(panel_fills1, 7, wxEXPAND) boxs.Add(bStartSearch, 7, wxEXPAND | wxALIGN_RIGHT) ## boxs.Add(panel_fills2, 1, wxEXPAND) panel_start.SetAutoLayout(True) panel_start.SetSizer(boxs) panel_start.Layout() boxr = wxBoxSizer(wxVERTICAL) boxr.Add(label_signatures, 1, wxALIGN_CENTER_VERTICAL | wxALIGN_CENTER_HORIZONTAL) boxr.Add(self.signaturelist, 10, wxEXPAND) ## boxr.Add(pFill1, 1, wxEXPAND) boxr.Add(bInfo, 2, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT) boxr.Add(pFill2, 1, wxEXPAND) boxr.Add(label_outputdir, 1, wxALIGN_BOTTOM| wxALIGN_CENTER_HORIZONTAL) boxr.Add(panel_dir, 2, wxEXPAND | wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT) boxr.Add(pFill3, 1, wxEXPAND) boxr.Add(panel_start, 2, wxEXPAND) panel_right.SetAutoLayout(True) panel_right.SetSizer(boxr) panel_right.Layout() # layout for outer window panel_fill_hor1 = wxPanel(panel_outer, -1) panel_fill_hor2 = wxPanel(panel_outer, -1) panel_fill_hor3 = wxPanel(panel_outer, -1) box = wxBoxSizer(wxHORIZONTAL) box.Add(panel_fill_hor1, 1, wxEXPAND) box.Add(panel_left, 10, wxEXPAND) box.Add(panel_fill_hor2, 1, wxEXPAND) box.Add(panel_right, 10, wxEXPAND) box.Add(panel_fill_hor3, 1, wxEXPAND) panel_outer.SetAutoLayout(True) panel_outer.SetSizer(box) panel_outer.Layout() pFill1 = wxPanel(self, -1) pFill2 = wxPanel(self, -1) ## pFill3 = wxPanel(self, -1) boxo = wxBoxSizer(wxVERTICAL) boxo.Add(pFill1, 1, wxEXPAND) boxo.Add(panel_outer, 20, wxEXPAND) boxo.Add(pFill2, 1, wxEXPAND) ## boxo.Add(panel_start, 1, wxEXPAND) ## boxo.Add(pFill3, 1, wxEXPAND) self.SetAutoLayout(True) self.SetSizer(boxo) self.Layout() fileMenu = wx.Menu() addItem = wx.MenuItem(fileMenu, _ID_ADD, "&Add Source File", "Add Source File to be searched in") bm = wx.Bitmap(os.path.join(FESettings.PATH_ICONS, "small/edit_add.png"), wx.BITMAP_TYPE_PNG); addItem.SetBitmap(bm) fileMenu.AppendItem(addItem) startItem = wx.MenuItem(fileMenu, _ID_START, "&Start Searching", "Go and find your files") bm = wx.Bitmap(os.path.join(FESettings.PATH_ICONS, "small/start.png"), wx.BITMAP_TYPE_PNG); startItem.SetBitmap(bm) fileMenu.AppendItem(startItem) fileMenu.AppendSeparator() prefItem = wx.MenuItem(fileMenu, _ID_OPTIONS, "&Options", "Apply Settings for the program") bm = wx.Bitmap(os.path.join(FESettings.PATH_ICONS, "small/configure.png"), wx.BITMAP_TYPE_PNG); prefItem.SetBitmap(bm) fileMenu.AppendItem(prefItem) fileMenu.AppendSeparator() exitItem = wx.MenuItem(fileMenu, _ID_EXIT, "E&xit", "Terminate the program") bmExit = wx.Bitmap(os.path.join(FESettings.PATH_ICONS, "small/exit.png"), wx.BITMAP_TYPE_PNG); exitItem.SetBitmap(bmExit) fileMenu.AppendItem(exitItem) menuBar = wxMenuBar() menuBar.Append(fileMenu, "&File"); toolsMenu = wxMenu() imageItem = wx.MenuItem(toolsMenu, _ID_IMAGEGENERATOR, "&ImageGenerator...", "Create an image file") bm = wx.Bitmap(os.path.join(FESettings.PATH_ICONS, "small/tools_image.png"), wx.BITMAP_TYPE_PNG); imageItem.SetBitmap(bm) toolsMenu.AppendItem(imageItem) menuBar.Append(toolsMenu, "&Tools") helpMenu = wxMenu() helpItem = wx.MenuItem(helpMenu, _ID_CONTENT, "&Content", "How to use this Program in detail") bm = wx.Bitmap(os.path.join(FESettings.PATH_ICONS, "small/help.png"), wx.BITMAP_TYPE_PNG); helpItem.SetBitmap(bm) helpMenu.AppendItem(helpItem) helpMenu.AppendSeparator() aboutItem = wx.MenuItem(helpMenu, _ID_ABOUT, "&About", "Basic Information about this program") bm = wx.Bitmap(os.path.join(FESettings.PATH_ICONS, "small/info.png"), wx.BITMAP_TYPE_PNG); aboutItem.SetBitmap(bm) helpMenu.AppendItem(aboutItem) menuBar.Append(helpMenu, "&Help") self.SetMenuBar(menuBar) EVT_MENU(self, _ID_ABOUT, self._OnAbout) EVT_MENU(self, _ID_EXIT, self._TimeToQuit) EVT_MENU(self, _ID_ADD, self._AddSourceFile) EVT_MENU(self, _ID_START, self._StartSearch) EVT_MENU(self, _ID_CONTENT, self._showHelp) EVT_MENU(self, _ID_OPTIONS, self._OnSettings) if _MODULE_IMAGE_GENERATOR: EVT_MENU(self, _ID_IMAGEGENERATOR, self._startImageGenerator) else: EVT_MENU(self, _ID_IMAGEGENERATOR, self._NotAvailable) EVT_BUTTON(self, _ID_B_ADD, self._AddSourceFile) EVT_BUTTON(self, _ID_B_REMOVE, self._RemoveSourceFile) EVT_BUTTON(self, _ID_B_INFO, self._InfoSignature) EVT_BUTTON(self, _ID_B_DIR, self._ChangeOutputDir) EVT_BUTTON(self, _ID_B_START, self._StartSearch) # # toolbar # ## import wx ## wx.InitAllImageHandlers() #toolbar = self.CreateToolBar(style = wxNO_BORDER | wxTB_HORIZONTAL) toolbar = self.CreateToolBar(style = wxRAISED_BORDER | wxTB_TEXT | wxTB_HORIZONTAL) self.ToolBar = toolbar toolbar.SetToolBitmapSize((21,21)) # 1. global bmExit = wx.Bitmap(os.path.join(FESettings.PATH_ICONS, "exit.png"), wx.BITMAP_TYPE_PNG); toolbar.DoAddTool(id = 1001, bitmap = bmExit, label="Exit", shortHelp = "Quit FileExtractor") toolbar.AddSeparator() # 2. Actions bmAdd = wx.Bitmap(os.path.join(FESettings.PATH_ICONS, "edit_add.png"), wx.BITMAP_TYPE_PNG); toolbar.DoAddTool(id = 1002, bitmap = bmAdd, label="Add", shortHelp = "Add Source File") bmRem = wx.Bitmap(os.path.join(FESettings.PATH_ICONS, "edit_remove.png"), wx.BITMAP_TYPE_PNG); toolbar.DoAddTool(id = 1003, bitmap = bmRem, label="Remove", shortHelp = "Remove Source File") bmStart = wx.Bitmap(os.path.join(FESettings.PATH_ICONS, "start.png"), wx.BITMAP_TYPE_PNG); toolbar.DoAddTool(id = 1004, bitmap = bmStart, label="Start", shortHelp = "Start recovery") toolbar.AddSeparator() # 3. Tools bmImage = wx.Bitmap(os.path.join(FESettings.PATH_ICONS, "tools_image.png"), wx.BITMAP_TYPE_PNG); toolbar.DoAddTool(id = 1005, bitmap = bmImage, label="Image", shortHelp = "Image your data source") toolbar.AddSeparator() # 4. Configure bmConf = wx.Bitmap(os.path.join(FESettings.PATH_ICONS, "configure.png"), wx.BITMAP_TYPE_PNG); toolbar.DoAddTool(id = 1006, bitmap = bmConf, label="Configure", shortHelp = "Configure FileExtractor") toolbar.AddSeparator() # 5. Help bmHelp = wx.Bitmap(os.path.join(FESettings.PATH_ICONS, "help.png"), wx.BITMAP_TYPE_PNG); toolbar.DoAddTool(id = 1007, bitmap = bmHelp, label="Help", shortHelp = "FileExtractor Help") toolbar.AddSeparator() toolbar.Realize() EVT_TOOL(self, 1001, self._TimeToQuit) EVT_TOOL(self, 1002, self._AddSourceFile) EVT_TOOL(self, 1003, self._RemoveSourceFile) EVT_TOOL(self, 1004, self._StartSearch) if _MODULE_IMAGE_GENERATOR: EVT_TOOL(self, 1005, self._startImageGenerator) else: EVT_TOOL(self, 1005, self._NotAvailable) EVT_TOOL(self, 1006, self._OnSettings) EVT_TOOL(self, 1007, self._showHelp)