def process_action(self, action, node):
     """ Helper function for processing actions, finds out what does each action do and sets the appropriate attributed of the node
     :param obj action The action to be processed.
     :param obj node The node to be changed."""
     if action.isFormat:
         node.add_emoji("Fmt:")
         node.addAttribute("action", "Format")
     else:
         node.add_emoji("Dev:")
         node.addAttribute("action", "Device")
     if action.isDestroy or action.isRemove:
         print("Adding action: Delete for node: " + node.getName())
         node.addAttribute("action", "delete")
         node.change_color(self.pallete.complement["2"])
         node.add_emoji(emoji.emojize(":fire:"))
     if action.isCreate or action.isAdd:
         print("Adding action: Add for node: " + node.getName())
         node.addAttribute("action", "add")
         node.change_color(self.pallete.primary["2"])
         node.add_emoji(emoji.emojize(":building_construction:"))
     if action.isResize or action.isShrink or action.isGrow:
         print("Adding action: Resize for node: " + node.getName())
         node.addAttribute("action", "resize")
         node.change_color(self.pallete.secondary_second["2"])
         node.add_emoji(emoji.emojize(":wrench:"))
 def process_action(self, action, node):
     """ Helper function for processing actions, finds out what does each action do and sets the appropriate attributed of the node
     :param obj action The action to be processed.
     :param obj node The node to be changed."""
     if action.isFormat:
         node.add_emoji("Fmt:")
         node.addAttribute("action", "Format")
     else:
         node.add_emoji("Dev:")
         node.addAttribute("action", "Device")
     if action.isDestroy or action.isRemove:
         print("Adding action: Delete for node: " + node.getName())
         node.addAttribute("action", "delete")
         node.change_color(self.pallete.complement["2"])
         node.add_emoji(emoji.emojize(":fire:"))
     if action.isCreate or action.isAdd:
         print("Adding action: Add for node: " + node.getName())
         node.addAttribute("action", "add")
         node.change_color(self.pallete.primary["2"])
         node.add_emoji(emoji.emojize(":building_construction:"))
     if action.isResize or action.isShrink or action.isGrow:
         print("Adding action: Resize for node: " + node.getName())
         node.addAttribute("action", "resize")
         node.change_color(self.pallete.secondary_second["2"])
         node.add_emoji(emoji.emojize(":wrench:"))
예제 #3
0
파일: network.py 프로젝트: ni1s/animats
 def addNode(self, node):
     if self.hasNode(node): return False
     self.nodes[node.getName()] = node
     self.node_count = self.node_count + 1
     node.setNetwork(self)
     self.lastChange = self.time
     return True
예제 #4
0
 def addNode(self, node):
     """add a node to the graph. The input must be a Node"""
     nodeName = node.getName()
     self.add_node(
         nodeName, obj=node
     )  # add the node to the graph by name storing the Node in obj
     self._labels[
         nodeName] = nodeName  # add the name to the labels dictionary
예제 #5
0
 def process_node(self, node, device):
     """ Sorts node based on it's type and starts command related to it.
     :param obj node node that should be sorted
     :param obj device the device from which the node originated, used for getting aditional information"""
     print("Adding device, Name: " + device.name + " Type: " + device.type)
     # Adding entries that are present for all nodes
     if (device.encrypted):
         node.add_emoji(emoji.emojize(":lock:"))
     else:
         node.add_emoji(emoji.emojize(":open_lock:"))
     # End of common entries
     if node.getType() == "luks/dm-crypt":
         self.nodeIsLuks(node)
     if node.getType() == "disk":
         self.nodeIsHarddrive(node)
         if (device.format.type == "disklabel"):
             node.addAttribute("format", device.format.labelType)
     if node.getType() == "partition":
         self.nodeIsPartition(node)
     if node.getType() == "lvmlv":
         self.nodeIsLV(node)
         if (device.cached):
             node.addAttribute("cached", "True")
     if node.getType() == "lvmvg":
         self.nodeIsVG(node)
     if node.getType() == "lvmthinpool":
         self.nodeIsLVMThinPool(node)
     if node.getType() == "lvmthinlv":
         self.nodeIsLVMThinLv(node)
         if (device.cached):
             node.addAttribute("cached", "True")
     if node.getType() == "btrfs volume":
         self.nodeIsBTRFS(node)
     if node.getType() == "mdarray":
         self.nodeIsMDRAID(node)
     if node.getType() == "lvmsnapshot":
         self.nodeIsLVMSnapshot(node)
         new_edge = edge.Edge(device.origin.name, node.getName())
         new_edge.addGvAttribute("style", "dashed")
         self.edge_list.append(new_edge)
         node.addAttribute("Snap. origin", device.origin.name)
     self.node_list.append(node)
     for parent in device.parents:
         edge_to_be_added = edge.Edge(parent.name, device.name)
         self.edge_list.append(edge_to_be_added)
 def process_node(self, node, device):
     """ Sorts node based on it's type and starts command related to it.
     :param obj node node that should be sorted
     :param obj device the device from which the node originated, used for getting aditional information"""
     print("Adding device, Name: " + device.name + " Type: " + device.type)
     # Adding entries that are present for all nodes
     if (device.encrypted):
         node.add_emoji(emoji.emojize(":lock:"))
     else:
         node.add_emoji(emoji.emojize(":open_lock:"))
     # End of common entries
     if node.getType() == "luks/dm-crypt":
         self.nodeIsLuks(node)
     if node.getType() == "disk":
         self.nodeIsHarddrive(node)
         if (device.format.type == "disklabel"):
             node.addAttribute("format", device.format.labelType)
     if node.getType() == "partition":
         self.nodeIsPartition(node)
     if node.getType() == "lvmlv":
         self.nodeIsLV(node)
         if (device.cached):
             node.addAttribute("cached", "True")
     if node.getType() == "lvmvg":
         self.nodeIsVG(node)
     if node.getType() == "lvmthinpool":
         self.nodeIsLVMThinPool(node)
     if node.getType() == "lvmthinlv":
         self.nodeIsLVMThinLv(node)
         if (device.cached):
             node.addAttribute("cached", "True")
     if node.getType() == "btrfs volume":
         self.nodeIsBTRFS(node)
     if node.getType() == "mdarray":
         self.nodeIsMDRAID(node) 
     if node.getType() == "lvmsnapshot":
         self.nodeIsLVMSnapshot(node)
         new_edge = edge.Edge(device.origin.name, node.getName())
         new_edge.addGvAttribute("style", "dashed")
         self.edge_list.append(new_edge)
         node.addAttribute("Snap. origin",device.origin.name)
     self.node_list.append(node)
     for parent in device.parents:
         edge_to_be_added = edge.Edge(parent.name, device.name)
         self.edge_list.append(edge_to_be_added)
예제 #7
0
파일: network.py 프로젝트: ni1s/animats
 def hasNode(self, node):
     if type(node) == str or type(node) == unicode:
         return self.findNode(node) != None
     else:
         return self.findNode(node.getName()) != None
예제 #8
0
 def displayNode(self):
     """creates a graphical dialog to display a nodes information
     which will be shown in a seperate dialog"""
     currNodes = self.graph.nodes()
     nodeName, ok = dialogs.DisplayNode.getDataDialog(currNodes)
     if ok:
         node = self.graph.getNode(nodeName)
         # displays the selected nodes information in a message box
         message = QtGui.QMessageBox.information(self, "View Node", "Name: {0}\nStorage: {1}".format(node.getName(), node.getStorage()))
예제 #9
0
 def addNode(self, node):
     """add a node to the graph. The input must be a Node"""
     nodeName = node.getName()
     self.add_node(nodeName, obj = node) # add the node to the graph by name storing the Node in obj
     self._labels[nodeName] = nodeName # add the name to the labels dictionary