def botCreateLinkStep4(message): params.append(message.text) parametr = link.Link(params[0], params[1], params[2], params[3]) db_worker = SQLiter('codes.db') db_worker.insert_row(message.from_user.id, parametr.getCode(), parametr.getChannelLink(), parametr.getNotSub(), parametr.getSub()) db_worker.connection.commit() db_worker.close() links.append(link.Link(params[0], params[1], params[2], params[3])) startWork(message)
def test_is_ssl(self): link = l.Link("index", "http://stackoverflow.com/") self.assertFalse(link.is_ssl()) link.set_base("https://stackoverflow.com/") self.assertTrue(link.is_ssl()) link.set_raw_value("http://rivergillis.com/") self.assertFalse(link.is_ssl())
def msg_makeLink(self, msg): if msg.localID in self.links.keys(): raise Exception('A link with ID %s already exists' % msg.localID) if msg.localID in self.payeeLinks.keys(): raise Exception('A payee link with ID %s already exists' % msg.localID) if msg.localID[0] == '_': raise Exception('Names starting with an underscore are reserved, and can not be used') self.links[msg.localID] = link.Link(remoteID=msg.remoteID, localID=msg.localID) self.connections[msg.localID] = \ persistentconnection.PersistentConnection( host=msg.remoteHost, port=msg.remotePort, connectMessage=messages.ConnectLink( ID=msg.remoteID, #TODO: find a way to update this whenever it changes: callbackHost=msg.localHost, callbackPort=msg.localPort, callbackID=msg.localID ) ) return []
def read_link(): #reading Link Data print 'reading link data ...' with open('Partition6467LinkData.csv', 'rb') as csvfile: spamreader = csv.reader(csvfile, delimiter=',', quotechar='|') i = 0 for row in spamreader: # print 'row_length=',row[16] link_obj = link.Link(row) # for shape_point in link_obj.shape_points: # x.append(shape_point.longitude) # y.append(shape_point.latitude) # print 'No=',i,'latitude=', shape_point.latitude, 'longitude=', shape_point.longitude #For displaying nodes only # x.append(link_obj.reference_node.longitude) # y.append(link_obj.reference_node.latitude) # print 'No=', i, 'latitude=', link_obj.reference_node.latitude, 'longitude=', link_obj.reference_node.longitude # # x.append(link_obj.non_reference_node.longitude) # y.append(link_obj.non_reference_node.latitude) # print 'No=', i, 'latitude=', link_obj.non_reference_node.latitude, 'longitude=', link_obj.non_reference_node.longitude i = i + 1 # print type(link_obj.reference_node.latitude) link_data.append(link_obj)
def parse_links(f): links = [] l_map = {} num_links = int(next_line(f)) for i in xrange(num_links): link_id = next_line(f) # Input link rate is in MB/s. Convert to # pass link_rate into constructor in bytes per second link_rate = (next_line(f, 'f')) * 1e6 / 8 # print link_rate # Input link delay is in milliseconds. Convert to # seconds when passing to constructor link_delay = next_line(f, 'f') * 0.001 # Input buffer size is in MB. # Passing buffer size into constructor in bytes link_buffer_size = next_line(f, 'f') * 1e3 # print link_buffer_size # Construct link and add to link map and list of links l = link_class.Link(link_id, link_rate, link_delay, link_buffer_size) l_map[link_id] = l links.append(l) # Set the map for the link class link_class.Link.l_map = l_map return (links, l_map)
def read_link(): #reading Link Data print 'Reading link data ...' with open('Partition6467LinkData.csv', 'rb') as csvfile: spamreader = csv.reader(csvfile, delimiter=',', quotechar='|') for i, row in enumerate(spamreader): link_obj=link.Link(row) link_data.append(link_obj)
def setUp(self): self.ID = "L1" self.left = "H1" self.right = "H2" self.rate = "10" self.delay = "10" self.buff = "64" self.l = link.Link(self.ID,self.left,self.right,self.rate,self.delay,self.buff)
def Start(): global lnk import link print("Link ENABLED") lnk = link.Link(120) lnk.enabled = True lnk.startStopSyncEnabled = True linked = True
def create_network(self,line): fields = line.split() if len(fields) < 2: return start = self.get_node(fields[0]) for i in range(1,len(fields)): end = self.get_node(fields[i]) l = link.Link(self.address,start,endpoint=end) self.address += 1 start.add_link(l)
def StartLink(): global lnk import link print("Link ENABLED") lnk = link.Link(120) lnk.enabled = True lnk.startStopSyncEnabled = True SendOSCUI('/bpm', "120")
def __init__(self): ''' Constructor ''' self.imagen = pygame.image.load("imagenes/escenario2.png").convert() self.antorcha = pygame.image.load("imagenes/laantorcha.gif").convert() self.win = pygame.image.load("imagenes/creditos.jpg").convert() #self.antorchaRect = self.antorcha.get_rect() self.miLink = link.Link() self.enemigo = ganon.Ganon() self.rect = self.imagen.get_rect() self.escena3 = escenario3.Escenario3()
def __init__(self): self.cursor_mouse = cursor_mouse.CursorMouse() self.imagen = pygame.image.load("imagenes/escena1.png").convert() self.puerta = pygame.image.load("imagenes/puerta.png").convert() self.rect_puerta = self.puerta.get_rect() #Rectangulo de la puerta self.rect_puerta.centerx = 300 self.rect_puerta.centery = 50 self.rect = self.imagen.get_rect() self.enemigos = enemigos.Enemigos() self.miLink = link.Link() self.rect_link = self.miLink.obtenerRect() self.miEscena2 = escenario2.Escenario2()
def justificationToLink(just): linkList = [] just = just.replace('(', '').replace(')', '').replace('\r', '') justList = just.split('\n') justListTemp = [] justListTemp2 = [] for j in justList: justListTemp.extend(j.split(',')) for j in justListTemp: if 'Post. ' in j: continue else: justListTemp2.extend(j.split(' ')) justList = justListTemp2 print justList for j in justList: comp = j.replace(',', '').replace(' ', '').split('.') print comp if comp[0] in [ '', '\r', 'Above', 'Cor', '.', 'As', 'in', 'as', 'or', 'converse', 'and', 'to' ]: continue elif (comp[0] == '13'): #one edge case in book 7 print "Book 7 edge" l = link.Link('Def', 7, 13) linkList.append(l) elif comp[0] == 'C': if len(comp) == 3 and len(comp[2]) > 0: l = link.Link('Com', 1, int(comp[2])) linkList.append(l) else: for i in range(1, 6): l = link.Link('Com', 1, i) linkList.append(l) elif comp[0] == 'Post' or comp[1] == 'Post': l = link.Link('Pos', 1, int(comp[-1])) linkList.append(l) elif comp[0] == 'Def': book = romanToBook(comp[1]) l = link.Link('Def', book, int(comp[2])) linkList.append(l) elif comp[1] == 'Def': book = romanToBook(comp[0]) l = link.Link('Def', book, int(comp[2])) linkList.append(l) else: book = romanToBook(comp[0]) l = link.Link('Pro', book, int(comp[1])) linkList.append(l) return linkList
def setUp (self): self.lNode = node.Node("h1") self.rNode = node.Node("h2") # don't need flow, as no packet timeouts created to callback to flow # and node receive is a dummy function for i in 1, 2, 3: self.lPs.append(packet.Packet("","h1","h2","data",i,1000)) # 1000kbit self.rPs.append(packet.Packet("","h2","h1","data",i,1000)) self.link = link.Link("l1", "h1", "h2", 1000.0, 10.0, 3000.0) # 1000kbit/ms, 10 ms prop delay, 3000kbit buffers self.sim = event_simulator.Event_Simulator({"l1":self.link, \ "h1":self.lNode, \ "h2":self.rNode})
def __init__(self, core_id, idc_id, id, upload_capacity, download_capacity): self.id = id self.super_core_id = core_id self.idc_id = idc_id self.block_list = {} # blockid: blockinfo self.link = link.Link(upload_capacity, download_capacity) self.task_status = {} # blockid: finished or not(0:1) self.status = 0 # finished all self.sender_list = { } # {(super_core_id, idc_id, server_id): download block info} self.receiver_list = { } # {(super_core_id, idc_id, server_id): upload block info}
def __init__(self): self.miLink = link.Link() self.enemigo = ganon.Ganon() self.imagenEscenario3 = pygame.image.load( "imagenes/escenario3.jpg").convert() self.rect = self.imagenEscenario3.get_rect() self.perfil1 = pygame.image.load("imagenes/ganonPerfil.gif") self.perfil2 = pygame.image.load("imagenes/linkPerfil.gif") self.letra = pygame.font.SysFont("Algerian", 20) self.color = (250, 0, 0) self.barraVida = pygame.image.load("imagenes/barraVida.png") self.turno = True self.vidaGanon = self.enemigo.obtenerVida() self.vidaLink = self.miLink.obtenerVida() self.gana = "Ninguno"
def test_page_create_links(self): # This test is very slow page = p.Page("http://rivergillis.com/about/") correct_link_str = { "http://rivergillis.com/", "http://rivergillis.com/about/", "http://rivergillis.com/posts/", "http://rivergillis.com/feed.xml", "https://github.com/rivergillis", "https://twitter.com/rivergillis", "http://rivergillis.com/resume.pdf" } correct_links = set() for link in correct_link_str: correct_links.add(l.Link(link, "http://rivergillis.com/about/")) self.assertEqual(page.get_links(), correct_links)
def collect_references(self): """Populates the pkm (local) references (links and images).""" markdownbody = markdown.markdown(self.body_text) # markdownbody = markdown.markdown(page_to_validate.content, extensions=['wikilinks']) doc = etree.fromstring(markdownbody, etree.HTMLParser()) # collect links for link_element in doc.xpath('//a'): self.body_links.append(link.Link(link_element)) # collect images for image_element in doc.xpath('//img'): self.body_images.append(image.Image(image_element))
def newtempo(tempo): global lnk #print("val2", val2, "tempo", tempo) if linked == True: lnk.enabled = False lnk.startStopSyncEnabled = False lnk = link.Link(tempo) lnk.enabled = True lnk.startStopSyncEnabled = True bpm = tempo print(("New BPM", bpm)) midix.SendUI('/bpm', [bpm]) else: print("Link is disabled")
def newtempo(tempo): global lnk #print("val2", val2, "tempo", tempo) if gstt.link == True: lnk.enabled = False lnk.startStopSyncEnabled = False lnk = link.Link(tempo) lnk.enabled = True lnk.startStopSyncEnabled = True gstt.currentbpm = tempo print("New BPM", tempo) SendOSCUI('/bpm', tempo) #SendOSCUI('/bpm', [gstt.currentbpm]) #AllStatus("New BPM : "+ str(tempo)) else: print("Link is disabled")
def R18(): size_packet=8 # in bits num_packets=5 list_data=[] #err_prob=0 #loss_prob=0.03 rate_link= 2000000 # bits/s delay_prop_link=0.01 # m/s #delay_proc_router=0.01 #queue_router=2 for i in range(num_packets): list_data.append(physical.Databits(i,size_packet)) env=simpy.Environment() A=link.Host(env,'mac_a') B=link.Host(env,'mac_b') rA=link.Router(env,0.1,3,'mac_rA') l1=link.Link(env,'l1',rate_link,delay_prop_link) A.addHandler(l1.getHandler) B.addHandler(l1.getHandler) l1.addHandler(rA.getHandler) l1.addHandler(A.getHandler) l1.addHandler(B.getHandler) rA.addHandler(l1.getHandler) A.sendData(list_data, 'mac_rA') B.sendData(list_data, 'mac_rA') env.run(until=1000)
1: 3 } } # packet to host 2 through interface 1 for cost 3 router_b = network.Router(name='B', intf_cost_L=[1, 3], intf_capacity_L=[500, 100], rt_tbl_D=router_b_rt_tbl_D, max_queue_size=router_queue_size) object_L.append(router_b) #create a Link Layer to keep track of links between network nodes link_layer = link.LinkLayer() object_L.append(link_layer) #add all the links link_layer.add_link(link.Link(client, 0, router_a, 0)) link_layer.add_link(link.Link(router_a, 1, router_b, 0)) link_layer.add_link(link.Link(router_b, 1, server, 0)) #start all the objects thread_L = [] for obj in object_L: thread_L.append(threading.Thread(name=obj.__str__(), target=obj.run)) for t in thread_L: t.start() #create some send events for i in range(5): priority = i % 2 print(priority)
table_d = [(2, 3), (3, 4)] router_d = network_3.Router(name='D', intf_count=4, max_queue_size=router_queue_size, forward_t=table_d) object_L.append(router_d) # create a Link Layer to keep track of links between network_3 nodes link_layer = link.LinkLayer() object_L.append(link_layer) # add all the links # link parameters: from_node, from_intf_num, to_node, to_intf_num, mtu # connect client 1 to router a link_layer.add_link(link.Link(client_1, 0, router_a, 0, 50)) # connect client 2 to router a link_layer.add_link(link.Link(client_2, 0, router_a, 1, 50)) #Upper port values are OUTPUT ports else input link_layer.add_link(link.Link(router_a, 2, router_b, 0, 50)) # connect a to b link_layer.add_link(link.Link(router_b, 1, router_d, 0, 50)) # connect b to d link_layer.add_link(link.Link(router_a, 3, router_c, 0, 50)) # connect a to c link_layer.add_link(link.Link(router_c, 1, router_d, 1, 50)) # connect c to d # connect server 1 to router d link_layer.add_link(link.Link(router_d, 2, server_1, 0, 50))
cost_D=cost_D, max_queue_size=router_queue_size) object_L.append(router_a) cost_D = {'H2': {1: 3}, 'RA': {0: 1}} # {neighbor: {interface: cost}} router_b = network.Router(name='RB', cost_D=cost_D, max_queue_size=router_queue_size) object_L.append(router_b) #create a Link Layer to keep track of links between network nodes link_layer = link.LinkLayer() object_L.append(link_layer) #add all the links - need to reflect the connectivity in cost_D tables above link_layer.add_link(link.Link(host_1, 0, router_a, 0)) link_layer.add_link(link.Link(router_a, 1, router_b, 0)) link_layer.add_link(link.Link(router_b, 1, host_2, 0)) #start all the objects thread_L = [] for obj in object_L: thread_L.append(threading.Thread(name=obj.__str__(), target=obj.run)) for t in thread_L: t.start() ## compute routing tables router_a.send_routes(1) #one update starts the routing process sleep(simulation_time) #let the tables converge # router_a.rt_tbl_D = router_b.rt_tbl_D
if __name__ == '__main__': import doctest doctest.testmod() import sys port = None port = sys.argv[1:] and sys.argv[1] or False serial_num = sys.argv[2:] and sys.argv[2] or False if not port or not serial_num: print "usage:\n%s <port> <serial>, eg /dev/ttyUSB0 208850" % sys.argv[0] sys.exit(1) import link import stick import session from pprint import pformat logging.basicConfig(stream=sys.stdout, level=logging.DEBUG) log.info( "howdy! I'm going to take a look at your pump and grab lots of info.") stick = stick.Stick(link.Link(port, timeout=.400)) stick.open() session = session.Pump(stick, serial_num) log.info(pformat(stick.interface_stats())) log.info('PUMP MODEL: %s' % session.read_model()) do_commands(session) log.info(pformat(stick.interface_stats())) #get_pages(session) #log.info(pformat(stick.interface_stats( ))) log.info("howdy! we downloaded a lot of pump info successfully.") # stick.open( )
0: 1 }, 'H2': { 2: 1 } } # {neighbor: {interface: cost}} router_d = network.Router(name='RD', cost_D=cost_D, max_queue_size=router_queue_size) object_L.append(router_d) #create a Link Layer to keep track of links between network nodes link_layer = link.LinkLayer() object_L.append(link_layer) #add all the links - need to reflect the connectivity in cost_D tables above link_layer.add_link(link.Link(host_1, 0, router_a, 0)) link_layer.add_link(link.Link(router_a, 1, router_b, 0)) link_layer.add_link(link.Link(router_a, 2, router_c, 0)) link_layer.add_link(link.Link(router_b, 1, router_d, 0)) link_layer.add_link(link.Link(router_c, 1, router_d, 1)) link_layer.add_link(link.Link(router_d, 2, host_2, 0)) #start all the objects thread_L = [] for obj in object_L: thread_L.append(threading.Thread(name=obj.__str__(), target=obj.run)) for t in thread_L: t.start() ## compute routing tables
if __name__ == '__main__': import doctest doctest.testmod() import sys port = None port = sys.argv[1:] and sys.argv[1] or False if not port: print "usage:\n%s /dev/ttyUSB0" % sys.argv[0] sys.exit(1) import link from pprint import pformat logging.basicConfig(stream=sys.stdout, level=logging.DEBUG) log.info("howdy! I'm going to take a look at your carelink usb stick.") stick = Stick(link.Link(port)) stick.open() log.info('test fetching product info %s' % stick) log.info(pformat(stick.product_info())) log.info('get signal strength of %s' % stick) signal = 0 while signal < 50: signal = stick.signal_strength() log.info('we seem to have found a nice signal strength of: %s' % signal) log.info(""" at this point, we could issue remote commands to a medical device, let's inspect the interfaces""".strip()) #log.info(pformat(stick.usb_stats( ))) #log.info(pformat(stick.radio_stats( ))) log.info(pformat(stick.interface_stats())) """
def test_get_full_hyperlink(self): test_link = l.Link("/index", "http://rivergillis.com/") self.assertEqual(test_link.full_hyperlink, "http://rivergillis.com/index/") test_link.set_raw_value("/index.html") self.assertEqual(test_link.full_hyperlink, "http://rivergillis.com/index.html") test_link.set_raw_value("/index#sadf") self.assertEqual(test_link.full_hyperlink, "http://rivergillis.com/index/") test_link.set_raw_value("//stackoverflow.com") self.assertEqual(test_link.full_hyperlink, "http://stackoverflow.com/") # self.assertEqual(c.clean_link(base_url, "../", root_url), ?) # self.assertEqual(c.clean_link(base_url, "../../", root_url), ?) test_link.set_raw_value("#sadf") self.assertEqual(test_link.full_hyperlink, "http://rivergillis.com/") test_link.set_raw_value("index.html") self.assertEqual(test_link.full_hyperlink, "http://rivergillis.com/index.html") test_link.set_raw_value("index#sdf") self.assertEqual(test_link.full_hyperlink, "http://rivergillis.com/index/") test_link.set_base("https://www.rivergillis.co.uk/test/3.5/") test_link.set_raw_value("/index") self.assertEqual(test_link.full_hyperlink, "https://www.rivergillis.co.uk/index/") test_link.set_raw_value("/index.html") self.assertEqual(test_link.full_hyperlink, "https://www.rivergillis.co.uk/index.html") test_link.set_raw_value("/index#sadf") self.assertEqual(test_link.full_hyperlink, "https://www.rivergillis.co.uk/index/") test_link.set_raw_value("//stackoverflow.com") self.assertEqual(test_link.full_hyperlink, "https://stackoverflow.com/") test_link.set_raw_value("../") self.assertEqual(test_link.full_hyperlink, "https://www.rivergillis.co.uk/test/") test_link.set_raw_value("../index") self.assertEqual(test_link.full_hyperlink, "https://www.rivergillis.co.uk/test/index/") test_link.set_raw_value("../index#asdf") self.assertEqual(test_link.full_hyperlink, "https://www.rivergillis.co.uk/test/index/") test_link.set_raw_value("../index.html") self.assertEqual(test_link.full_hyperlink, "https://www.rivergillis.co.uk/test/index.html") test_link.set_raw_value("../../") self.assertEqual(test_link.full_hyperlink, "https://www.rivergillis.co.uk/") test_link.set_raw_value("#asdf") self.assertEqual(test_link.full_hyperlink, "https://www.rivergillis.co.uk/test/3.5/") test_link.set_raw_value("index.html") self.assertEqual(test_link.full_hyperlink, "https://www.rivergillis.co.uk/test/3.5/index.html") test_link.set_raw_value("index") self.assertEqual(test_link.full_hyperlink, "https://www.rivergillis.co.uk/test/3.5/index/") test_link.set_raw_value("./foo") self.assertEqual(test_link.full_hyperlink, "https://www.rivergillis.co.uk/test/3.5/foo/") test_link.set_raw_value("./foo.html") self.assertEqual(test_link.full_hyperlink, "https://www.rivergillis.co.uk/test/3.5/foo.html") test_link.set_raw_value("./foo.html#asdf") self.assertEqual(test_link.full_hyperlink, "https://www.rivergillis.co.uk/test/3.5/foo.html") test_link.set_raw_value("./../foo") self.assertEqual(test_link.full_hyperlink, "https://www.rivergillis.co.uk/test/foo/") test_link.set_raw_value(".././foo") self.assertEqual(test_link.full_hyperlink, "https://www.rivergillis.co.uk/test/foo/")
''' Provides easy access to commonly used functions. Initializes constants. ''' import node import link import activations Node = node.Node() Link = link.Link() Activation = activations.Activation() # ---------------- # # Hyper Paramaters # # ---------------- # # Sizes population = 100 generations = 30 # Node type node_type = 'cppn' # Weight Mutations weight_mutation_strength = 2.5 weight_max_size = 8.0 # Mutation Chance chance_inherit_disabled_gene = 0.75 chance_mutate_weight = 0.8
object_L.append(host3) router_a = network.Router(name='A', intf_count_in=2, intf_count_out=2, max_queue_size=router_queue_size, inLUT=aTable) object_L.append(router_a) router_b = network.Router(name='B', intf_count_in=1, intf_count_out=1, max_queue_size=router_queue_size, inLUT=bTable) object_L.append(router_b) router_c = network.Router(name='C', intf_count_in=1, intf_count_out=1, max_queue_size=router_queue_size, inLUT=cTable) object_L.append(router_c) router_d = network.Router(name='D', intf_count_in=2, intf_count_out=1, max_queue_size=router_queue_size, inLUT=dTable) object_L.append(router_d) # create a Link Layer to keep track of links between network nodes link_layer = link.LinkLayer() object_L.append(link_layer) # add all the links link_layer.add_link(link.Link(host1, 0, router_a, 0, 50)) #H1:0 - RA:0 link_layer.add_link(link.Link(host2, 0, router_a, 1, 50)) #H2:0 - RA:1 link_layer.add_link(link.Link(router_a, 0, router_b, 0, 50)) #RA:0 - RB:0 link_layer.add_link(link.Link(router_a, 1, router_c, 0, 50)) #RA:1 - RC:0 link_layer.add_link(link.Link(router_b, 0, router_d, 0, 50)) #RB:0 - RD:0 link_layer.add_link(link.Link(router_c, 0, router_d, 1, 50)) #RC:0 - RD:1 link_layer.add_link(link.Link(router_d, 0, host3, 0, 50)) #RD:0 - H3:0 # start all the objects thread_L = [] thread_L.append(threading.Thread(name=host1.__str__(), target=host1.run)) thread_L.append(threading.Thread(name=host2.__str__(), target=host2.run)) thread_L.append(threading.Thread(name=host3.__str__(), target=host3.run)) thread_L.append(threading.Thread(name=router_a.__str__(), target=router_a.run)) thread_L.append(threading.Thread(name=router_b.__str__(), target=router_b.run)) thread_L.append(threading.Thread(name=router_c.__str__(), target=router_c.run))