Import / export implants sets

This commit is contained in:
blitzmann
2016-03-21 23:43:45 -04:00
parent 94f73241ea
commit 3ae312db37
4 changed files with 95 additions and 29 deletions

View File

@@ -22,7 +22,10 @@ from gui.bitmapLoader import BitmapLoader
from gui.builtinViews.implantEditor import BaseImplantEditorView
import service
from gui.utils.clipboard import toClipboard, fromClipboard
from service.targetResists import ImportError
from service.implantSet import ImportError
import logging
logger = logging.getLogger(__name__)
class ImplantSetEditor(BaseImplantEditorView):
def __init__(self, parent):
@@ -326,14 +329,15 @@ class ImplantSetEditorDlg(wx.Dialog):
text = fromClipboard()
if text:
sTR = service.TargetResists.getInstance()
sIS = service.ImplantSets.getInstance()
try:
sTR.importPatterns(text)
sIS.importSets(text)
self.stNotice.SetLabel("Patterns successfully imported from clipboard")
self.showInput(False)
except service.targetResists.ImportError, e:
except ImportError, e:
self.stNotice.SetLabel(str(e))
except Exception, e:
logging.exception("Unhandled Exception")
self.stNotice.SetLabel("Could not import from clipboard: unknown errors")
finally:
self.updateChoices()
@@ -343,6 +347,6 @@ class ImplantSetEditorDlg(wx.Dialog):
def exportPatterns(self, event):
"Event fired when export to clipboard button is clicked"
sTR = service.TargetResists.getInstance()
toClipboard( sTR.exportPatterns() )
self.stNotice.SetLabel("Patterns exported to clipboard")
sIS = service.ImplantSets.getInstance()
toClipboard(sIS.exportSets())
self.stNotice.SetLabel("Sets exported to clipboard")