def setup(self): self.hub = Hub()
class test_Hub(Case): def setup(self): self.hub = Hub() def teardown(self): self.hub.close()
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)
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])
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
for i in range(k): sol[0][solp[i]] = 1 sol[1][soln[i] + t - 1] = solp[i] v = 1 for j in range(n): if labels[j] == labels[solp[i]] and j != solp[i]: sol[1][soln[i] + t - v - 1] = j v += 1 t += soln[i] sol[1] = [t + 1 for t in sol[1]] return sol dataFile = '50.5' h = Hub.pHub(dataFile) mo = MetaOperator.MetaOperator() np = 50 mi = 100 pc = 30 pm = 20 pop = [] cpop = [] cpop2 = [] mpop = [] besti = [] archive = [] start_time = time.time()
def setUp(self): self.hub = Hub()
class test_Hub(Case): def setUp(self): self.hub = Hub() def tearDown(self): self.hub.close()