def startServer(self): while (not self.terminated): inputs = raw_input('>>> ') inputs = inputs.split() if (inputs[0] == 'fta-server'): if (len(inputs) == 4): self.port = int(inputs[1]) self.dest_ip = inputs[2] self.dest_port = int(inputs[3]) elif (len(inputs) == 3): self.port = int(inputs[1]) self.dest_ip = '' self.dest_port = int(inputs[2]) self.server_socket = server(self.port, self.dest_port, self.dest_ip) connected = self.server_socket.connect() #Same as listen self.connected = connected self.running() elif (inputs[0] == 'terminate'): self.terminated = True print "Application Server Closing"
def check_hosts(): try: global active_hosts for host, result in execute(run_command, "uptime", hosts=env.hosts).iteritems(): if result.succeeded: active_hosts.append(server(host,22,active=True)) except Exception: pass
def main(): print( '1.send details 2.get credentials 3.generate cert 4.client 5.server 6.send device parameters' ) x = int(input("Enter choice: ")) if (x == 1): send_data() elif (x == 2): while (True): receive_data() time.sleep(1800) elif (x == 3): generate_cert() elif (x == 4): client() elif (x == 5): server() else: dparams()
def __init__(self): self.server = server() self.finger_table = table() self.server.listen_() self.local_ip = socket.gethostbyname(socket.gethostname()) self.client = client() self.friends = [] self.private_key = rsa.generate(1024) self.public_key = self.private_key.publickey() self.to_msg = None self.from_msg = None self.messages = {}
def creat_all_xml(channel, config, sid): serverinfo = select_logic_info(config, sid) sid = serverinfo['ServerId'] ActivityBossIp = serverinfo['ActivityBossIp'] ActivityBossDbName = serverinfo['ActivityBossDbName'] ActivityBossDbUser = serverinfo['ActivityBossDbUser'] ActivityBossDbPw = serverinfo['ActivityBossDbPw'] DbIp = serverinfo['DbIp'] DbName = serverinfo['DbName'] DbPw = serverinfo['DbPw'] DbUser = serverinfo['DbUser'] DynamicPort = serverinfo['DynamicPort'] AccountIP = serverinfo['AccountIP'] AccountDbName = serverinfo['AccountDbName'] AccountDbUser = serverinfo['AccountDbUser'] AccountDbPw = serverinfo['AccountDbPw'] GamePort = serverinfo['GamePort'] CsIp = serverinfo['CsIp'] CsPort = serverinfo['CsPort'] AsIp = serverinfo['AsIp'] AsPort = serverinfo['AsPort'] CsDbName = serverinfo['CsDbName'] CsDbUser = serverinfo['CsDbUser'] CsDbPw = serverinfo['CsDbPw'] ActivityBossConfiguration(channel, sid, ActivityBossIp, ActivityBossDbName, ActivityBossDbUser, ActivityBossDbPw) Configuration(channel, sid, DbIp, DbName, DbUser, DbPw) dynamicDB(channel, sid, DynamicPort) GMConfiguration(channel, sid, AccountIP, AccountDbName, AccountDbUser, AccountDbPw) serverID(channel, sid) server(channel, sid, GamePort, CsIp, CsPort, AsIp, AsPort) WarConfiguration(channel, sid, CsIp, CsDbName, CsDbUser, CsDbPw)
def json_2_server(d): if d.has_key('ip') and d.has_key('port') and d.has_key( 'username') and d.has_key('password') and d.has_key( 'susername') and d.has_key('spassword'): return server(ip=d['ip'], port=d['port'], username=d['username'], password=d['password'], susername=d['susername'], spassword=d['spassword'], comment=d['comment']) elif d.has_key('name') and d.has_key('child_groups') and d.has_key( 'hosts') and d.has_key('comment'): return jgroup(name=d['name'], child_groups=d['child_groups'], hosts=d['hosts'], comment=d['comment']) else: return d
def receivingLoop(self): print("starting receiving loop") # this thread stays alive the whole time, even if preempted. while (not self._quit): item = server(str(self._ipAddr)) if (item.messageType == Message.PING): # Send a response to the master node print("Received a ping from master. Sending pong...") self._sendingQueue.put( types.SimpleNamespace(messageType=Message.PONG)) elif (item.messageType == Message.PREEMPT): print("Received a preempt from master. Calling preempt..") self.preempt() elif (item.messageType == Message.RESTART): print( "Received a restart command from master. Calling restart..." ) self.restart() elif (item.messageType == Message.MATRICES): print("Received matrix message.") print("Time: " + str(time.time())) print("Updating based on recieved information...") print("Shape of received item:") print(np.array(item.data).shape) print("Item:") print(item.data) self._x = item.data[:int(len(item.data) / 2), :] self._matrix = item.data[int(len(item.data) / 2):, :] self._matrixReady = True elif (item.messageType == Message.RESPONSE): print("Received response from worker.") print(item.data) self._responseData = item.data self._receivedResponse[item.deviceId] = 1 time.sleep(1) else: print( "WARNING: Received an unknown command from master node: " + str(item.messageType.name))
def server_2_json(d): if type(d) == type(server()): return { 'ip': d.ip, 'port': d.port, 'username': d.username, 'password': d.password, 'susername': d.susername, 'spassword': d.spassword, 'comment': d.comment } elif type(d) == type(jgroup()): return { 'name': d.name, 'child_groups': d.child_groups, 'hosts': d.hosts, 'comment': d.comment } else: return d
def host(arg): try: ip = arg[0] port = arg[1] username = arg[2] password = arg[3] try: susername = arg[4] spassword = arg[5] except: susername = '' spassword = '' gl.jssh['services'][ip] = server(ip=ip, port=port, username=username, password=password, susername=susername, spassword=spassword) save_log('add host %s success!' % ip) except: save_log( 'add host failed! eg: 192.168.3.23 22 user password root rootpassword' )
serNUm = int(strs[4]) wQueue = waitQueue(maxQueueLen) # produce the interval time sequence refer to poisson_distribution arrTimes = npy.random.exponential(float(averArrTime), customerNum) # produce the serval time sequence refer to exponential_distribution serTimes = npy.random.exponential(averSerTime, customerNum) customers = [] countTime = 0.0 # produce the customer sequence for i in range(0, customerNum): countTime += arrTimes[i] cus = customer(arrTimes[i], serTimes[i], i, countTime) customers.insert(len(customers), cus) lastArrivalTime = customers[len(customers) - 1].arrivalTime ser = server(customers, wQueue, serNUm) ser.mmnSimulation() print("the number of arriving people per s : ", customerNum / lastArrivalTime, " p/s\n") print("the number of serving people per s : ", (ser.serveNum / ser.serveTime), " p/s\n") print("average number of people in queue : ", (wQueue.totalDelayTime / ser.currentTime), " p\n") print("average number of waiting time : ", (wQueue.totalDelayTime / ser.serveNum), " s\n") print("rate of using the server : ", (ser.serveTime / ser.currentTime), "\n") #mplot.yticks([y for y in range(maxQueueLen + 1)]) #mplot.step(ser.eventTime,ser.queueSize)
request.setHeader('Access-Control-Allow-Origin', '*') request.setHeader('Access-Control-Allow-Headers', 'Content-Type, X-Requested-With') request.setHeader("Content-Type", "application/json") return resp def render_OPTIONS(self,request): request.setHeader('Access-Control-Allow-Origin', '*') request.setHeader('Access-Control-Allow-Headers', 'Content-Type, X-Requested-With') request.setHeader("Content-Type", "application/json") return "good" if __name__ == '__main__': # startLogging(sys.stdout) # create_db() s = server() p = process(s) factory = ws_factory(p, "ws://0.0.0.0:7778") factory.setProtocolOptions(allowHixie76 = True) resource = WebSocketResource(factory) root = File("./static") root.putChild("websocket", resource) root.putChild("", post(p)) site = Site(root, ) from twisted.internet import reactor reactor.listenTCP(7778, site) lc = LoopingCall(s.tick) lc.start(TICK*0.001)
"""Application instance for {{cookiecutter.project}}. Use this module for rnning by `flask run` command or importing the application instance to use with other applications. When running this application by `gunicorn` this instance is not used at all. Gunicorn will use the `server` function to instantiate the app. This is also used for database migrations by `Flask-Migrate`. """ from {{cookiecutter.project_name}} import server application = server({})
#!/usr/bin/python3 # -*- coding: utf-8 -*- from queue import Queue from server import * from OBD_handler import * if(__name__ == '__main__'): queue_server_obd = Queue() queue_obd_server = Queue() thread1 = OBD_handler(queue_server_obd, queue_obd_server) # OBD handler thread2 = server(queue_server_obd, queue_obd_server) # Server thread1.start() thread2.start()
def connectServer(self): self.server = server(self.sock_port) self.server.main() self.server.call_arduino(self.port) self.sflg = 1
def open_list(): # 选择服务器清单 fd = askopenfilename(initialdir='.') if fd: save_log(log='%s open list %s\n' % (datetime.now(), fd)) root.title('Current file list:%s' % fd) try: server_list = open(fd) except: text.insert(END, "open file failed !\n") server_list=None if server_list: gl.server_all.clear() if any(gl.cbuts): for i in gl.cbuts.keys(): gl.cbuts[i].destroy() gl.cbuts.clear() for (num, value) in enumerate(server_list): if len(value) > 4 and not value.startswith('#'): try: hostname = value.split()[0] except: pass try: ipinfo = value.split()[1] ip_addr = ipinfo.split(":")[0] except: pass try: if gl.server_all[hostname]: err='ERROR,At line %s:Duplicate hostname %s\n' % (num,hostname) text.insert(END, err) save_log(log=err) except: pass try: if gl.server_all[hostname].ip_addr+":"+gl.server_all[hostname].port: err='ERROR,At line %s:Duplicate ip and port %s\n' % (num,ipinfo) text.insert(END, err) save_log(log=err) except: pass try: try: port = int(ipinfo.split(":")[1]) except: port = 22 username = value.split()[2] password = value.split()[3] gl.server_all[hostname] = server(ip=ip_addr, port=port, username=username, password=password) gl.server_all[hostname].selected = IntVar() gl.cbuts[hostname] = (Checkbutton(listframe, text=hostname, font=ft, bg='black', foreground="blue", variable=gl.server_all[hostname].selected)) gl.cbuts[hostname].select() gl.cbuts[hostname].pack() gl.cbuts[hostname].bind("<Button-3>", lambda event, i=hostname:find_it(event, i)) gl.cbuts[hostname].bind("<Control-Button-1>", lambda event, i=hostname:xshell(event, i)) except IndexError: err = 'ERROR,At line %s,wrong host info: %s\n' % (num + 1, value) text.insert(END, err) save_log(log=err) server_list.close() disconnect['state'] = DISABLED if any(gl.server_all): connect['state'] = ACTIVE cmd_log.flush()
def MakeDataBase(serverName, databaseName): #serverName= input('Enter the server name: ') MainServer = server(serverName, databaseName) MainServer.command("""CREATE TABLE customers( customer_id UNIQUEIDENTIFIER DEFAULT NEWID() NOT NULL PRIMARY KEY, customer_name varchar(50) NOT NULL, customer_phone varchar(11) NOT NULL UNIQUE, customer_storePreference varchar(50) NOT NULL, customer_username varchar(50) NOT NULL, customer_password varchar(50) NOT NULL );""") MainServer.command("""CREATE TABLE employees( employee_id UNIQUEIDENTIFIER DEFAULT NEWID() NOT NULL PRIMARY KEY, employee_name varchar(50) NOT NULL, employee_username varchar(50) NOT NULL, employee_password varchar(50) NOT NULL, employee_storePreference varchar(50) NOT NULL, employee_accessLevel int NOT NULL, employee_sales DECIMAL(10,2) NOT NULL, employee_phone varchar(11) NOT NULL UNIQUE);""" ) MainServer.command("""CREATE TABLE store( store_id UNIQUEIDENTIFIER DEFAULT NEWID() NOT NULL PRIMARY KEY, store_sales DECIMAL(10,2) NOT NULL, store_name varchar(50) NOT NULL UNIQUE);""") MainServer.command("""CREATE TABLE orders( order_id UNIQUEIDENTIFIER DEFAULT NEWID() NOT NULL PRIMARY KEY, customer_id UNIQUEIDENTIFIER FOREIGN KEY REFERENCES customers(customer_id), employee_id UNIQUEIDENTIFIER FOREIGN KEY REFERENCES employees(employee_id), store_id UNIQUEIDENTIFIER NOT NULL FOREIGN KEY REFERENCES store(store_id), order_date DATE NOT NULL,order_price DECIMAL(10,2) NOT NULL, payment_type varchar(50) NOT NULL, delivery_date DATE, active varchar(4) NOT NULL);""") MainServer.command("""CREATE TABLE shipments( shipment_id UNIQUEIDENTIFIER DEFAULT NEWID() NOT NULL PRIMARY KEY, order_id UNIQUEIDENTIFIER NOT NULL FOREIGN KEY REFERENCES orders(order_id), shipment_date DATE NOT NULL);""") MainServer.command("""CREATE TABLE item( item_id UNIQUEIDENTIFIER DEFAULT NEWID() NOT NULL PRIMARY KEY, item_price DECIMAL(10,2) NOT NULL,item_description varchar(50) NOT NULL, quantity_inStock int NOT NULL);""") MainServer.command("""CREATE TABLE full_set( set_id UNIQUEIDENTIFIER DEFAULT NEWID() NOT NULL PRIMARY KEY, set_description varchar(50) NOT NULL UNIQUE);""" ) MainServer.command("""CREATE TABLE set_item( set_itemId UNIQUEIDENTIFIER DEFAULT NEWID() NOT NULL PRIMARY KEY, item_id UNIQUEIDENTIFIER NOT NULL FOREIGN KEY REFERENCES item(item_id), set_itemQuantity int NOT NULL, set_id UNIQUEIDENTIFIER NOT NULL FOREIGN KEY REFERENCES full_set(set_id));""" ) MainServer.command( """INSERT INTO customers(customer_name, customer_phone, customer_storePreference, customer_username, customer_password)VALUES( 'Blake Cox', '2134567968', 'LegoTron', 'MrBlake123', '123456'), ('Jacob Butler', '1230987658', 'LegoTron', 'MrJacob456', '123456'), ('Drew Araujo', '1235436554', 'Mrs.LegoTron', 'MrDrew789', '123456');""" ) MainServer.command( """INSERT INTO employees(employee_name, employee_username, employee_password, employee_storePreference, employee_accessLevel, employee_sales, employee_phone)VALUES ('Joseph Smith', 'Mr.Smith', 'password', 'Mrs.LegoTron', 1, 10000, '2143245543'), ('Harry Potter', 'Mr.Potter', 'password1', 'Mrs.LegoTron', 2, 9000, '2145555543'), ('Billy Idol', 'Mr.Idol', 'password2', 'LegoTron', 1, 15000, '2154345543'), ('Pocahontas Lady', 'Mr.Lady', 'password3', 'LegoTron', 2, 11000, '7657655543');""" ) MainServer.command( "INSERT INTO store(store_sales, store_name)VALUES(200345, 'Mrs.LegoTron'),(591765, 'LegoTron');" ) MainServer.command( """INSERT INTO orders(customer_id, employee_id, order_date, order_price, store_id, payment_type, delivery_date, active)VALUES ((SELECT customer_id FROM customers WHERE customer_phone='2134567968'), (SELECT employee_id FROM employees WHERE employee_phone='2143245543'),'2020-04-29', 108.92, (SELECT store_id FROM store WHERE store_name='Mrs.LegoTron'), 'cash', NULL, 'yes'), ((SELECT customer_id FROM customers WHERE customer_phone='2134567968'), (SELECT employee_id FROM employees WHERE employee_phone='2143245543'),'2020-04-12', 400.92, (SELECT store_id FROM store WHERE store_name='Mrs.LegoTron'), 'visa','2020-04-29', 'no'), ((SELECT customer_id FROM customers WHERE customer_phone='1235436554'), (SELECT employee_id FROM employees WHERE employee_phone='7657655543'), '2020-05-21', 678.90, (SELECT store_id FROM store WHERE store_name='LegoTron'), 'mc', NULL, 'no'), ((SELECT customer_id FROM customers WHERE customer_phone='1235436554'), (SELECT employee_id FROM employees WHERE employee_phone='7657655543'), '2020-01-21', 70.90, (SELECT store_id FROM store WHERE store_name='LegoTron'),'cash', NULL, 'no'), ((SELECT customer_id FROM customers WHERE customer_phone='1235436554'), NULL, '2020-03-25', 432.90, (SELECT store_id FROM store WHERE store_name='Mrs.LegoTron'),'cash', NULL, 'no'), ((SELECT customer_id FROM customers WHERE customer_phone='1230987658'), (SELECT employee_id FROM employees WHERE employee_phone='2145555543'), '2020-06-28', 54.90, (SELECT store_id FROM store WHERE store_name='Mrs.LegoTron'), 'mc', NULL, 'no'), ((SELECT customer_id FROM customers WHERE customer_phone='1230987658'), (SELECT employee_id FROM employees WHERE employee_phone='2154345543'), '2020-03-21', 890.90, (SELECT store_id FROM store WHERE store_name='LegoTron'),'mc', NULL, 'no'), ((SELECT customer_id FROM customers WHERE customer_phone='1230987658'), NULL, '2020-04-21', 1023.99, (SELECT store_id FROM store WHERE store_name='LegoTron'), 'mc', NULL, 'no'), (NULL, (SELECT employee_id FROM employees WHERE employee_phone='2154345543'), '2020-02-12', 36.70, (SELECT store_id FROM store WHERE store_name='LegoTron'), 'mc', NULL, 'no');""" ) MainServer.command("""INSERT INTO shipments(order_id, shipment_date)VALUES ((SELECT order_id FROM orders WHERE order_price = 1023.99), '2020-04-22'), ((SELECT order_id FROM orders WHERE order_price = 70.90), '2020-01-22'), ((SELECT order_id FROM orders WHERE order_price = 678.90), '2020-05-22');""" ) MainServer.command( """INSERT INTO item(item_price, item_description, quantity_inStock)VALUES (.28, 'Brick 1x8 Blue', 127), (.28, 'Brick 1x8 Red', 94), (.28, 'Brick 1x8 Yellow', 342), (.28, 'Brick 1x8 Orange', 110), (.28, 'Brick 1x8 Black', 76), (.89, 'Plate 4x4 Round Orange', 132), (.89, 'Plate 4x4 Round Red', 121), (.89, 'Plate 4x4 Round Black', 212), (.89, 'Plate 4x4 Round Yellow', 87), (.89, 'Plate 4x4 Round Blue', 92), (.14, 'Plate 2x3 Yellow', 23), (.14, 'Plate 2x3 Black', 23), (.14, 'Plate 2x3 Orange', 23), (.14, 'Plate 2x3 Purple', 23), (.07, 'Nose Cone Small', 40), (.06, 'Round Brick 1x1 Green', 104), (.06, 'Round Brick 1x1 Red', 94), (.06, 'Round Brick 1x1 Yellow', 144), (.06, 'Round Brick 1x1 Maroon', 104), (.24, '.5 Circle Plate 2x6 Blue', 90), (.24, '.5 Circle Plate 2x6 Red', 99), (.24, '.5 Circle Plate 2x6 Yellow', 120), (.24, '.5 Circle Plate 2x6 Black', 81), (.24, '.5 Circle Plate 2x6 Orange', 37), (.32, 'Brick 2x8 Red', 86), (.32, 'Brick 2x8 Blue', 109), (.32, 'Brick 2x8 Green', 78), (.32, 'Brick 2x8 Orange', 120), (.32, 'Brick 2x8 Black', 139), (.53, 'Brick 4x16 Red', 86), (.53, 'Brick 4x16 Blue', 86), (.53, 'Brick 4x16 Black', 86), (.53, 'Brick 4x16 Yellow', 86), (.53, 'Brick 4x16 Orange', 86), (.53, 'Brick 4x16 Green', 86), (2.3, 'Person 1', 42), (2.3, 'Person 2', 48), (2.3, 'Person 3', 37), (2.3, 'Person 4', 9), (7.9, 'Person 5', 1), (2.3, 'Person 6', 67), (2.3, 'Person 7', 96), (.24, 'Brick 2x2 Red', 201), (.24, 'Brick 2x2 Yellow', 223), (.24, 'Brick 2x2 Blue', 231), (.24, 'Brick 2x2 Black', 278), (.24, 'Brick 2x2 Green', 301), (1.2, 'Plate 12x24 Red', 65), (1.2, 'Plate 12x24 Blue', 45), (1.2, 'Plate 12x24 Black', 76), (1.2, 'Plate 12x24 Orange', 15), (1.2, 'Plate 12x24 Yellow', 34), (.14, 'Flat Tile 1x6 Red', 45), (.14, 'Flat Tile 1x6 Blue', 56), (.14, 'Flat Tile 1x6 Black', 9), (.14, 'Flat Tile 1x6 Green', 89), (.14, 'Flat Tile 1x6 Yellow', 36), (.14, 'Flat Tile 1x6 Purple', 145), (.14, 'Flat Tile 1x6 White', 46), (.44, 'Wall Element 1x6x5 Red', 56), (.44, 'Wall Element 1x6x5 Yellow', 56), (.44, 'Wall Element 1x6x5 Blue', 56), (.44, 'Wall Element 1x6x5 White', 56), (.44, 'Wall Element 1x6x5 Black', 56);""") MainServer.command("""INSERT INTO full_set(set_description)VALUES ('Set 1'), ('Set 2'), ('Set 3');""") MainServer.command( """INSERT INTO set_item(item_Id, set_itemQuantity, set_id)VALUES ((SELECT item_id FROM item WHERE item_description = 'Plate 12x24 Red'), 2, (SELECT set_id FROM full_set WHERE set_description = 'Set 1')), ((SELECT item_id FROM item WHERE item_description = 'Plate 12x24 Orange'), 2, (SELECT set_id FROM full_set WHERE set_description = 'Set 1')), ((SELECT item_id FROM item WHERE item_description = 'Wall Element 1x6x5 Blue'), 2, (SELECT set_id FROM full_set WHERE set_description = 'Set 1')), ((SELECT item_id FROM item WHERE item_description = 'Brick 2x8 Orange'), 9, (SELECT set_id FROM full_set WHERE set_description = 'Set 1')), ((SELECT item_id FROM item WHERE item_description = 'Brick 1x8 Blue'), 15, (SELECT set_id FROM full_set WHERE set_description = 'Set 1')), ((SELECT item_id FROM item WHERE item_description = 'Brick 1x8 Orange'), 20, (SELECT set_id FROM full_set WHERE set_description = 'Set 2')), ((SELECT item_id FROM item WHERE item_description = 'Brick 1x8 Red'), 10, (SELECT set_id FROM full_set WHERE set_description = 'Set 2')), ((SELECT item_id FROM item WHERE item_description = 'Person 1'), 1, (SELECT set_id FROM full_set WHERE set_description = 'Set 2')), ((SELECT item_id FROM item WHERE item_description = 'Person 3'), 1, (SELECT set_id FROM full_set WHERE set_description = 'Set 2')), ((SELECT item_id FROM item WHERE item_description = 'Plate 12x24 Yellow'), 4, (SELECT set_id FROM full_set WHERE set_description = 'Set 2')), ((SELECT item_id FROM item WHERE item_description = 'Plate 12x24 Orange'), 3, (SELECT set_id FROM full_set WHERE set_description = 'Set 2')), ((SELECT item_id FROM item WHERE item_description = 'Plate 12x24 Black'), 3, (SELECT set_id FROM full_set WHERE set_description = 'Set 3')), ((SELECT item_id FROM item WHERE item_description = 'Person 6'), 1, (SELECT set_id FROM full_set WHERE set_description = 'Set 3')), ((SELECT item_id FROM item WHERE item_description = 'Plate 4x4 Round Black'), 3, (SELECT set_id FROM full_set WHERE set_description = 'Set 3')), ((SELECT item_id FROM item WHERE item_description = 'Wall Element 1x6x5 Black'), 4, (SELECT set_id FROM full_set WHERE set_description = 'Set 3')), ((SELECT item_id FROM item WHERE item_description = 'Wall Element 1x6x5 Blue'), 3, (SELECT set_id FROM full_set WHERE set_description = 'Set 3')), ((SELECT item_id FROM item WHERE item_description = 'Nose Cone Small'), 10, (SELECT set_id FROM full_set WHERE set_description = 'Set 3'));""" ) MainServer.command("COMMIT TRANSACTION") MainServer.endConnection() print("Finished Making tables")
while "moi" not in locals(): try: choix = int(input("Veuillez entrer votre choix: ")) - 1 assert 0 <= choix <= len(profiles) + 1 except Exception as ex: print(ex) else: if choix < len(profiles): moi = PrivateProfile(profiles[choix], getpass()) elif choix == len(profiles): moi = PrivateProfile( askopenfilename(initialdir=os.getcwd(), title="Importer un profile")) #On initialise le serveur sur un autre thread et on écoute les requêtes server = server(moi) server.start() #On initialise un editeur de texte pour des testes b = blackboard() #On ouvre un projet par defaut server.open("project", "test.txt") while True: msg = input(">>> ") if msg == "stop": break eval(msg) #On arrête le serveur et on stoppe le serveur
import sys import threading sys.path.append('classes/') sys.path.append("services/") from server import * from rpitrack import * config_array = ["timer", "lighting", "water"] #from screenmodule import * #screen = ScreenModule() myServer = server(50007, config_array, 5) rpt = RPiTrack() exit = 0 while exit == 0: print("0 EXIT") print("1 Start Server") print("2 Close Server") print("3 Close connections") print("4 Send Message to all connections") print("5 Display RPi informations") var = raw_input("What to do \n") if (not var or int(var) == 0): if myServer.ServerOn == True: myServer.CloseServer() #all services needs to have a CloseService method #screen.close() exit = 1
if __name__ == '__main__': #Define attached pin atachments Right_R=17 Right_F=4 Left_R=21 Left_F=22 #setup move routines drive=move() drive.setup(Right_F,Right_R,Left_F,Left_R) #start server try: soc=server() ser=soc.setup(1337,5) connection,address = ser.accept() while 1: message=connection.recv(4096) if message == '': print "client cut connection, exiting" raise KeyboardInterrupt print message if message == 'w': drive.forward() time.sleep(.5) drive.stop() if message == 's':
def startServer(): port=portText.get() server(int(port)) uplineState["text"]="成功上线!"
add t1d, 0 add t1d, 0 // faster sw_complete .sw_dbg 111111111111110 001 00 000000000000 add t1d, 0 add t1d, 0 add t1d, 0 """) # create server and ucode objects serial_port = os.environ["MY_SERIALPORT"] gpio_pins = os.environ["MY_GPIOPINS"] serv = server(serial_port, gpio_pins) uc = ucode() uc.header.loaddefaultheader() uc.header.match_register_list[0] = 0x120 #uc.header.init_flag = 1 uc.set_triads(UcodeAs(ucode_rtl).assemble(), negate=True) # send ucode update data = uc.getbytes_crypt(True) # append HMAC data+= struct.pack('<LL', 0x8abf7f10, 0x5c17c730) fastpath = True if fastpath:
mov dword [ebx + 0x10], esi mov dword [ebx + 0x14], edi mov dword [ebx + 0x18], ebp mov dword [ebx + 0x1C], esp pushfd pop eax mov dword [ebx + 0x20], eax ; restore reg state and return to angry OS popad ret """) # create server and ucode objects serial_port = os.environ["MY_SERIALPORT"] gpio_pins = os.environ["MY_GPIOPINS"] serv = server(serial_port, gpio_pins) uc = ucode() uc.header.loaddefaultheader() # 0xaca - shrd # 0x972 - div uc.header.match_register_list[1] = 0xaca ucode_rtl = (""" mov ebp, 0xdead sll ebp, 16 or ebp, 0xbeef mov eax, eax mov eax, eax
#On demande à l'utilisateur de faire un choix while "moi" not in locals(): try: choix = int(input("Veuillez entrer votre choix: "))-1 assert 0 <= choix <= len(profiles)+1 except Exception as ex: print(ex) else: if choix < len(profiles): moi = PrivateProfile(profiles[choix], getpass()) elif choix == len(profiles): moi = PrivateProfile(askopenfilename(initialdir=os.getcwd(),title="Importer un profile")) #On initialise le serveur sur un autre thread et on écoute les requêtes server = server(moi) server.start() #On initialise un editeur de texte pour des testes b = blackboard() #On ouvre un projet par defaut server.open("project", "test.txt") while True: msg = input(">>> ") if msg=="stop": break eval(msg) #On arrête le serveur et on stoppe le serveur
if __name__ == '__main__': #Define attached pin atachments Right_R = 17 Right_F = 4 Left_R = 21 Left_F = 22 #setup move routines drive = move() drive.setup(Right_F, Right_R, Left_F, Left_R) #start server try: soc = server() ser = soc.setup(1337, 5) connection, address = ser.accept() while 1: message = connection.recv(4096) if message == '': print "client cut connection, exiting" raise KeyboardInterrupt print message if message == 'w': drive.forward() time.sleep(.5) drive.stop() if message == 's':
a = b = c = d = 0 return ('%d.%d.%d.%d' % (a, b, c, d), port) # [1:2::3]:456 or [1:2::3] or 456 def parse_ipport6(s): s = str(s) m = re.match(r'(?:\[([^]]*)])?(?::)?(?:(\d+))?$', s) if not m: raise Fatal('%s is not a valid IP:port format' % s) (ip, port) = m.groups() (ip, port) = (ip or '::', int(port or 0)) return (ip, port) optspec = """ sshuttle [-l [ip:]port] [-r [username@]sshserver[:port]] <subnets...> sshuttle --server sshuttle --firewall <port> <subnets...> sshuttle --hostwatch -- l,listen= transproxy to this ip address and port number H,auto-hosts scan for remote hostnames and update local /etc/hosts N,auto-nets automatically determine subnets to route dns capture local DNS requests and forward to the remote DNS server method= auto, nat, tproxy, or ipfw python= path to python interpreter on the remote server r,remote= ssh hostname (and optional username) of remote sshuttle server x,exclude= exclude this subnet (can be used more than once) X,exclude-from= exclude the subnets in a file (whitespace separated) v,verbose increase debug message verbosity
def test_server_wo_args(self): self.assertEqual(server())
s = str(s) m = re.match(r"(?:(\d+)\.(\d+)\.(\d+)\.(\d+))?(?::)?(?:(\d+))?$", s) if not m: raise Fatal("%r is not a valid IP:port format" % s) (a, b, c, d, port) = m.groups() (a, b, c, d, port) = (int(a or 0), int(b or 0), int(c or 0), int(d or 0), int(port or 0)) if a > 255 or b > 255 or c > 255 or d > 255: raise Fatal("%d.%d.%d.%d has numbers > 255" % (a, b, c, d)) if port > 65535: raise Fatal("*:%d is greater than the maximum of 65535" % port) if a == None: a = b = c = d = 0 return ("%d.%d.%d.%d" % (a, b, c, d), port) optspec = """ sshuttle [-l [ip:]port] [-r [username@]sshserver[:port]] <subnets...> sshuttle --server sshuttle --firewall <port> <subnets...> sshuttle --hostwatch -- l,listen= transproxy to this ip address and port number [127.0.0.1:0] H,auto-hosts scan for remote hostnames and update local /etc/hosts N,auto-nets automatically determine subnets to route dns capture local DNS requests and forward to the remote DNS server python= path to python interpreter on the remote server r,remote= ssh hostname (and optional username) of remote sshuttle server x,exclude= exclude this subnet (can be used more than once) exclude-from= exclude the subnets in a file (whitespace separated) v,verbose increase debug message verbosity e,ssh-cmd= the command to use to connect to the remote [ssh]
def test_server_with_args(self): self.assertEqual(server(sys.argv[1:]))
from server import * eps = 1e-3 n = 12 # agent 数量 m = 2000 # 服务器数量 ntype = 4 # 服务器种类 ntask = 10000 # 任务数量 rate = [82, 10, 57, 14] # 种类对应的处理速率 Qos = 0 # avg response time # 服务器列表 server_list = [server(0,49.6,272,82) for i in range(500)] + [server(1,15.9,45.1,10) for i in range(500)] + \ [server(2,122,580,57) for i in range(500)] + [server(3,63.2,236,14) for i in range(500)] _lambda = [[1], [2]] # 到达速率 for n agents _gamma = 0 # 分级的数目 mm1_start_limit = 10000 mm1_end_limit = 100000 mm1_interval = int((mm1_end_limit - mm1_start_limit) / 100)
from customerFunction import * from employeeFunction import * from newUser import * from server import * from Populate_Server import * from addRevenue import * t=0 #This loop connects and checks the connection to the server while t==0: serverName= input('Enter the server name: ') #serverName="DESKTOP-LPJK5QO\SCHOOL" databaseName=input('Enter a valid database name: ') #databaseName="Legos" try: MainServer=server(serverName, databaseName) t=1 except: print("could not connect") t=0 ###Blakes Test ### #serverName='RXLBCOXLT\BLAKESMSQLSERVER' #databaseName='Lego' #MainServer=server(serverName, databaseName) #This function will poplulate an empty database with exsample tables first=input("Do you need to create the tables for the first time?y for yes, n for no: ") if first=='y' or first=='Y': MakeDataBase(serverName,databaseName)
import sys import threading sys.path.append('classes/') sys.path.append("services/") from server import * from rpitrack import * config_array = ["timer", "lighting", "water"] #from screenmodule import * #screen = ScreenModule() myServer = server( 50007, config_array, 5 ) rpt = RPiTrack() exit = 0 while exit == 0: print("0 EXIT") print("1 Start Server") print("2 Close Server") print("3 Close connections") print("4 Send Message to all connections") print("5 Display RPi informations") var = raw_input("What to do \n") if (not var or int(var) == 0): if myServer.ServerOn == True: myServer.CloseServer() #all services needs to have a CloseService method #screen.close() exit = 1