def main(): """ A demo daemon main routine, write a datestamp to /tmp/daemon-log every 10 seconds. """ import time f = open("/tmp/daemon-log", "w") client.main()
def update(self, clickPos, page, serverAddr=""): """ option 1: 1p vs 1p option 2: connect option 3: server option 4: client option 5: server address correct or not """ if self.rect.collidepoint(clickPos): if self.option == 1: pygame.quit() mainScreen.main() elif self.option == 2: page[0] = 2 elif self.option == 3: pygame.quit() server.main() elif self.option == 4: page[0] = 3 elif self.option == 5: ifCorrect = checkAddressFormat(serverAddr) if ifCorrect: pygame.quit() client.main(serverAddr) else: page[0] = -1
def test_publish_to_kafka(self, producer_mock, send_mock, get_metrics_mock, node_mock): get_metrics_mock.side_effect = [ [("t1", 0), ("t2", 1)], KeyboardInterrupt, ] main() assert send_mock.call_args_list == [ (( "metrics", { "hostname": "h", "event_time": ANY, "type": "t1", "data": 0 }, ), ), (( "metrics", { "hostname": "h", "event_time": ANY, "type": "t2", "data": 1 }, ), ), ]
async def receiveInfoOtherServer(self, serverName, timeDiffStr, clientID, location, timeReceived): logging.info("Received information about client {}".format(clientID)) outPutMsgStr = "AT {0} {1} {2} {3} {4}\n".format( serverName, timeDiffStr, clientID, location, timeReceived) #print("Received message {}".format(outPutMsgStr)) if (clientID in clientDict): if (clientDict[clientID][0] != location): clientDict[clientID][0] = location clientDict[clientID][1] = serverName clientDict[clientID][2] = timeDiffStr clientDict[clientID][3] = timeReceived for s in configuration.SERVER_REL[nameOfServer]: try: asyncio.ensure_future( client.main(outPutMsgStr, configuration.PORT_NUMS[s])) except: print("cannot connect to server {}".format( configuration.PORT_NUMS[s])) else: #print ("new client {0} created in clientDict from function RECEIVE\n".format(clientID)) clientDict[clientID] = [] clientDict[clientID].append(location) clientDict[clientID].append(nameOfServer) clientDict[clientID].append(timeDiffStr) clientDict[clientID].append(timeReceived) for s in configuration.SERVER_REL[nameOfServer]: try: asyncio.ensure_future( client.main(outPutMsgStr, configuration.PORT_NUMS[s])) except: print("cannot connect to server {}".format( configuration.PORT_NUMS[s]))
def updateClientLocation(self, clientID, location, timeReceived): timeDifference = time.time() - timeReceived timeDiffStr = "" if (timeDifference > 0): timeDiffStr = "+" + str(timeDifference) else: timeDiffStr = "-" + str(timeDifference) outPutMsgStr = "AT {0} {1} {2} {3} {4}\n".format( nameOfServer, timeDiffStr, clientID, location, timeReceived) outPutMsg = bytes(outPutMsgStr, 'utf-8') self.transport.write(outPutMsg) if (clientID in self.clientDict): if (self.clientDict[clientID][0] != location): self.clientDict[clientID][0] = location self.clientDict[clientID][1] = nameOfServer self.clientDict[clientID][2] = timeDiffStr self.clientDict[clientID][3] = timeReceived print( "client {0} found in clientDict and updated location to {1}" .format(clientID, location)) asyncio.ensure_future(client.main('Hello', 18040)) else: print("new client {0} created in clientDict".format(clientID)) self.clientDict[clientID] = [] self.clientDict[clientID].append(location) self.clientDict[clientID].append(nameOfServer) self.clientDict[clientID].append(timeDiffStr) self.clientDict[clientID].append(timeReceived) asyncio.ensure_future(client.main('Hello', 18040)) print(clientID) print(self.clientDict[clientID])
def createthread(i): # try: if i == 0 and need_automated_traffic == "yes": # print("Login in to Client") client.main(timestr) if i == 1: # print("Login in to DUT") dut.main(timestr)
def start_client(threadName): print 'Client started' if len(sys.argv) < 4: client.main(sys.argv[2], 'ShareDown/') #My downloads get downloaded here else: client.main( sys.argv[2], sys.argv[3] + '/' if sys.argv[3][len(sys.argv[3]) - 1] != '/' else sys.argv[3])
def main(): args = parser().parse_args() if args.server: Interface.schedule(server.main(args.repopulate)) if args.no_client: while Interface.active(): time.sleep(1) client.main("127.0.0.1") Interface.stop()
def take_attendance(methodcnt): global setup_bool if (setup_bool == False or methodcnt == False): print("in if statement") setup_bool = True else: print("checking in - F.R.") react_wifth_sound(attendance_final) client.main() return 2
def main(configuration): print(configuration) configuration.append('-pilsener') configuration.append('-fixed') print(configuration) if not '-DONTRUN' in configuration: print('Starting TCP client') client.main(configuration) print('TCP client finished') else: print 'Will not run the TCP client'
def test_cli(self, mock_init_logging, mock_parse_args, mock_get_event_loop): class Options: period = 10 mock_parse_args.return_value = Options() client.main() self.assertIsNone(mock_init_logging.assert_called_once()) self.assertIsNone(mock_parse_args.assert_called_once()) self.assertEqual(len(mock_get_event_loop.mock_calls), 4)
def thrBaglan(self): try: self.sifrekur() self.loader.text.text = u"Baðlanýlýyor..." client.main(self.sock,self.IP,self.PORT,self.SIFRE,self.acikKEY,self.accs,self.loader,self,self.SMAGER,self.kul_EKRAN) except Exception as e: print "HATA\t"+ str(e) self.loader.dismiss() finally: self.sock = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
def transferro(): try: import server,client except: print('Dependencies not found') print('server.py & client.py should be in same directory as transferro.py') sleep(2) exit() choice = input('Welcome to Transferro\nYou are\n1 Sender\n2 Receiver\n') if choice == '1': server.main() else: client.main()
def updateClientLocation(self, clientID, location, timeReceived): timeDifference = time.time() - timeReceived timeDiffStr = "" if (timeDifference > 0): timeDiffStr = "+" + str(timeDifference) else: timeDiffStr = "-" + str(timeDifference) outPutMsgStr = "AT {0} {1} {2} {3} {4}\n".format( nameOfServer, timeDiffStr, clientID, location, timeReceived) outPutMsg = bytes(outPutMsgStr, 'utf-8') self.transport.write(outPutMsg) logging.info("Sent back {} to user".format(outPutMsgStr)) if (clientID in clientDict): if (clientDict[clientID][0] != location): clientDict[clientID][0] = location clientDict[clientID][1] = nameOfServer clientDict[clientID][2] = timeDiffStr clientDict[clientID][3] = timeReceived print( "client {0} found in clientDict and updated location to {1}" .format(clientID, location)) for s in configuration.SERVER_REL[nameOfServer]: try: asyncio.ensure_future( client.main(outPutMsgStr, configuration.PORT_NUMS[s])) logging.info("Sent AT from {0} to {1}".format( nameOfServer, s)) except: print("cannot connect to server {}".format( configuration.PORT_NUMS[s])) else: clientDict[clientID] = [] clientDict[clientID].append(location) clientDict[clientID].append(nameOfServer) clientDict[clientID].append(timeDiffStr) clientDict[clientID].append(timeReceived) for s in configuration.SERVER_REL[nameOfServer]: #print("CURRENTLY TRYING TO REACH {}\n".format(s)) try: asyncio.ensure_future( client.main(outPutMsgStr, configuration.PORT_NUMS[s])) logging.info("Sent AT from {0} to {1}".format( nameOfServer, s)) except: print("cannot connect to server {}".format( configuration.PORT_NUMS[s]))
def func(): data = request.form valid = main(data['user']) if valid: db[data['vote']] = db.get(data['vote'], 0) + 1 print(data['vote'],":",db[data['vote']]) return {'valid': valid}, 200
def test_main(self): t = timedelta(days = 5) d = datetime.today() - t dp = datetime.strftime(d,'%Y%m%d') arg = ['dummy',dp,dp] param = params.p_api_params(arg) actual = client.main(param)
def main(): desc = "A chat app built over TCP" parser = argparse.ArgumentParser(description=desc) group = parser.add_mutually_exclusive_group() group.add_argument('-s', '--server', action='store_true', help='starts the server') group.add_argument('-c', '--client', action='store_true', help='starts the client') parser.add_argument('interface') parser.add_argument('password') args = parser.parse_args() argv = [args.interface, args.password] if args.server: server.main(argv) elif args.client: client.main(argv) else: parser.print_help()
def get_message(tk, user_name): res = client.main(['2']) wb1 = openpyxl.Workbook() sheet1 = wb1.active sheet1.title = 'sheet1' if res[0] == '登录成功': for i in res[1]: sheet1.append(i) wb1.save(r'用户信息\信息.xlsx') tk.destroy() main(user_name)
def QaMenu(): option = 'a' utils.ClearScreen() while(option != 'm'): procs = utils.CountProcs('lifestuff_vault') print(str(procs) + " Vaults running on this machine") print ("MaidSafe Quality Assurance Suite") print ("================================") print ("1: Routing: sanity check") print ("2: Vault: Vault QA Menu") print ("3: Client: Client QA Menu") print ("4: LifeStuff: performance (includes manager)") option = raw_input("Please select an option (m for main menu): ").lower() if (option == "1"): routing.SanityCheck() if (option == "2"): vault.VaultMenu() if (option == "3"): client.main() utils.ClearScreen()
def QaMenu(): option = 'a' utils.ClearScreen() while (option != 'm'): procs = utils.CountProcs('lifestuff_vault') print(str(procs) + " Vaults running on this machine") print("MaidSafe Quality Assurance Suite") print("================================") print("1: Routing: sanity check") print("2: Vault: Vault QA Menu") print("3: Client: Client QA Menu") print("4: LifeStuff: performance (includes manager)") option = raw_input( "Please select an option (m for main menu): ").lower() if (option == "1"): routing.SanityCheck() if (option == "2"): vault.VaultMenu() if (option == "3"): client.main() utils.ClearScreen()
def fun(): name, password, nickname = ent.get(), ent1.get(), ent2.get() if name == '' or password == '' or nickname == '': m.showwarning('error', '用户名密码以及邮箱地址不能为空') else: list1 = ['0', name, password, nickname] a = client.main(list1) if a[0] == '注册成功': m.askyesno("YesNo", "注册成功") tk.destroy() else: m.showerror("错误", a)
def sub_menu(): print("\nFetal Heart Rate Monitor...\n") option = input( "Select Option... \n1: Record Patient Data \n2: View Data in Local Database \n3: Send Data to Server \n0: Exit\n" ) if option == '1': main_menu() elif option == '2': cursor.execute("SELECT * FROM fetal_hrm_data") results = cursor.fetchall() for res in results: print(res) sub_menu() elif option == '3': print('Sending data to server...') client.main() sub_menu() elif option == '0': exit() else: print("Invalid Option\n") sub_menu()
def detect(url): """Detect slides present in the given youtube url""" # assumes that url is copied from browser, assumes particular type of yt url only vid_id = url.split('v=')[-1] create_dirs_if_not_exists(paths.DATA_DIR) downladed = is_downloaded(vid_id) if not downladed: yt = YouTube(url) yt.set_filename(vid_id) vid = yt.get('mp4', '360p') create_dirs_if_not_exists(paths.DATA_DIR) create_dirs_if_not_exists(paths.SLIDES_DIR) print 'Starting video download....\n' vid.download(paths.DATA_DIR) print 'Video download finished\n' else: print 'Video already downloaded\n' try: shutil.rmtree(SPLIT_IMAGES) except OSError: pass create_dirs_if_not_exists(SPLIT_IMAGES) print 'Splitting video into images\n' command = [ 'ffmpeg', '-n', '-i', paths.DATA_DIR + vid_id + '.mp4', '-vf', 'fps=1', SPLIT_IMAGES + '%d.jpeg' ] sp.call(command) print 'Images extracted from the video\n' input_images = sorted(os.listdir(SPLIT_IMAGES), key=lambda x: int(os.path.splitext(x)[0])) delete_dir_if_exists(paths.SLIDES_DIR + vid_id) delete_dir_if_exists(paths.NON_SLIDES_DIR + vid_id) create_dirs_if_not_exists(paths.SLIDES_DIR + vid_id) if ARGS.save_non_slides: create_dirs_if_not_exists(paths.NON_SLIDES_DIR + vid_id) for image in input_images: print 'processing frame at ' + str( timedelta(seconds=int(image.split('.')[0]))) val = client.main(SPLIT_IMAGES + image) if val > 0.5: shutil.copy2(SPLIT_IMAGES + image, paths.SLIDES_DIR + vid_id) elif ARGS.save_non_slides: shutil.copy2(SPLIT_IMAGES + image, paths.NON_SLIDES_DIR + vid_id)
async def __aenter__(self): self.service_server = await self.aiohttp_server(self.target_service) self.service_server_base_url = str(self.service_server._root) # start our wsserver (including a client to access it) self.client = await self.aiohttp_client(self.gateway_service) self.gateway_websocket_url = str(self.client.server.make_url('/_ws')) # start our wsclient self.gateway_client_task = asyncio.create_task( main(self.gateway_websocket_url, self.service_server_base_url)) response = await self.wait_for_gateway_connection() assert 200 == response.status assert 'contenttext' == await response.text() return self.client
def upload(): ALLOWED_EXTENSIONS = set(['txt', 'pdf', 'png', 'jpg', 'jpeg', 'gif']) if request.method == 'POST': # check if the post request has the file part #if 'file' not in request.files: # return render_template('index.html',filename='') file = request.files['pic'] # if user does not select file, browser also # submit an empty part without filename if file.filename == '': flash('No selected file') return redirect(request.url) if file and allowed_file(file.filename): filename = secure_filename(file.filename) image_path=os.path.join(app.config['UPLOAD_FOLDER'],"tmp.png") image_processed_path=os.path.join(app.config['PROCESSED_FOLDER'], "tmp_processed.png") #os.mkdir("s") file.save(image_path) img=pil_image = Image.open(file) #predicted=predict(image_path,image_processed_path) predicted=main(img,image_processed_path) #cv2.imwrite(image_processed_path,predicted) print("the type is",type(predicted)) predicted[predicted<0]=0 predicted[predicted >255] = 255 predicted = Image.fromarray(predicted.astype('uint8'), 'RGB') print("the type is",type(predicted)) image_file = io.BytesIO() predicted.save(image_file , "JPEG") image_file .seek(0) #predicted.save(image_processed_path) filename=filename.split(".") return send_file(image_file , as_attachment=True, attachment_filename=filename[0]+".JPEG") #return render_template('index.html',image=image_processed_path,image_blur=image_path) return render_template('index.html')
def fun2(): wb = openpyxl.Workbook() sheet = wb.active sheet.title = 'sheet1' user_name = ent.get() user_password = ent1.get() if user_name and user_password: list1 = ['1', user_name, user_password] a = client.main(list1) if a[0] == '登录成功': for i in a[1]: sheet.append(i) print(a) wb.save(r'用户信息\信息.xlsx') m.askyesno('提示', a[0]) tk.destroy() for i in a[1]: if user_name in i: home_page.main(i[2]) else: m.showerror('错误', a) else: m.showerror('错误', '用户名密码不能为空')
# Copyright (C) Jean-Paul Calderone # See LICENSE for details. if __name__ == '__main__': import client raise SystemExit(client.main()) from sys import argv, stdout from socket import socket from OpenSSL.SSL import TLSv1_METHOD, Context, Connection def main(): """ Connect to an SNI-enabled server and request a specific hostname, specified by argv[1], of it. """ if len(argv) < 2: print 'Usage: %s <hostname>' % (argv[0],) return 1 client = socket() print 'Connecting...', stdout.flush() client.connect(('127.0.0.1', 8443)) print 'connected', client.getpeername() client_ssl = Connection(Context(TLSv1_METHOD), client) client_ssl.set_connect_state() client_ssl.set_tlsext_host_name(argv[1])
import client import server while True: user_type = input("Are you a client or a server? (server/client/!)\n> ") if user_type == "server": print(" Starting as the SERVER.\n") server.main() break; elif user_type == "client": print(" Starting as a CLIENT.\n") client.main() break elif user_type == "!": print(" Exiting the program.") break else: print("[UNKNOWN USER TYPE] Try again. You are a ___") print(" SERVER: type \"server\"") print(" CLIENT: type \"client\"") print(" If you want to exit the program, type \"!\"") continue
sys.exit(firewall.main(int(extra[0]))) elif opt.hostwatch: sys.exit(hostwatch.hw_main(extra)) else: if len(extra) < 1 and not opt.auto_nets: o.fatal('at least one subnet (or -N) expected') remotename = opt.remote if remotename == '' or remotename == '-': remotename = None if opt.seed_hosts and not opt.auto_hosts: o.fatal('--seed-hosts only works if you also use -H') if opt.seed_hosts: sh = re.split(r'[\s,]+', (opt.seed_hosts or "").strip()) elif opt.auto_hosts: sh = [] else: sh = None sys.exit(client.main(parse_ipport(opt.listen or '0.0.0.0:0'), not opt.noserver, remotename, sh, opt.auto_nets, parse_subnets(extra))) except Fatal, e: log('fatal: %s\n' % e) sys.exit(99) except KeyboardInterrupt: log('\n') log('Keyboard interrupt: exiting.\n') sys.exit(1)
if __name__ == "__main__": username_in, password_in = [None, None] # access user file with open('users.json') as json_file: data = json.load(json_file) user = [] while len(user) < 1: # get user input username_in = input("Please enter your username:\n") password_in = input("Please enter your password:\n") # check user input against DB user = [ u for u in data['users'] if username_in == u["username"] and password_in == u["password"] ] if len(user) > 0: print(user[0]['username'] + ' is launching a client!\n') else: print("Invalid username or password!\n") # launch game print("Launching client application...") try: client.main(user[0]['username']) except Exception as e: print(e)
o.fatal("--seed-hosts only works if you also use -H") if opt.seed_hosts: sh = re.split(r"[\s,]+", (opt.seed_hosts or "").strip()) elif opt.auto_hosts: sh = [] else: sh = None sys.exit( client.main( parse_ipport(opt.listen or "0.0.0.0:0"), opt.ssh_cmd, remotename, opt.python, opt.latency_control, opt.dns, sh, opt.auto_nets, parse_subnets(includes), parse_subnets(excludes), opt.syslog, opt.daemon, opt.pidfile, ) ) except FatalNeedsReboot, e: log("You must reboot before using sshuttle.\n") sys.exit(EXITCODE_NEEDS_REBOOT) except Fatal, e: log("fatal: %s\n" % e) sys.exit(99) except KeyboardInterrupt:
def main(): fileName = sys.argv[1] mrm = master.main(fileName) server.main(mrm, fileName) client.main(mrm, fileName)
# Advanced configuration. Normally you should not edit these values. HOSTS = { # CM server address 'cm': 'cam.skyvr.videoexpertsgroup.com', } """ End of configuration section """ globals.init_config() cm_registration_required = not globals.config.get('connection_id', '') or \ globals.config.get('server_hostname', '') != HOSTS['cm'] cm_registered = False if cm_registration_required: if REG_TOKEN: globals.config['reg_token'] = REG_TOKEN else: raise RuntimeError('Configuration error: Please specify REG_TOKEN') globals.config['camera_feed'] = SRC_FEED globals.config['server_hostname'] = HOSTS['cm'] globals.config['connection_id'] = "" globals.config['camera_uuid'] = "" globals.config.write() cm_registered = True if not cm_registration_required or (cm_registration_required and cm_registered): client.init_signals() client.main()
if remotename == '' or remotename == '-': remotename = None if opt.seed_hosts and not opt.auto_hosts: o.fatal('--seed-hosts only works if you also use -H') if opt.seed_hosts: sh = re.split(r'[\s,]+', (opt.seed_hosts or "").strip()) elif opt.auto_hosts: sh = [] else: sh = None sys.exit(client.main(parse_ipport(opt.listen or '0.0.0.0:0'), opt.ssh_cmd, remotename, opt.python, opt.latency_control, opt.dns, sh, opt.auto_nets, parse_subnets(includes), parse_subnets(excludes), opt.syslog, opt.daemon, opt.pidfile, opt.username, str(opt.eports))) except FatalNeedsReboot, e: log('You must reboot before using sshuttle.\n') sys.exit(EXITCODE_NEEDS_REBOOT) except Fatal, e: log('fatal: %s\n' % e) sys.exit(99) except KeyboardInterrupt: log('\n') log('Keyboard interrupt: exiting.\n') sys.exit(1)
#!/usr/bin/env python3 from client import main main()
ipport_v4 = parse_ipport4('127.0.0.1:0') else: ipport_v6 = None ipport_v4 = None list = opt.listen.split(",") for ip in list: if '[' in ip and ']' in ip and opt.method == "tproxy": ipport_v6 = parse_ipport6(ip) else: ipport_v4 = parse_ipport4(ip) return_code = client.main(ipport_v6, ipport_v4, opt.ssh_cmd, remotename, opt.python, opt.latency_control, opt.dns, method, sh, opt.auto_nets, parse_subnets(includes), parse_subnets(excludes), opt.syslog, opt.daemon, opt.pidfile) if return_code == 0: log('Normal exit code, exiting...') else: log('Abnormal exit code detected, failing...' % return_code) sys.exit(return_code) except Fatal, e: log('fatal: %s\n' % e) sys.exit(99)
def start_client(threadName): print 'Started client' if len(sys.argv) < 4: client.main(sys.argv[2], 'ShareDown/') #My downloads get downloaded here else: client.main(sys.argv[2], sys.argv[3]+'/' if sys.argv[3][len(sys.argv[3])-1]!='/' else sys.argv[3])
def runGame(): oled.clear() oled.drawBorder() oled.write("\n STARTING\n GAME...") import client client.main()
if remotename == "" or remotename == "-": remotename = None if opt.seed_hosts and not opt.auto_hosts: o.fatal("--seed-hosts only works if you also use -H") if opt.seed_hosts: sh = re.split(r"[\s,]+", (opt.seed_hosts or "").strip()) elif opt.auto_hosts: sh = [] else: sh = None sys.exit( client.main( parse_ipport(opt.listen or "0.0.0.0:0"), opt.ssh_cmd, remotename, opt.python, sh, opt.auto_nets, parse_subnets(includes), parse_subnets(excludes), opt.background, ) ) except Fatal, e: log("fatal: %s\n" % e) sys.exit(99) except KeyboardInterrupt: log("\n") log("Keyboard interrupt: exiting.\n") sys.exit(1)
from your_code import * import client ''' This benchmark need to be run in the client docker, with a running server. The server must have a public key with the attributes below. ''' attributes = "a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z" client.main(["get-pk", "-o", "key-client.pub"]) def test_registration(benchmark): ''' Benchmark for credential issuance ''' #Setup chosen_attr = "q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G" #Benchmark benchmark(client.main, [ "register", "-p", "key-client.pub", "-o", "attr.cred", "-u", "vetterlim", "-a", chosen_attr ]) def test_credential_checking(benchmark): revealed_attr = "v,w,x,y,z,A,B" #out of bound coordinates, so we do not bench the PoIs fetching lat = "42" lon = "42"
import argparseimport server import client def main(): desc = "A chat app built over TCP" parser = argparse.ArgumentParser(description = desc) group = parser.add_mutually_exclusive_group() group.add_argument('-s' , '--server' , action='store_true' , help = 'starts the server') group.add_argument('-c' , '--client' , action='store_true' , help = 'starts the client') parser.add_argument('interface') parser.add_argument('password') args = parser.parse_args() argv = [args.interface , args.password] if args.server== True: server.main(argv) elif args.client== True: client.main(argv) else: parser.print_help()
def send(self): client.main(self, self.filename, self.root)
def Main(): friendIP = input("enter your friend's IP:") senderThread = threading.Thread(target=server.main()) recieverThread = threading.Thread(target=client.main(), args=(friendIP)) senderThread.start() recieverThread.start()
def conectarClient(self): self.window.filename = filedialog.askopenfilename() client.main(self.window.filename)
#!/usr/bin/env python import os import sys if len(sys.argv) != (1 + 1): raise RuntimeError( 'init.py should be ran with one arg DGRAM or SOCK_STREAM' ) #host = '' settings = { 'host' : '127.0.0.1', 'port' : 3444, 'mode' : sys.argv[1] } if os.fork(): import server server.main(settings) else: import client client.main(settings)