Esempio n. 1
0
    def __init__(self):
        super().__init__()

        self.setSocket(1, 0, Socket([
            None, None,
            EntranceConnection(), EntranceConnection(),
            EntranceConnection(), EntranceConnection(),
            EntrancePagoda(), EntranceCountTiles(7)
        ]))

        self.setSocket(2, 0, Socket([
            EntranceColor(EntranceColor.RED), None,
            None, EntranceColor(EntranceColor.RED),
            None, None,
            EntranceConnection(), EntranceConnection()
        ]))

        self.setSocket(0, 1, Socket([
            None, EntranceCountBridges(1),
            EntranceConnection(), EntranceConnection(),
            None, None,
            None, None
        ]))

        self.setSocket(1, 1, Socket([
            EntranceConnection(), EntranceConnection(),
            None, None,
            None, None,
            EntranceConnection(), EntranceConnection()
        ]))
Esempio n. 2
0
    def __init__(self):
        super().__init__()

        self.setSocket(1,0, Socket([
            None, None,
            None, EntranceColor(EntranceColor.PURPLE),
            EntranceConnection(), EntranceConnection(),
            EntranceColor(EntranceColor.RED), None
        ]))

        self.setSocket(0, 1, Socket([
            EntranceColor(EntranceColor.YELLOW), None,
            EntranceConnection(), EntranceConnection(),
            None, EntranceColor(EntranceColor.RED),
            None, None
        ]))

        self.setSocket(1, 1, Socket([
            EntranceConnection(), EntranceConnection(),
            EntranceConnection(), EntranceConnection(),
            None, None,
            EntranceConnection(), EntranceConnection()
        ]))

        self.setSocket(2, 1, Socket([
            None, EntranceColor(EntranceColor.PURPLE),
            None, None,
            EntranceColor(EntranceColor.YELLOW), None,
            EntranceConnection(), EntranceConnection()
        ]))
Esempio n. 3
0
    def __init__(self):
        super().__init__()

        self.setSocket(0, 0, Socket([
            None, None,
            None, EntranceCountTiles(2),
            EntranceConnection(), EntranceConnection(),
            None, EntrancePagoda()
            ]))

        self.setSocket(0, 1, Socket([
            EntranceConnection(), EntranceConnection(),
            None, EntrancePagoda(),
            None, None,
            None, None
        ]))
Esempio n. 4
0
 def run(self, ssid=None, passwd=None):
     """OH SNAP HERE COME DATBOI"""
     logger.log("Starting DATBOI..")
     if (ssid == "" or ssid is None) and (passwd == "" or passwd is None):
         return self.VALIDATION_ERRORS["ERR_EMPTY"]
     else:
         self.ssid = ssid
         self.set_status(1)
         self.socket = Socket(ssid, passwd, self)
Esempio n. 5
0
    def __init__(self, nick, serverAddr, recvMessageCallback, newClientCallback, handshakeDoneCallback, errorCallback):
        self.clients = {}

        self.nick = nick
        self.sock = Socket(serverAddr)
        self.recvMessageCallback = recvMessageCallback
        self.newClientCallback = newClientCallback
        self.handshakeDoneCallback = handshakeDoneCallback
        self.errorCallback = errorCallback
        self.sendThread = SendThread(self.sock, self.errorCallback)
        self.recvThread = RecvThread(self.sock, self.recvMessage, self.errorCallback)
        self.messageQueue = Queue.Queue()
Esempio n. 6
0
    def __init__(self):
        super().__init__()

        self.setSocket(0, 0, Socket([
            None, None,
            None, None,
            EntranceConnection(), EntranceConnection(),
            EntrancePagoda(), None
            ]))

        self.setSocket(2, 0, Socket([
            None, None,
            None, EntrancePagoda(),
            EntranceConnection(), EntranceConnection(),
            None, None
            ]))

        self.setSocket(0, 1, Socket([
            EntranceConnection(), EntranceConnection(),
            EntranceConnection(), EntranceConnection(),
            None, None,
            None, None
            ]))

        self.setSocket(1, 1, Socket([
            None, None,
            EntranceConnection(), EntranceConnection(),
            EntranceCountBridges(1), EntranceYinYang(),
            EntranceConnection(), EntranceConnection()
            ]))

        self.setSocket(2, 1, Socket([
            EntranceConnection(), EntranceConnection(),
            None, None,
            None, EntranceCountBridges(2),
            EntranceConnection(), EntranceConnection()
            ]))
Esempio n. 7
0
    def __init__(self, protocol_id, timeout):
        self._protocol_id = protocol_id
        self._timeout = timeout

        self._mode = None
        self.running = False

        self.state = None
        self.socket = Socket()
        self.address = Address()
        self.timeout_accumulator = 0

        self.local_sequence_number = 0

        self.clear_data()
Esempio n. 8
0
def main():
    port = 30000
    print("Creating socket on port {}".format(port))
    socket = Socket()

    if not socket.open(port):
        print("Failed to create socket")
        return

    addresses = get_addresses_from_file('addresses.txt')

    while 1:
        data = 'Hello world'
        for address in addresses:
            socket.send(address, data, len(data))

        while 1:
            bytes_read, sender = socket.receive(1024)
            if not bytes_read:
                break
            print("Received packet from {}.{}.{}.{} ({} bytes)".format(
                sender.a, sender.b, sender.c, sender.d, len(bytes_read)))

        time.sleep(0.5)
Esempio n. 9
0
def main():
    port = 30000
    print("Creating socket on port {}".format(port))

    socket = Socket()
    if not socket.open(port):
        print("Failed to open socket")
        return

    while 1:
        data = 'Hello world'

        socket.send(Address(a=127, b=0, c=0, d=1, port=port), data, len(data))

        while 1:
            bytes_read, sender = socket.receive(1024)
            if not bytes_read:
                break

            print(sender)
            print("Received packet from {} ({} bytes)".format(
                sender.address, sender.port, bytes_read))

        time.sleep(0.25)
Esempio n. 10
0
    import sys
    import optparse
    import pickle
    import h5py

    usage = '%prog <save/load> filename'
    parser = optparse.OptionParser(usage)
    options, args = parser.parse_args()

    if len(args) < 2:
        sys.exit(parser.format_help())

    import setup
    from sock import Socket

    scope = Socket(setup.scope_ip, timeout=20.0)
    scope.clear()

    if args[0] == 'save':
        settings = get_settings(scope)
        for command, setting in settings.items():
            print('%s, %s' % (command, setting))
        f = open(args[1], 'wb')
        pickle.dump(settings, f)
        f.close()
    elif args[0] == 'load':
        try:
            f = h5py.File(args[1], 'r')
            settings = dict(f.attrs)
            f.close()
        except h5py.h5e.LowLevelIOError: