def hello_world(): print("Hello World!") print("Nigel is a poopy-but-hole") print("Just kidding") print("Or am I?") print("What?") print("Tomato!") print("Crazy") print("All the honey") print("All the D") print("This is a really big change") print(""" """) selection = input("Type home to return to the main menu: ") if selection.lower() == "home": master.master()
def runmaster(variable, scenario, bc_and_resolution, inpath, outpath, season, region, calc_file, xmin, xmax, ymin, ymax, plotter, overwrite): import master print 'you have selected calc file: ' + str(file_name) print 'you have selected inpath: ' + str(inpath) print 'you have selected outpath: ' + str(outpath) print 'you have selected scenario: ' + str(period) print 'you have selected varaible: ' + str(variable) print 'you have selected resolution: ' + str(bc) print 'you have selected plot type: ' + str(plotter) print 'you have selected season: ' + str(season) print 'you have selected region: ' + str(area_name) print 'you have selected x boundaries: ' + str(xmin), str(xmax) print 'you have selected y boundaries: ' + str(ymin), str(ymax) # print 'Please type Y to continue' continu = raw_input('Please type Y to continue ---->') if continu == 'Y' or continu == 'y': master.master(variable, scenario, bc_and_resolution, inpath, outpath, season, region, calc_file, xmin, xmax, ymin, ymax, plotter, overwrite) print 'You have finished the burrito' # season = [] # bc = [] # period = [] else: print "Burrito not running, please hit 'Run code' to try again."
def __init__(self): host_name = socket.gethostname() if os.path.isdir("sdfs/"): shutil.rmtree("sdfs/") os.system("mkdir sdfs") self.membership_manager = Peer(host_name) self.membership_manager.start() self.padding = "jyuan18?yixinz6" self.file_receive_socket = socket.socket(socket.AF_INET,socket.SOCK_STREAM) self.file_receive_socket.bind(("0.0.0.0",2333)) self.file_dict = {"filename":[1,2,3,4,5]} self.file_dict_lock = threading.Lock() self.file_to_node = {"filename":["ip1","ip2","ip3"]} self.ip = socket.gethostname() self.file_receive_socket.listen(100) logging.basicConfig(filename='vm1.log', level=logging.INFO) threading.Thread(target=self.receive_file).start() if self.ip == "fa18-cs425-g26-01.cs.illinois.edu": Master = master(self.membership_manager) threading.Thread(target=Master.listen, args=(Master.op_listen_socket, False)).start() threading.Thread(target=Master.listen, args=(Master.ack_listen_socket, True)).start()
def game(): # Generate a Random number between 1 - 1000 secret_num = random.randint(1, 1000) # Keeps track of the number of guesses in an array guesses = [] # Checks the length of "counter" to see if there are less than 20 guesses while len(guesses) < 20: # Get a number guess from the player try: guess = int(input("Guess a number between 1 and 1000: \n -->: ")) except ValueError: print("That is not a number\n") else: # Compare the guess to the secret number if guess == secret_num: print(" -->: You got it!, the secret number was {}.\n".format( secret_num)) break # Print hit/miss to show user how close they are elif guess < secret_num: print( " -->: That's not it, the secret number is greater then what you've guessed.\n" ) elif guess > secret_num: print( " -->: That's not it, the secret number is less then what you've guessed.\n" ) guesses.append(guess) else: print(" -->: You lost, the secret number was {}.\n".format(secret_num)) play_again = input("Do you want to play again? Y/n \n") if play_again.lower() != 'n': print(""" """) game() else: print("Bye!\n") master.master()
def main(): comm = MPI.COMM_WORLD procid = comm.Get_rank() dim = 16 if (len(sys.argv) > 1): dim = int(sys.argv[1]) if procid == 0: print("Starting master for async communication on %d ..." % (procid)) master(dim) else: print("Starting slave for async communication on %d ..." % (procid)) slave() return 0
def douser(): path = "D:/USER/DOWN/2.mp4" usersid = master.master(path) if usersid >= 0: userid = usersid else: userid = master.master(path) print(userid) u = hot_goods() u1 = like() lenu1 = len(u1) u22 = [] temp = season_goods() for i in temp: u22.append(i[0]) u2 = u22[::2] return render_template("homepage_people.html", u=u, u1=u1, u2=u2, lenu1=lenu1)
def main(): comm = MPI.COMM_WORLD procid = comm.Get_rank() dim = 4 if (len(sys.argv) > 1): dim = int(sys.argv[1]) if procid == 0: print("Starting master on %d ..." % (procid)) master(dim) else: print("Starting slave on %d ..." % (procid)) slave(dim) return 0
def default(self, *args, **kwargs): ''' This is the main handler for any requests recieved on this mount point. ''' if cherrypy.request.method != "GET" and cherrypy.session.get("user",None) is None: raise cherrypy.HTTPError(401, "Not authorized to %s to this source" %(cherrypy.request.method)) if "action" in kwargs: action = kwargs['action'] else: action = "view" self.parsePath(args) if cherrypy.request.method == "POST": action=self._handlePost(args,**kwargs) if action == "edit": import edit cherrypy.request.template = template = edit.edit() elif action == "upload": import upload cherrypy.request.template = template = upload.upload() elif action == "bare": if 'id_prefix' in kwargs: print "id_prefix: "+ kwargs["id_prefix"] return cherrypy.request.rst.render(settings_overrides={'id_prefix': kwargs['id_prefix']}) return cherrypy.request.rst.render() else: action = "view" import master cherrypy.request.template = template = master.master() template.action = action if cherrypy.request.resourceFileExt != ".rst": mimetype = mimetypes.guess_type(cherrypy.request.resourceFilePath) cherrypy.response.headers["Content-Type"] = mimetype[0] return open(cherrypy.request.resourceFilePath).read() elif os.path.isfile(cherrypy.request.resourceFilePath): template.rst = RstDocument(cherrypy.request.resourceFilePath) else: raise cherrypy.HTTPError(404) return self.render()
def train(dsetname='dataset_pickle', mylog=None): mylog.current("train") #training m = master(dsetname) mylog.finished("main::train>> m=master(dsetname)\nmaster: %s" % m) m.reset() print(mylog.finished("main::train>> m.reset()")) #print("main>>H,Q:".format(m.reset())) m.train(uniquename) print(mylog.finished("main::train>> m.train(uniquename)")) #recording the tree pickle file tree_file = os.path.join(path, uniquename + '.pic') pickleFile = open(tree_file, 'wb') pickle.dump(m.root, pickleFile, pickle.HIGHEST_PROTOCOL) pickleFile.close() print(mylog.finished("main::train>> recording tree")) return tree_file
def train(dsetname='dataset_pickle',mylog=None): mylog.current("train") #training m=master(dsetname) mylog.finished("main::train>> m=master(dsetname)\nmaster: %s"%m) m.reset() print(mylog.finished("main::train>> m.reset()")) #print("main>>H,Q:".format(m.reset())) m.train(uniquename) print(mylog.finished("main::train>> m.train(uniquename)")) #recording the tree pickle file tree_file=os.path.join(path,uniquename+'.pic') pickleFile = open(tree_file, 'wb') pickle.dump(m.root, pickleFile, pickle.HIGHEST_PROTOCOL) pickleFile.close() print(mylog.finished("main::train>> recording tree")) return tree_file
def main(): if not directory(): return try: script = open("input/script.txt", 'r') except OSError: print("\nSCRIPT WAS NOT FOUND.\n") return signal_time = 10 try: config = open("input/config.txt", 'r') except OSError: print("\nCONFIG WAS NOT FOUND.\n") else: try: values = lines(config) for line in values: if len(line) < 1: continue line = line.split('=') if line[0] == "signal_time": signal_time = int(line[1]) else: print("\nWRONG CONFIG INSTRUCTION.") raise Exception except Exception: print("\nCONFIG FORMAT ERROR.\n") signal_time = 10 try: # Comment to debug print("\nCONNECTION STARTED.") print("(TIME = 0)\n") time = master(signal_time, translator(script)) script.close() print("\nCONNECTION ENDED.") print("(TIME = {})\n".format(time)) except Exception: print("\nBAD FORMAT ERROR.\n")
parser.add_argument('--server', dest='server', type=str, nargs=2) parser.add_argument('--client', dest='client', type=str, nargs=2) parser.add_argument('--num_logins', const='num_logins', type=int, nargs='?', default=1, help='number of times to login to each account') parser.add_argument('--sequential_bootup', const='sequential_bootup', nargs='?', default=False, help='Some computers need to login to each account sequentially. If hexchat never boots up, try setting this option.') args=parser.parse_args() if args.debug: logging.basicConfig(filename=args.logfile[0],level=logging.DEBUG) else: logging.basicConfig(filename=args.logfile[0],level=logging.WARN) server_socket=socket.socket(socket.AF_INET, socket.SOCK_STREAM) server_socket.setblocking(1) server_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) server_socket.bind(('127.0.0.1',54321)) server_socket.listen(1024) server=master([args.server], None, args.num_logins, args.sequential_bootup) client=master([args.client], None, args.num_logins, args.sequential_bootup) client.create_server_socket(('127.0.0.1',12345), args.server[0], ('127.0.0.1',54321)) client_socket=socket.create_connection(('127.0.0.1',12345)) client_socket.setblocking(1) (server_socket, _)=server_socket.accept() r=threading.Thread(name="recv %d" % 1, target=lambda: recv(client_socket)) s=threading.Thread(name="send %d" % 1, target=lambda: send(server_socket, server)) s.start() r.start() while r.isAlive() and s.isAlive(): time.sleep(1)
def default(self, *args, **kwargs): ''' This is the main handler for any requests recieved on this mount point. ''' usar = cherrypy.session.get("user", None) if usar is not None: print usar.keys() if cherrypy.request.method != "GET" and usar is None: # if we've setup a post-recieve hook, check out this first. if self._triggerurl == cherrypy.request.path_info and cherrypy.request.app.vcs is not None: # perhaps do some exception handling and put a warning on .app that merge conflict happened? cherrypy.request.app.vcs.pull() return "" else: # otherwise: raise cherrypy.HTTPError( 401, "Not authorized to %s to this source" % (cherrypy.request.method)) if "action" in kwargs: action = kwargs['action'] else: action = "view" self.parsePath(args) if cherrypy.request.method == "POST": action = self._handlePost(args, **kwargs) if action == "create" and usar is not None and cherrypy.request.resourceFileExt == ".rst": import create cherrypy.request.template = template = create.create() print "Showing create page %s" % (cherrypy.request.path_info) filename = cherrypy.request.path_info[1:] title = filename.replace("/", ".") heading = "=" * len(title) somerst = ".. _%s:\n\n%s\n%s\n%s\n\nTODOC!\n\n.. contents ::\n :depth: 2\n\n=============\nFirst Section\n=============\n\n" % ( filename, heading, title, heading) template.rst = RstDocument() template.rst.update(somerst) template.encoded_rst = cgi.escape(template.rst.document) template.title = "Creating: %s" % (template.rst.gettitle()) template.action = action cherrypy.response.status = 404 return self.render() elif action == "edit": import edit cherrypy.request.template = template = edit.edit() elif action == "upload": import upload cherrypy.request.template = template = upload.upload() elif action == "bare": if 'id_prefix' in kwargs: print "id_prefix: " + kwargs["id_prefix"] return cherrypy.request.rst.render( settings_overrides={'id_prefix': kwargs['id_prefix']}) return cherrypy.request.rst.render() else: action = "view" import master cherrypy.request.template = template = master.master() cherrypy.request.githublink = self.githubroot template.action = action if cherrypy.request.resourceFileExt != ".rst": mimetype = mimetypes.guess_type(cherrypy.request.resourceFilePath) cherrypy.response.headers["Content-Type"] = mimetype[0] return open(cherrypy.request.resourceFilePath).read() elif os.path.isfile(cherrypy.request.resourceFilePath): template.rst = RstDocument(cherrypy.request.resourceFilePath) template.encoded_rst = cgi.escape(template.rst.document) template.title = template.rst.gettitle() else: get_parmas = urllib.quote(cherrypy.request.request_line.split()[1]) creating = get_parmas.find("action%3Dcreate") print get_parmas if creating == -1: redir = get_parmas + "?action=create" raise cherrypy.HTTPRedirect(redir) else: raise cherrypy.HTTPError(404) return self.render()
import getopt from master import master def usage(status=0): print '''Usage: ./master_test.p''' sys.exit(status) # main execution if __name__ == '__main__': # parse options try: opts, args = getopt.getopt(sys.argv[1:], "h") except getopt.GetoptError as err: print err usage() for o, a in opts: usage(1) # call master function with demo urls keywords = master([ "http://michaelsills.com/sample_links.html", "http://michaelsills.com/sample_links_2.html" ]) # print results for word in keywords: print word[0] + ' ' + str(word[1])
if args.debug: logging.basicConfig(filename=args.logfile[0],level=logging.DEBUG) else: logging.basicConfig(filename=args.logfile[0],level=logging.WARN) username_passwords=[] index=0 while index<len(args.login): username_passwords.append((args.login[index], args.login[index+1])) index+=2 if args.whitelist==None: whitelist=None else: whitelist=[] index=0 while index<len(args.whitelist): whitelist.append((args.whitelist[index], int(args.whitelist[index+1]))) index+=2 master0=master(username_passwords, whitelist) if args.client: index=0 while index<len(args.client): master0.create_server_socket((args.client[index],int(args.client[index+1])), args.client[index+2], (args.client[index+3],int(args.client[index+4]))) index+=5 while True: time.sleep(1)
import game as Game import master import worker num_agents = 10 # 500-1200 games # num_agents = 15 # 1200-5000 games # num_agents = 20 # 100,000 - 1,000,000 games # experiment to see how much choosing the agent with the highest sigma # reduces the number of games that need to by played. Implementation # is not optimal, but gains can be significant especially as the number # of agents increases pick_max_sigma = False stopping_sigma = 1 # all agent's sigmas must fall below this for us to # stop the tournament if __name__ == '__main__': comm = MPI.COMM_WORLD myid = comm.Get_rank() game = Game.NormalGame() if myid == 0: # mimics the case where the master has all the agents, depending # on how they are stored, it may make more sense to load them in # every worker...not enough info in the assignment to know which # makes more sense agents = [Game.NormalAgent(i, 3) for i in range(num_agents)] master.master(agents, stopping_sigma, pick_max_sigma) else: worker.worker(game)
try: opts, args = getopt.getopt(sys.argv[1:], "h") except getopt.GetoptError as err: print err usage() for o, a in opts: usage(1) urls = [ "http://michaelsills.com/sample_links.html", "http://michaelsills.com/sample_links_2.html" ] # call master with demo urls keywords = master(urls) # call lookup with keywords headlines = [] for url in urls: headlines += lookup(url, keywords) # sort by matches then by weight headlines.sort(key=lambda element: (element[0], element[1])) # print top two headlines for headline in headlines[:-2:-1]: print headline[2] print headline[3] print '\n', print headlines[-2][2]
cfg["env"]["ASAN_OPTIONS"] = "coverage=1:symbolize=1" cfg["env"]["MALLOC_CHECK_"] = "0" cfg["env"]["PATH"] = "%s/asan-builds/bin/:%s/asan-builds/sbin/" % (home,home) cfg["env"]["LD_LIBRARY_PATH"] = "%s/asan-builds/lib/" % home save_json("%s/cfg.json" % workdir, cfg) elif what == "select-testcases": cfg = load_json("%s/cfg.json" % workdir) seeddirs = map(os.path.abspath, args) s = selector(cfg, workdir) s.select_testcases(seeddirs) elif what == "fuzz": cfg = load_json("%s/cfg.json" % workdir) f = master(cfg, workdir, port) while True: seeds = glob.glob("seeds/*") shuffle(seeds) for seed in seeds: try: f.fuzz(seed) except: import traceback; traceback.print_exc() os.kill(os.getpid(), 9) elif what == "work": #set up worker workdir = os.path.abspath(workdir) while True: try:
'Some computers need to login to each account sequentially. If hexchat never boots up, try setting this option.' ) args = parser.parse_args() if args.debug: logging.basicConfig(filename=args.logfile[0], level=logging.DEBUG) else: logging.basicConfig(filename=args.logfile[0], level=logging.WARN) server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) server_socket.setblocking(1) server_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) server_socket.bind(('127.0.0.1', 54321)) server_socket.listen(1024) server = master([args.server], None, args.num_logins, args.sequential_bootup) client = master([args.client], None, args.num_logins, args.sequential_bootup) client.create_server_socket(('127.0.0.1', 12345), args.server[0], ('127.0.0.1', 54321)) client_socket = socket.create_connection(('127.0.0.1', 12345)) client_socket.setblocking(1) (server_socket, _) = server_socket.accept() r = threading.Thread(name="recv %d" % 1, target=lambda: recv(client_socket)) s = threading.Thread(name="send %d" % 1, target=lambda: send(server_socket, server)) s.start() r.start() while r.isAlive() and s.isAlive():
arm_and_takeoff(vehicle, 10) vehicle.airspeed = 5 print("Vehicle speed set to: " + str(vehicle.airspeed)) def close_shop(): print("Setting LAND mode...") vehicle.mode = VehicleMode("LAND") print('Close vehicle object') vehicle.close() if sitl is not None: sitl.stop() time.sleep(20) config = { "apiKey": "AIzaSyAwV9FXEvHaDjTr16yOfcoK14d0GrrGfRQ", "authDomain": "dronephone-a53c9.firebaseio.com", "databaseURL": "https://dronephone-a53c9.firebaseio.com", "storageBucket": "dronephone-a53c9.appspot.com" } currentMaster = master.master() currentMaster.activateCallLoop(config, vehicle) close_shop()
print(px[i]) ax.annotate(txt, (px[i], py[i])) plt.plot(px, py, 'bo') plt.xlabel('X') plt.ylabel('Y') plt.title("Hostesses")#Muda título do gráfico plt.show() #plt.savefig('Plot_host.png') ''' name = 'GUSSS' logging.basicConfig(filename='test.log', level=logging.INFO) # testing log #logging.info('Hello world, this is {}'.format(h1)) # Creating master m1 = master(id = 100) # Creating hostesses h1 = host(mac=1, x=1, y=0, master=m1, reach=4) h2 = host(mac=2, x=2, y=3, master=m1, reach=4) h3 = host(mac=3, x=3, y=5, master=m1, reach=4) h4 = host(mac=4, x=6, y=8, master=m1, reach=4) h5 = host(mac=10, x=5, y=7.5, master=m1, reach=4) #h6 = host(mac=6, x=3, y=2, master=m1, reach=4) #y = h1.get_instances() #plot_host(y) # ******** Starting the simulation ******** c = 0 logging.info(f"TIME : {c} \n")
import master variable = 'pr' scenario = ['rcp45'] bc_and_resolution = ['WA_data'] inpath = 'D://CMIP5/CMIP5_Africa' outpath ='D://CMIP5/save_files' season = ['jas'] region = 'West_Africa' calc_file = 'mean_rain' xmin = -10 xmax = 10 ymin = 5 ymax = 25 plotter = 'plot_histogram_anomaly' overwrite = 'No' master.master(variable, scenario, bc_and_resolution, inpath, outpath, season, region, calc_file, xmin, xmax, ymin, ymax, plotter, overwrite)
username_passwords = [] index = 0 while index < len(args.login): username_passwords.append((args.login[index], args.login[index + 1])) index += 2 if args.whitelist == None: whitelist = None else: whitelist = [] index = 0 while index < len(args.whitelist): whitelist.append( (args.whitelist[index], int(args.whitelist[index + 1]))) index += 2 master0 = master(username_passwords, whitelist, args.num_logins, args.sequential_bootup) if args.client: index = 0 while index < len(args.client): master0.create_server_socket( (args.client[index], int(args.client[index + 1])), args.client[index + 2], (args.client[index + 3], int(args.client[index + 4]))) index += 5 while True: time.sleep(1)
# -*- encoding: utf-8 -*- from flask import Flask, request from flask import jsonify from event_detection import demo from master import master from threading import Thread import os, json, time from sklearn.externals import joblib m = master() handle = Thread(target=m.run) handle.start() def build_trending_domain(trending_titles, docs_trending): # build json content trending = [] for k, title in trending_titles.items(): event = {} docs = docs_trending[k] event.update({u'title': title + u' - %d docs' % (len(docs))}) # sub_title = [] sub_title = [{u'title': name} for name in docs] event.update({u'subTitles': sub_title}) trending.append(event) return trending
def execute(self): self.entity = master.master(self.dict) return eval("self.entity.%s()" % self.cmd)
if args.debug: logging.basicConfig(filename=args.logfile[0],level=logging.DEBUG) else: logging.basicConfig(filename=args.logfile[0],level=logging.WARN) username_passwords=[] index=0 while index<len(args.login): username_passwords.append((args.login[index], args.login[index+1])) index+=2 if args.whitelist==None: whitelist=None else: whitelist=[] index=0 while index<len(args.whitelist): whitelist.append((args.whitelist[index], int(args.whitelist[index+1]))) index+=2 master0=master(username_passwords, whitelist, args.num_logins, args.sequential_bootup) if args.client: index=0 while index<len(args.client): master0.create_server_socket((args.client[index],int(args.client[index+1])), args.client[index+2], (args.client[index+3],int(args.client[index+4]))) index+=5 while True: time.sleep(1)
logging.basicConfig(filename=args.logfile[0], level=logging.WARN) username_passwords = [] index = 0 while index < len(args.login): username_passwords.append((args.login[index], args.login[index + 1])) index += 2 if args.whitelist == None: whitelist = None else: whitelist = [] index = 0 while index < len(args.whitelist): whitelist.append( (args.whitelist[index], int(args.whitelist[index + 1]))) index += 2 master0 = master(username_passwords, whitelist) if args.client: index = 0 while index < len(args.client): master0.create_server_socket( (args.client[index], int(args.client[index + 1])), args.client[index + 2], (args.client[index + 3], int(args.client[index + 4]))) index += 5 while True: time.sleep(1)
def default(self, *args, **kwargs): ''' This is the main handler for any requests recieved on this mount point. ''' usar = cherrypy.session.get("user", None) if usar is not None: print usar.keys() if cherrypy.request.method != "GET" and usar is None: # if we've setup a post-recieve hook, check out this first. if self._triggerurl == cherrypy.request.path_info and cherrypy.request.app.vcs is not None: # perhaps do some exception handling and put a warning on .app that merge conflict happened? cherrypy.request.app.vcs.pull() return "" else: # otherwise: raise cherrypy.HTTPError(401, "Not authorized to %s to this source" % (cherrypy.request.method)) if "action" in kwargs: action = kwargs['action'] else: action = "view" self.parsePath(args) if cherrypy.request.method == "POST": action = self._handlePost(args, **kwargs) if action == "create" and usar is not None and cherrypy.request.resourceFileExt == ".rst": import create cherrypy.request.template = template = create.create() print "Showing create page %s" % (cherrypy.request.path_info) filename = cherrypy.request.path_info[1:] title = filename.replace("/", ".") heading = "=" * len(title) somerst = ".. _%s:\n\n%s\n%s\n%s\n\nTODOC!\n\n.. contents ::\n :depth: 2\n\n=============\nFirst Section\n=============\n\n" % ( filename, heading, title, heading ) template.rst = RstDocument() template.rst.update(somerst) template.encoded_rst = cgi.escape(template.rst.document) template.title = "Creating: %s" % (template.rst.gettitle()) template.action = action cherrypy.response.status = 404 return self.render() elif action == "edit": import edit cherrypy.request.template = template = edit.edit() elif action == "upload": import upload cherrypy.request.template = template = upload.upload() elif action == "bare": if 'id_prefix' in kwargs: print "id_prefix: " + kwargs["id_prefix"] return cherrypy.request.rst.render(settings_overrides={'id_prefix': kwargs['id_prefix']}) return cherrypy.request.rst.render() else: action = "view" import master cherrypy.request.template = template = master.master() cherrypy.request.githublink = self.githubroot template.action = action if cherrypy.request.resourceFileExt != ".rst": mimetype = mimetypes.guess_type(cherrypy.request.resourceFilePath) cherrypy.response.headers["Content-Type"] = mimetype[0] return open(cherrypy.request.resourceFilePath).read() elif os.path.isfile(cherrypy.request.resourceFilePath): template.rst = RstDocument(cherrypy.request.resourceFilePath) template.encoded_rst = cgi.escape(template.rst.document) template.title = template.rst.gettitle() else: get_parmas = urllib.quote(cherrypy.request.request_line.split()[1]) creating = get_parmas.find("action%3Dcreate") print get_parmas if creating == -1: redir = get_parmas + "?action=create" raise cherrypy.HTTPRedirect(redir) else: raise cherrypy.HTTPError(404) return self.render()
def RUN_THE_BURRITO(): # So this is the big one # This button will run all codes for all time slices and all boundary conditions for the West Africa # Region # This is the whole enchaliada # Let's have some fun # First preset all the things that will not change import master global area_name global xmin global xmax global ymin global ymax global boundary_dictionary area_name = 'West_Africa' xmin = boundary_dictionary[area_name][0] xmax = boundary_dictionary[area_name][1] ymin = boundary_dictionary[area_name][2] ymax = boundary_dictionary[area_name][3] global outpath outpath = askdirectory() # now pull in all scenarios and all BC global period_dictionary global period period = period_dictionary.values() global bcs_dictionary global bc bc = bcs_dictionary.values() # Ok here is the sweet bit global list_of_calc_files global file_name for item in list_of_calc_files: print item string = item.split('calc_')[-1] item = string.split(".")[0] calc_file = 'calc_' + str(item) findvar = __import__(calc_file) global variable global season global plotter temp = findvar.variable_setter('plot_type') if temp != "plot type": plotter = temp temp = findvar.variable_setter('seas') if temp != "seas": season = temp temp = findvar.variable_setter('var') if temp != "var": variable = temp print "Plot type preset to: '%s'" % plotter print "Season preset to: '%s'" % season print "Variable preset to: '%s'" % variable for p in period: for b in bc: print variable, p, b, outpath, season, area_name, item, xmin, xmax, ymin, ymax, plotter master.master(variable, p, b, outpath, season, area_name, item, xmin, xmax, ymin, ymax, plotter)
c.checkspdup(y=y, m=m) c.export(option='w', y=y, m=m, outputdir=crspsp_inpath, header=True) pass for y in range(beginyear, endyear + 1): if month == 0: for m in range(1, 13): merge_crsp_sp(y, m) else: m = month merge_crsp_sp(y, m) # part III: merge with master # initialization mst = master.master(beginyear, endyear, month, file='master') def merge_crsp_master(y, m): print('{a}-{b}:\nReading master data'.format(a=y, b=m)) mst.readdata(datadir=master_inpath, y=y, m=m) mst.add8CUSIP( y=y, m=m, newcolname='CUSIP_8', outputdir=master_inpath) # add eight digit cusip to master data print('Reading crsp_sp data') c.readdata(datadir=crspsp_inpath, y=y, m=m) c.mergedata(data=mst.returndata(y, m), y=y, m=m, how='outer', left_on=['CUSIP', 'date'],
# encoding: utf-8 import time, logging from master import master from process.bitmexPublicWsUsersProcess import bitmexPublicWsUsersProcess from process.bitmexPrivateWsUsersProcess import bitmexPrivateWsUsersProcess from process.strategyProcess import strategyProcess from process.bitmexRestUsersProcess import bitmexRestUsersProcess logging.basicConfig( filename="./logs/" + time.strftime("%Y%m%d") + '.log', filemode="a", format="%(asctime)s %(name)s:%(levelname)s:%(message)s", level=logging.INFO, datefmt="%Y-%m-%d %H:%M:%S" ) mat = master() mat.add_process(bitmexPublicWsUsersProcess) mat.add_process(bitmexPrivateWsUsersProcess) mat.add_process(bitmexRestUsersProcess) mat.add_process(strategyProcess) mat.run()
index = 0 while index < len(args.login): username_passwords.append((args.login[index], args.login[index + 1])) index += 2 if args.whitelist == None: whitelist = None else: whitelist = [] index = 0 while index < len(args.whitelist): whitelist.append((args.whitelist[index], int(args.whitelist[index + 1]))) index += 2 master0 = master( username_passwords, whitelist, args.num_logins, args.sequential_bootup, args.take_measurements ) if args.client: index = 0 while index < len(args.client): master0.create_server_socket( (args.client[index], int(args.client[index + 1])), args.client[index + 2], (args.client[index + 3], int(args.client[index + 4])) ) index += 5 while True: time.sleep(1)
import os os.chdir('/Users/abhishek/Desktop/shivam/python-got-to-go/') import webbrowser import requests import json from user import user from master import master user = user() master = master() print('') print('') print('Welcome to Shouchalya Mission') print('-----------------------------') print('') print('') print("Welcome to login module") choice = int(input("Do you want to sign-in or sign-up, please select 1 or 2 ")) if choice == 1: user.login() print(user.first_name + " logged in last at " + str(user.last_login)) else: user.new_user() master.read_data() choice = 0 while choice < 4:
#!/usr/bin/python #coding:utf8 def fun(n): if n > 0: return n * fun(n - 1) else: return 1 a = fun(5) print a l = range(1, 6) print reduce(lambda x, y: x - y, l) sum = reduce(lambda x, y: x + y, l) print sum import master import master as cc cc.master() from master import master master()
#help string to print when needed help_string = "SLAVE MODE: python main.py -s | MASTER MODE: python main.py -m" try: #parse arguments opts, args = getopt.getopt(sys.argv[1:], "hsm:") except getopt.GetoptError: #if error print help string and exit print help_string sys.exit(2) # iterate through arguments for opt, arg in opts: # if help mode requested, print help and exit if opt == '-h': print help_string sys.exit() # if slave set start up restful server elif opt in ("-s", "--slave"): print 'Running as a slave' slave.slave() #if master store the config file elif opt in ("-m", "--master"): print 'Running as a master' config_file = arg master.master(config_file) else: print help_string sys.exit(2) #Collect the configured information from all the machines #collect_config("spark1.local","ubuntu","key","sample1/forloop") #collect_info_from_machines(0)