Exemple #1
0
 def test_get_set_event_loop(self):
     set_event_loop(None)
     self.assertIsNone(_hub._current_loop)
     self.assertIsNone(get_event_loop())
     hub = Hub()
     set_event_loop(hub)
     self.assertIs(_hub._current_loop, hub)
     self.assertIs(get_event_loop(), hub)
Exemple #2
0
def main():
    logging.basicConfig(format='%(asctime)s|%(levelname)s|%(message)s',
                        datefmt='%H:%M:%S',
                        level=logging.INFO)
    serial_ports = serial.tools.list_ports.comports()
    boards = []
    for port in serial_ports:
        if (port.vid == 1240 and port.pid == 10):
            boards.append(port.device)
    print("Select which device to use: " + str(boards))
    COM_port = input(">")
    hub = Hub.Hub(COM_port)
    tui = TUI(hub)
    tui.show()
    def create_hubs(self, num_hubs, speed):
        for hub in ['hub{}'.format(x) for x in range(num_hubs)]:
            self.world['hubs'][hub] = Hub.Hub(hub)
            self.world['hubs'][hub].x = random.random()
            self.world['hubs'][hub].y = random.random()

        for hubA in self.world['hubs']:
            dist = []
            for hubB in self.world['hubs']:
                distance = self.distance(self.world['hubs'][hubA].x,
                                         self.world['hubs'][hubA].y,
                                         self.world['hubs'][hubB].x,
                                         self.world['hubs'][hubB].y)
                if distance != 0 and hubB not in self.world['hubs'][
                        hubA].connections:
                    dist.append([distance, hubB])

            connections = []
            number_connections = random.randint(1, 2)
            passes = 1
            while passes <= number_connections and dist != []:
                min = []
                for element in dist:
                    if min == [] or min[0] > element[0]:
                        min = [element[0], element[1], dist.index(element)]
                dist.pop(min[2])
                connections.append(min[1])
                self.world['hubs'][min[1]].connections.append(hubA)
                passes += 1

            for node in connections:
                self.world['hubs'][hubA].connections.append(node)

        for hubA in self.world['hubs']:
            for hubB in self.world['hubs'][hubA].connections:
                x1 = self.world['hubs'][hubA].x
                y1 = self.world['hubs'][hubA].y
                x2 = self.world['hubs'][hubB].x
                y2 = self.world['hubs'][hubB].y

                self.world['hubs'][hubA].roads[hubB] = Road.Road(
                    '{}:{}'.format(hubA, hubB), x1, y1, x2, y2, speed)
                self.world['hubs'][hubA].park['Trailer{}:{}'.format(
                    hubA, hubB)] = Trailer.Trailer(self.world['hubs'][hubA],
                                                   self.world['hubs'][hubB])
Exemple #4
0
import sys, os
sys.path.append(os.path.abspath('../build/debug-default/bin/'))
sys.path.append(os.path.abspath('../build/debug-mingw/bin/'))

import pyadchpp as a

from Helpers import *
from Hub import *

hub = Hub()
op = Profile('op', hub)
vip = Profile('vip', hub)

profiles = dict([(x.name, x) for x in (op, vip)])

users = [User(profile=op, nick='arnetheduck', password='******')]

nicks = dict([(x.nick, x) for x in users if x.nick])
cids = dict([(x.cid, x) for x in users if x.cid])

configPath = os.path.abspath('../etc/') + os.sep
core = a.Core.create(configPath)


def findUser(nick, cid):
    print "looking for", nick, cid
    if nick in nicks:
        return nicks[nick].password
    if cid in cids:
        return cids[cid].password
Exemple #5
0
 def setUp(self):
     self.hub = Hub()
Exemple #6
0
 def setup(self):
     self.hub = Hub()