def __init__(self, parent=None, name='', physical=True, voltage=None, required=True): Port.__init__(self, parent, params={}, name=name) self.addAllowableMate(ElectricalPort) self.addParameter('voltage') self.addParameter('physical') self.addParameter('controllerPin') self.addParameter('required') self.setParameter('voltage', voltage) self.setParameter('physical', physical) self.setParameter('required', required)
def setParameter(self, name, value): if name.lower() == 'voltage' and value is not None: if not isinstance(value, (list, tuple)): return Port.setParameter(self, name, (value, value)) try: toSet = list(value[:]) toSet[0] = float(toSet[0]) toSet[1] = float(toSet[1]) toSet.sort() return Port.setParameter(self, name, toSet) except ValueError: return None return Port.setParameter(self, name, value)
def getPorts(self): ''' run an nmap TCP port scan on all ports for given ip address ''' # create a xml file to parse for results scanfile = '/tmp/temp.xml' # create a subprocess and run nmap command pScan = subprocess.call('nmap -T4 -p- {} -oX {} > /dev/null'.format( self.ip, scanfile), shell=True) # parse temp xml file tree = xml.etree.ElementTree.parse(scanfile) # create a list of port objects ports = [] # remove temporary xml file created (cleanup) os.remove('/tmp/temp.xml') # traverse through all ports found for h in tree.findall('host'): for ps in h.findall('ports'): for p in ps.findall('port'): # find port information to create Port object portID = p.attrib['portid'] transportProtocol = p.attrib['protocol'] for st in p.findall('state'): state = st.attrib['state'] for sv in p.findall('service'): service = {'name': sv.attrib['name']} # create a new Port object port = Port(portID, transportProtocol, state, service) # append Port to the list of ports found ports.append(port) # update list of ports self.ports = ports
def __init__(self, Host_Queue, state, name): self.Host_name = name self.state = state self.hostQueue = Host_Queue self.readQueue = Queue() self.Port0 = Port(hostQueue, "Blocked", 0, self.name, self.toPort) readThread = Thread(target=Read, args=(self.hostQueue, )) readThread.start()
def canMate(self, otherPort): if not otherPort.hasParameter('dataType'): return False myType = self.getParameter('dataType') otherType = otherPort.getParameter('dataType') if myType is not None and otherType is not None: if myType != otherType: return False return Port.canMate(self, otherPort)
def menu(self): print("Welcome to AFPP!") print("1> ADSL&FTTX Port.") print("2> Manage Port Data.") print("3> Exit.") ch = raw_input("Please input choice: ") p = Port() if ch == "1": p.processCmd() return False elif ch == "2": p.manageData() return False elif ch == "3": print("Bye,bye!") return True else: print("Invalid choice.") return False
def canMate(self, otherPort): if isinstance(otherPort, ElectricalPort): #if not self.isPhysical() or not otherPort.isPhysical(): # return True myVoltage = self.getParameter('voltage') otherVoltage = otherPort.getParameter('voltage') if myVoltage is not None and otherVoltage is not None: if myVoltage[1] < otherVoltage[0]: return False if myVoltage[0] > otherVoltage[1]: return False return Port.canMate(self, otherPort)
def __init__(self, parent, graph=None, face=None, edge=None, cross=None): if graph is not None: _, pt = graph.get3DCOM() elif face is not None: pt = face.get3DCOM() elif edge is not None: if cross is None: pt = edge.get3DCOM() else: from itertools import product for (p1, p2) in product(edge.pts3D, cross.pts3D): if p1 == p2: pt = p1 break else: raise ValueError("Can't find edge intersection") else: raise ValueError("No geometry specified for PointPort") params = {'dx': pt[0], 'dy': pt[1], 'dz': pt[2]} Port.__init__(self, parent, params)
def fromNode(node): status = node.find('status').attrib['state'] address = node.find('address').attrib['addr'] hostnames = None ports = [] for each in node.find('ports'): if each.tag == 'port': innerNode = Port.fromNode(each) elif each.tag == 'extraports': innerNode = ExtraPorts.fromNode(each) ports.append(innerNode) os = OS.fromNode(node.find('os')) uptime = None return Host(status, address, hostnames, ports, os, uptime)
def setParameter(self, name, value): if name == 'dataType': return Port.setParameter(self, name, str(value) if value is not None else None) return Port.setParameter(self, name, value)
def addCoupling(self, targetModel, targetName, sourceModel, sourceName): targetPort = Port(targetModel, targetName) sourcePort = Port(sourceModel, sourceName) self.couplings.append((targetPort, sourcePort)) targetModel.inports.append(targetPort) sourceModel.outports.append(sourcePort)
def __init__(self, parent, pt, heading): params = {'x': pt[0], 'y': pt[1], 'heading': heading} Port.__init__(self, parent, params)
def __init__(self, source, time, portName, value=None): assert type(time) is float self.port = Port(source, portName) self.time = time self.value = value
def addPortToPorts(self, consoleOutput): processingList = consoleOutput.rstrip("\n").split("\n") processingList = processingList[5:] for i in processingList: port = i.split() self.ports.append(Port(port[0], port[2]))
def __init__(self, dstModel, dstName, srcModel, srcName): self.destination = Port(dstModel, dstName) self.source = Port(srcModel, srcName)
def getParameter(self, name, strict=True): return Port.getParameter(self, name, strict=False)
def __init__(self): Component.__init__(self) self.port.new(s0=Port()) self.port.new(s1=Port()) self.port.new(m0=Port()) self.port.new(m1=Port())
def __init__(self, parent, obj): try: params = obj.get6DOF() except AttributeError: params = get6DOF(obj) Port.__init__(self, parent, params)
def __init__(self, parent, pname): params = {pname: parent.getParameter(pname)} Port.__init__(self, parent, params)
def add_port(self, ofpport): port = Port(self.dp.id, self.dp.ofproto, ofpport) if not port.is_reserved(): self.ports.append(port)
def __init__(self, parent, name='', dataType='string'): Port.__init__(self, parent, params={}, name=name) self.addAllowableMate(DataPort) self.addParameter('dataType', dataType) self.addParameter('protocol', 'direct')
def __init__(self, parent): Port.__init__(self, parent, {})
from Port import Port port = Port("input.txt",25) print(port.first_number_not_compliant()) print(port.encryption_weakness())
def port(self, peer, tag): from Port import Port return Port(self, peer, tag)
def test_encryption_weakness(file_name, preamble_len, result): port = Port(file_name, preamble_len) assert port.encryption_weakness() == result
def test_first_number_not_compliant(file_name, preamble_len, result): port = Port(file_name, preamble_len) assert port.first_number_not_compliant() == result
return info # load data fileName = "resources/HackathonDatapostarrival.xlsx" print("Loading data...") myList = readFile(fileName) for myVessel in myList: count = 0 for myContainer in myVessel.containers: temp = int(myContainer.size) count += temp myContainer.size = count LA = Port(0, 5625, myList) LA.unload("Sorcerer's Stone") # interact with user correct = 1 while (correct): user_type = raw_input("Please enter your user type (Company/Port/Truck): ") if (user_type == "Company" or user_type == "Port" or user_type == "Truck"): correct = 0 else: notify("wrong: please enter again ") correct = 1 # notify("Hello dear #{} user: what would you like to do? ".format(user_type)) action = raw_input( "Hello dear #{} user: what would you like to do? ".format(user_type)) if (action == "track"):
def __init__(self, parent, decoration): Port.__init__(self, parent, {}) self.decoration = decoration