def ReadFromFile(self,filename):
     if Playback.get().ReadFromFile(filename):
         self.OnEnablePlayback()
         self.ClearDataView()
         Recorder.get().OnSaved()
         return True
     return False
예제 #2
0
    def onRecordStartBtn(self):
        if not Recorder.get().HasBeenSaved() and Recorder.get().GetRecordedCount()>0:
            response = GuiMgr.MessageBox_OkCancel("Restart Recording?","You have not saved the current recorded data.  OK to Discard?")
            if False == response:
               return

        GuiMgr.OnStartRecording()
    def HandleIncomingGroupPacket(self, rawData, node, fromAddress):
        from Helpers import Configuration

        if Configuration.get().GetBITW_Active():
            rawData = Configuration.get().HandleBITWBuffer(
                rawData)  # handle Bump in the wire

        if 0 != TargetManager.GetTargetManager().BroadcastDownstream(
                rawData, False, node, True):  # send to all - towards a Marvin
            Statistics.GetStatistics().OnPacketChainedDownstream(rawData)

        # Break up packet and do bump in the wire.
        # If BITW not active, maybe we don't need to do this could be a lot of processing for nothing....
        objGroupPacket = MarvinGroupData.MarvinDataGroup(
            "", "", "", 0, "1.0", True)
        for packet in node.getElementsByTagName('Oscar'):
            objMarvinPacket = self.CreateMarvinData(packet, rawData,
                                                    fromAddress)
            if None == objMarvinPacket:
                return
            objGroupPacket.AddPacket(objMarvinPacket)


#        objData = MarvinData.MarvinData(namespace,ID,value,0,version,True)
        GuiMgr.OnDataPacketSentDownstream(objGroupPacket, "Chained")
        Recorder.get().AddData(objGroupPacket)
예제 #4
0
 def onLiveStartBtn(self):
     if not Recorder.get().HasBeenSaved() and Recorder.get().GetRecordedCount()>0:
         response = GuiMgr.MessageBox_OkCancel("Warning","You have not saved the current recorded data.  OK to Discard?")
         if False == response:
            return
     GuiMgr.OnStartLiveData()
     GuiMgr.SetPlaybackFilename("")
    def WriteToFile(self, filename):
        with open(filename, 'w+b') as fp:
            pickle.dump(self.PlaybackData, fp, pickle.DEFAULT_PROTOCOL)

        from Helpers import Recorder

        if not Recorder.get().HasBeenSaved():
            Recorder.get().OnSaved()
 def HandleExit(self):
     if not Recorder.get().HasBeenSaved(
     ) and Recorder.get().GetRecordedCount() > 0:
         response = GuiMgr.MessageBox_OkCancel(
             "Warning",
             "You have not saved the current recorded data.  OK to Discard?"
         )
         if False == response:
             return
     GuiMgr.Quit()
예제 #7
0
    def PerformInsertBookmark(self,Params):
        #<?xml version="1.0" encoding="utf-8"?>
        #<Marvin Type="OscarTask">
        #    <Version>1.0</Version>
        #     <OscarID>DemoOscar</OscarID>
        #     <UniqueID>1233456</UniqueID>
        #     <Task>InsertBookmark</Task>
        #     <Param>Namespace=foo</Param>
        #     <Param>ID=TestMarker</Param>
        #     <Param>Data=StartTest</Param>
        #     <Param>Propagate=True</Param> -- if True, the data is sent back upstream towards Marvin
        #</Marvin>
        if len(Params) >= 3:
            fPropagate = False
            for param in Params:
                parts = param.split("=")
                if len(parts)==2:
                    if parts[0].lower()=='namespace':
                        namespace = Alias.Alias(parts[1])
                    elif parts[0].lower()=='id':
                        id = Alias.Alias(parts[1])
                    elif parts[0].lower()=='data':
                        data = Alias.Alias(parts[1])
                    elif parts[0].lower()=='propagate':
                        propagate = Alias.Alias(parts[1])
                        if propagate.lower() == "true":
                            fPropagate = True

                    else:
                        Log.getLogger().error("Received invalid InsertBookmark task parameter: " + str(param))
                        return
        else:
            Log.getLogger().error("Received invalid InsertBookmark task.  Insufficient Parameters.")
            return

        if None == namespace:
            Log.getLogger().error("Received invalid InsertBookmark task.  Namespace not specified.")
            return

        if None == id:
            Log.getLogger().error("Received invalid InsertBookmark task.  ID not specified.")
            return

        if None == data:
            Log.getLogger().error("Received invalid InsertBookmark task.  Data not specified.")
            return
        
        eTime = Time.GetCurrMS()
        objData = MarvinData.MarvinData(namespace,id,data,eTime,1.0)
        if None != objData:
            Recorder.get().AddData(objData)
            GuiMgr.OnDataPacketSentDownstream(objData,"Minion")
            if fPropagate:
                TargetManager.GetTargetManager().BroadcastDownstream(objData.ToXML(),False,None)
    def WriteToFile(self,filename):
        # if recorded then played, then a 'cached' version will be around, we dont' want this
        for entry in self.PlaybackData:
            if hasattr(entry,'xmlData'):
                del entry.xmlData
            
        if '.bifm' in filename.lower(): #new MARVIN format
            self.WriteToMarvinFile(filename)

        else: #Oscar Format
            with open(filename,'w+b') as fp:
                pickle.dump(self.PlaybackData, fp, pickle.DEFAULT_PROTOCOL)

        from Helpers import Recorder

        if not Recorder.get().HasBeenSaved():
            Recorder.get().OnSaved()
    def HandleIncomingOscarDatapacket(self, node, rawData, fromAddress):
        from Helpers import Configuration
        # Use this object to update the gui and for recording
        # is also where BITW check update of checked map occurs
        objData = self.CreateMarvinData(node, rawData, fromAddress)

        if Configuration.get().GetBITW_Active():
            rawData = Configuration.get().HandleBITWBuffer(
                rawData)  # handle Bump in the wire

        if 0 != TargetManager.GetTargetManager().BroadcastDownstream(
                rawData, False, node):  # send to all - towards a Marvin
            Statistics.GetStatistics().OnPacketChainedDownstream(rawData)

        if None != objData:
            GuiMgr.OnDataPacketSentDownstream(objData, "Chained")
            Recorder.get().AddData(objData)
예제 #10
0
 def HandleIncomingMinionData(self, rawData, node, fromAddress):
     # <?xml version="1.0" encoding="utf-8"?>
     # <Minion>
     #    <Version>1</Version>
     #    <PacketNumber>44</PacketNumber>
     #    <Namespace>Namespace_Foo</Namespace>
     #    <Name>CPU_UTIL_CORE0</Name>
     #    <Value>33.2</Value>
     #    <Normalized>False</Normalized>
     #    <ElapsedTime>253</ElapsedTime>
     # </Minion>
     objData = self.CreateMarvinPacket(rawData, node, fromAddress)
     if None != objData:
         TargetManager.GetTargetManager().BroadcastDownstream(
             objData.ToXML(), False, node)
         GuiMgr.OnDataPacketSentDownstream(objData, "Minion")
         Recorder.get().AddData(objData)
예제 #11
0
    def HandleIncomingGroupPacket(self, rawData, node, fromAddress):
        # <?xml version="1.0" encoding="utf-8"?>
        # <MinionGroup>
        #   <Minion>
        #      <Version>1</Version>
        #      <PacketNumber>44</PacketNumber>
        #      <Namespace>Namespace_Foo</Namespace>
        #      <Name>CPU_UTIL_CORE0</Name>
        #      <Value>33.2</Value>
        #      <Normalized>False</Normalized>
        #      <ElapsedTime>253</ElapsedTime>
        #   </Minion>
        #   <Minion>
        #      <Version>1</Version>
        #      <PacketNumber>45</PacketNumber>
        #      <Namespace>Namespace_Foo</Namespace>
        #      <Name>CPU_UTIL_CORE1</Name>
        #      <Value>3.2</Value>
        #      <Normalized>False</Normalized>
        #      <ElapsedTime>273</ElapsedTime>
        #   </Minion>
        # </MinionGroup>

        objGroupPacket = MarvinGroupData.MarvinDataGroup(
            "", "", "", 0, "1.0", True)
        for packet in node.getElementsByTagName('Minion'):
            objMarvinPacket = self.CreateMarvinPacket(rawData, packet,
                                                      fromAddress)
            if None == objMarvinPacket:
                return
            objGroupPacket.AddPacket(objMarvinPacket)

        GuiMgr.OnDataPacketSentDownstream(objGroupPacket, "Minion")

        TargetManager.GetTargetManager().BroadcastDownstream(
            objGroupPacket.ToXML(), False, None, True)
        Recorder.get().AddData(objGroupPacket)
 def WriteToFile(self,filename):
     if Playback.get().WriteToFile(filename):
         Recorder.get().OnSaved()
 def OnStartLiveData(self):
     self._upstreamServer.DropPackets(False)
     self.Live_Receiving = True
     Playback.get().Clear()
     Recorder.get().Clear()
    def updateGui(self):
        if True == GuiMgr.get().Playback_Playing and (enabled(
                self.btnStopLive) or enabled(self.btnStartRecording)):
            disable(self.btnStopLive)
            disable(self.btnStartRecording)

        if False == GuiMgr.get().Live_Active and True == self.Visible:
            self.root.grid_remove()
            self.Visible = False
            return

        if True == GuiMgr.get().Live_Active and False == self.Visible:
            self.root.grid()
            self.Visible = True

        if False == self.Visible:
            return

        if True == GuiMgr.get().Playback_Playing and enabled(
                self.btnStartLive):
            disable(self.btnStartLive)

        if True == GuiMgr.get().Playback_Playing:
            return

        if True == GuiMgr.get().Live_Receiving and enabled(self.btnStartLive):
            self.btnStartLive.config(state=DISABLED)
            self.btnStopLive.config(state=NORMAL)
            self.RecordingInfoFrame.grid_remove()

        if False == GuiMgr.get().Live_Receiving and enabled(self.btnStopLive):
            enable(self.btnStartLive)
            disable(self.btnStopLive)

        if True == GuiMgr.get().Live_Recording and enabled(
                self.btnStartRecording):
            disable(self.btnStartRecording)
            enable(self.btnStopRecording)
            disable(self.btnStopLive)
            self.RecordingInfoFrame.grid()

        if enabled(self.btnStartRecording) and not enabled(self.btnStopLive):
            enable(self.btnStopLive)

        if enabled(self.btnStartLive) and enabled(self.btnStartRecording):
            self.btnStartRecording.config(state=DISABLED)

        if not enabled(self.btnStartLive) and not enabled(
                self.btnStartRecording) and not enabled(self.btnStopRecording):
            enable(self.btnStartRecording)

        if False == GuiMgr.get().Live_Recording and enabled(
                self.btnStopRecording):
            enable(self.btnStartRecording)
            disable(self.btnStopRecording)

        if True == GuiMgr.get().Live_Recording:
            self.RecordingTree.set("foo", "COUNT",
                                   str(Recorder.get().GetRecordedCount()))
            bytes = Recorder.get().GetBytesRecorded()
            if bytes < 1024:
                strVal = str(bytes) + " B"
            elif bytes < 1024 * 1024:
                strVal = "{0:.2f}".format(float(bytes / 1024)) + " KB"

            else:
                strVal = "{0:.2f}".format(float((bytes / 1024) / 1024)) + " MB"

            self.RecordingTree.set("foo", "MEM", str(strVal))
            self.RecordingTree.set("foo", "SECS",
                                   str(Recorder.get().GetRecordingTime()))
 def OnStopLiveData(self):
     self._upstreamServer.DropPackets(True)
     self.Live_Receiving = False
     if Recorder.get().GetRecordedCount()>0:
         self.OnEnablePlayback()
 def OnStartRecording(self):
     if True == self.Live_Active and True == self.Live_Receiving:
         self.Live_Recording=True
         Recorder.get().Clear()
         Recorder.get().Start()
 def OnStopRecording(self,flush):
     if True == self.Live_Recording:
         self.Live_Recording=False
         Recorder.get().Stop(flush)