def show_configuration(name): ##exec("from instrumentation import *") # -> locals() ##ConfigurationPanel(name=self.configuration.name,globals=self.globals,locals=self.locals) from start import start start( "SavedPositionsPanel_2", "ConfigurationPanel(name=%r,globals=globals(),locals=locals())" % name)
def start_1(): """ :return:system110 """ # print(b, 'b\n', e, 'e\n', a4, 'a4\n', a24, 'a24\n', l, 'l\n', f1, 'f1\n', c3c3, 'c3c3\n', ao3, 'ao3\n', d, 'd\n') qqq = input('=====================\n' '= system 1.1.0 =\n' '= =\n' '= 输 入 1 进 入 =\n' '= 输 入 2 退 出 =\n' '= 输 入 3 返 回 =\n' '= 开 始 界 面 =\n' '======================\n' '请 输 入:') if qqq == '1': choose() elif qqq == '2': exit_2(start_1) elif qqq == '3': print('\n已返回!\n') start.start() else: print('\n无效选择!') start_1()
def kai_shi(): """ :return:system106 """ # print(b, 'b\n', e, 'e\n', a4, 'a4\n', a24, 'a24\n', l, 'l\n', f1, 'f1\n', c3c3, 'c3c3\n', ao3, 'ao3\n', d, 'd\n') qqq = input('=====================\n' '= system 1.0.6 =\n' '= =\n' '= 输 入 1 进 入 =\n' '= 输 入 2 退 出 =\n' '= 输 入 3 返 回 =\n' '= 开 始 界 面 =\n' '======================\n' '请 输 入:') if qqq == '1': xuan_ze() elif qqq == '2': exit_2(kai_shi) elif qqq == '3': print('\n已返回!\n') start.start() else: print('\n无效选择!') kai_shi()
def boot(): clear0.clear0() boot = input(CGREEN + "type 'start' to boot the system.." + CEND) secs = 0 if boot == "start": while secs != 2: print(CBGREEN + " booting up.. " + CEND.format(secs)) time.sleep(7) secs += 2 clear.clear() print( CBWHITE + "________________________________WELCOME to IngSoft 94________________________________" + CEND) print("Loading data..") time.sleep(5) clear.clear() start.start() print("") else: clear0.clear0() boot() pass pass
def show_panel(name): ##exec("from instrumentation import *") # -> locals() ##SavedPositionsPanel(name=name,globals=globals(),locals=locals()) from start import start start( "SavedPositionsPanel_2", "SavedPositionsPanel(name=%r,globals=globals(),locals=locals())" % name)
def main(): try: parser = argparse.ArgumentParser(description='MQTT Benchmark Tool') parser.add_argument('--publishers', type=int, default=10, help='No of publishers for test') parser.add_argument('--hostname', type=str, default='localhost', help='MQTT Broker address') parser.add_argument('--port', type=int, default=1883, help='MQTT Port') parser.add_argument('--topic', type=str, default='v1/device/telemetry', help='MQTT Topic') parser.add_argument('--auth', type=bool, default=False, help='MQTT Authentication') parser.add_argument('--username', type=str, help='MQTT Username') parser.add_argument('--password', type=str, help='MQTT Password') parser.add_argument('--qos', type=int, default=0, help='MQTT QoS') parser.add_argument('--max_messages', type=int, default=10, help='Max MQTT messages to be sent') parser.add_argument('--timeout', type=int, default=60, help='Test Timeout') args = parser.parse_args() if args.auth is True and args.username is None: raise Exception('Authenication Credentials reqquired') print(f""" {'='*40} MQTT Benchmark Test Tool v1.0 {'='*40} """) start(hostname=args.hostname, port=args.port, max_publishers_no=args.publishers, topic=args.topic, auth=args.auth, username=args.username, password=args.password, QOS=args.qos, max_messages=args.max_messages, timeout=args.timeout) except Exception as error: print('[ERROR] main : {}'.format(error)) sys.exit()
def docker_storage(): os.system("clear") while True: start.start() os.system("tput setaf 10") print(''' [1] CREATE VOLUME [2] VOLUME INFO [3] ATTACH VOLUME TO CONTAINER [4] SHOW VOLUMES [5] REMOVE VOLUMES [6] REMOVE ALL VOLUMES [0] BACK [99] EXIT ''') os.system("tput setaf 15") i=int(input("ENTER CHOICE : ")) if i==1: inp=input("VOLUME NAME : ") os.system(f"docker volume create {inp}") elif i==2: inp=input("VOLUME NAME : ") os.system(f"docker volume inspect {inp}") elif i==3: inp=input("CONTAINER NAME : ") inp1=input("VOLUME NAME : ") inp2=input("IMAGE NAME : ") inp3=input("ATTACH VOLUME TO ANY FOLDER (y/n) : ") if inp3.lower()[0]=='y': inp4=input("PATH TO FOLDER : ") os.system(f"docker run -it --name {inp} -v {inp1}:{inp4} {inp2}") elif inp3.lower()[0]=='': os.system("tput setaf 9 && echo 'OPTION NOT SELECTED' && tput setaf 15") else: os.system(f"docker run -it --name {inp} -v {inp1} {inp2}") elif i==4: os.system("docker volume ls") elif i==5: inp=input("VOLUME NAME : ") os.system(f"docker volume rm {inp}") elif i==6: os.system("docker volume prune") elif i==0: main_menu.main_menu() elif i==99: os.system("reset") exit() else: os.system("tput setaf 9 && echo -e 'OPTION NOT SUPPORTED !!!' && tput setaf 15") time.sleep(1) os.system("tput setaf 4") inp=input("enter to continue.......") os.system("tput setaf 15 && clear")
def bot(): try: """"This is like the main function which we call first""" "" greet_and_introduce( ) #Here, the bot introduces itself and asks the user for name name = input("Your name please...") #The bot receives name of the user welcome(name) #The bot welcomes the user while (1): start() #we call start() function except Exception as e: print(str(e))
def docker_network(): os.system("clear") while True: start.start() os.system("tput setaf 10") print(''' [1] SHOW NETWORK [2] CREATE NETWORK [3] DISCONNECT NETWORK [4] RUN CONTAINER IN USERMADE NETWORK [5] INFO OF A NETWORK [6] REMOVE NETWORK [0] BACK [99] EXIT ''') os.system("tput setaf 15") i = int(input("CHOICE : ")) if i == 1: os.system("docker network ls") elif i == 2: inp = input("NETWORK NAME : ") inp1 = input("DRIVER NAME : ") inp2 = input("SUBNET RANGE : ") os.system( f"docker network create --driver {inp1} --subnet {inp2} {inp}") elif i == 3: inp = input("NETWORK NAME : ") inp1 = input("CONTAINER NAME : ") os.system(f"docker network disconnect {inp} {inp1}") elif i == 4: inp = input("CONTAINER NAME : ") inp1 = input("NETWORK NAME : ") inp2 = input("IMAGE NAME : ") os.system(f"docker run -it --name {inp} --network {inp1} {inp2}") elif i == 5: inp = input("NETWORK NAME : ") os.system(f"docker network inspect {inp}") elif i == 6: inp = input("NETWORK NAME : ") os.system(f"docker network rm {inp}") elif i == 0: main_menu.main_menu() elif i == 99: os.system("reset") exit() else: os.system( "tput setaf 9 && echo -e 'OPTION NOT SUPPORTED !!!' && tput setaf 15" ) time.sleep(1) os.system("tput setaf 4") inp = input("enter to continue.......") os.system("tput setaf 15 && clear")
def main_menu(): os.system("clear") while True: start.start() os.system("tput setaf 10") print(''' [1] INSTALL DOCKER [100] CHANGE LOCATION [2] GENERAL [3] DOCKER CONTAINER [4] DOCKER IMAGE [5] DOCKER COMPOSE [6] DOCKER NETWORK [7] DOCKER STORAGE [0] EXIT ''') os.system("tput setaf 15") i = int(input("ENTER CHOICE : ")) if i == 1: repo = sp.getoutput("rpm -q docker-ce | cut -c 1-9") if repo == "docker-ce": os.system( "tput setaf 4 && echo -e 'DOCKER IS ALREADY INSTALLED' && tput setaf 15" ) else: os.system( "echo -e '[docker]\nbaseurl=https://download.docker.com/linux/centos/7/x86_64/stable/\ngpgcheck=0' > /etc/yum.repos.d/docker.repo && dnf install docker-ce -y" ) elif i == 2: general.general() elif i == 3: docker_container.docker_container() elif i == 4: docker_image.docker_image() elif i == 5: docker_compose.docker_compose() elif i == 6: docker_network.docker_network() elif i == 7: docker_storage.docker_storage() elif i == 100: docker.main() elif i == 0: os.system("reset") exit() else: os.system( "tput setaf 9 && echo -e 'OPTION NOT SUPPORTED !!!' && tput setaf 15" ) time.sleep(1) os.system("tput setaf 4") inp = input("enter to continue.......") os.system("tput setaf 15 && clear")
def restart(args): global options #begin by parsing command line arguments #setup the f****n parser parser = optparse.OptionParser(\ usage=bcolors.OKGREEN+"%prog start"+bcolors.ENDC) parser.add_option('-v', '--verbose', action='store_true', help='print debug data') (options, args) = parser.parse_args(args) verbose("Args are: %s " % args) print bcolors.OKBLUE, "Restarting", bcolors.ENDC stop.stop([]) ##SERVER STILL NEEDS RESTARTING HERE (FIRST CONFIG NEEDS TO BE ADVANCED TO STORE THE FILE NAME AND THE START PARAMS OF PREVIOUS START) start.start(config.readStartParams())
def main(): if len(sys.argv) != 5: logging.info('please input args: car_path, road_path, cross_path, answerPath') exit(1) car_path = sys.argv[1] road_path = sys.argv[2] cross_path = sys.argv[3] answer_path = sys.argv[4] logging.info("car_path is %s" % (car_path)) logging.info("road_path is %s" % (road_path)) logging.info("cross_path is %s" % (cross_path)) logging.info("answer_path is %s" % (answer_path)) # to read input file car_dict, road_dict, cross_dict, car_ascending, cross_ascending = read(car_path, road_path, cross_path) P1, P2, total_lane_num = construct(car_dict, road_dict, cross_dict) # process ans, total_car_num, road_num = defaultdict(list), len(car_ascending), len(road_dict) best_balance, best_limit = 0, 0 min_time, dead_lock = 99999, 0 for balance in [0.5, ]: limit = 2000 for _ in range(1): car_dict_copy = copy.deepcopy(car_dict) road_dict_copy = copy.deepcopy(road_dict) car_ascending_copy = copy.deepcopy(car_ascending) time, arrival_num, temp_ans = 0, 0, defaultdict(list) while arrival_num < total_car_num: waiting_car_num = label(road_dict_copy, car_dict_copy, cross_dict, P1, P2, balance) dead_lock, schedule_arrival_num = \ schedule(cross_ascending, cross_dict, road_dict_copy, car_dict_copy, temp_ans, waiting_car_num, P1, P2, balance) arrival_num += schedule_arrival_num if dead_lock: print("dead_lock at time:", time) break remaining_car_num = total_car_num - arrival_num start(time, car_ascending_copy, car_dict_copy, cross_dict, road_dict_copy, temp_ans, remaining_car_num, P1, limit) time += 1 if time > min_time: break print("balance:", balance, "limit:", limit, "time:", time, "arrival_num:", arrival_num) if not dead_lock and time < min_time: best_limit = limit best_balance = balance min_time = time ans = copy.deepcopy(temp_ans) if dead_lock: limit -= 500 else: limit += 800 print("best_balance:",best_balance, "best_limit:",best_limit, "total_car_num:",total_car_num, "road_num:",road_num, "total_lane_num:",total_lane_num, "min_time:",min_time) # to write output file with open(answer_path, 'w') as ans_file: for car_id in ans: ans_file.write("(" + str(car_id) + ',' + ','.join(list(map(str, ans[car_id]))) + ")\n")
def menu(): # so i'm also defining the score variable here in order to try to save the score even after quiting to the menu print("-" * 50) print("Nice! You can choose:") print("HELP, START, QUIT, SCORE") print("-" * 50) global HINTS HINTS = [ "If you type anything other than Y or N in game you can continue playing.", "Don't underestimate the computer...it starts with ties...", "I don't really know how to make a good score option lol", "I made a score thingy hehe boi", "You can type MENU to go back to the...ãhhh...menu? ", "Actually typing MENU doesn't really work lol", "Don't use the score option before setting a name", "You can type the commands in lower case", "Actually, the menu command now works hehe" ] p_choice = str(input("What you choose? ")) if p_choice.lower() == "help": help.help() elif p_choice.lower() == "start": print("HINT:" + " " + choice(HINTS)) start.start() elif p_choice.lower() == "quit": print("Quitting to main panel...") print("HINT:" + " " + choice(HINTS)) sleep(0.5) elif p_choice.lower() == "score": if score.player_score > 0: print("Ok computing the score...") sleep(1) print(f"{start.name} score is {score.player_score}") print("Going back to menu...") sleep(1) menu() else: print("You don't have a score yet, try that after playing!") sleep(0.5) print("Going back to menu...") sleep(0.5) menu()
def setUp(self): root = Tk() cur = Mock() cur.execute.return_value = "" cur.fetchall.return_value = [('user1', '2110'), ('user2', '30411'), ('user3', '13105'), ('user4', '45234')] self.startpage = start(root, "white", cur)
def handle_start(): log_request(request) params = json.loads(request.data) response = start(params) return json.dumps(response)
def preprocess(fname): print('=================================') is_training_set = 'train' in fname df = start.start('data/' + fname) df = missing_values.fill_missing_values(df) df = encoding.encode_nominal(df) df = encoding.encode_ordinal(df) df = feature_generation.generate(df) df = feature_selection.select(df) df = feature_transformations.transform(df) if is_training_set: df = anomaly_detection.remove(df) df.to_csv('data/preprocessed_' + fname) if not is_training_set: df = df.fillna(0) print('==Summary==') print("# of examples: {:} \n# of features: {:}".format(*df.shape)) print('Total # of missing values: ', df.isna().sum().sum()) if 'train' in fname: print('Target: log_SalePrice') print("Features: ", *df.columns.to_list(), "\n") print('Preprocessed data is saved to: data/preprocessed_' + fname)
def contrast(self): #对比更新 mongodb=mongodb_con.mongodb_con() mongodb.callback_update(self.config_main.callback_domain(), self.contrast_data) mongodb.close() import_data=start.start() import_data.while_read() self.contrast_data=[]
def kai_shi(): """ :return: system 1.0.3 """ qqq = str(input('\n----system 1.0.3----\n\n --按1进入--\n\n --按2退出--\n\n----按3返回开始界面----\n\n请输入:')) if qqq == '1': xuan_ze() elif qqq == '2': print('\n程序已结束!') exit() elif qqq == '3': print('\n已返回!\n') start.start() else: print('\n无效选择!') kai_shi()
def choose_direction(): direction = start() if direction == "left": bear_room() elif direction == "right": cthulhu_room() else: dead("You stumble around the room until you starve.")
def start_for_tests(dropdb=True, droplog=False, dropdir=False): """ Start the OSF offline client in a clean configuration suitable for testing :param bool dropdb: Whether to delete the database. Defaults to True :param bool droplog: Whether to delete pre-existing shared error log. Defaults to False. :param bool dropdir: Whether to delete user data folder (a particular location for testing). Defaults to False. """ if dropdb: drop_db() if droplog: drop_log() osf_dir = os.path.expanduser('~/Desktop/OSF') if dropdir and os.path.exists(osf_dir): shutil.rmtree(osf_dir) start()
def main(): conf = {} confloader.loadconf(conf) if len(sys.argv) == 2 and sys.argv[1] == "start": start.start(conf) elif len(sys.argv) == 2 and sys.argv[1] == "restart": if stop.stop(conf) == True: common.log(conf, "Daemon stopped") print "Daemon stopped" start.start(conf) elif len(sys.argv) == 2 and sys.argv[1] == "stop": if stop.stop(conf) == True: common.log(conf, "Daemon stopped") print "Daemon stopped" else: print >> sys.stderr, "Daemon isn't started" else: print >> sys.stderr, "Va te faire foutre\n"
def delete_2(): def d(*args): for i in args: i.clear() global a321, b256, r try: b256 = random.randint(1, 9) a321 = int(input('\n你确定要清空所有数据吗?(输入0退出,继续请按:{},剩余机会:{}):'.format(b256, r + 1))) except ValueError: print('\n错误!') delete_2() if a321 == 0: print('\n已退出!') guan_li() elif r == 0: d(z_m, z, f1, al3, c2c2, variables.msg, variables.a_m, variables.n_s, variables.all_friend, variables.s56) variables.z.append(' visitor ') variables.z_m[' visitor '] = None variables.all_friend[' visitor '] = [] variables.msg[' visitor '] = [] read_write_file.write_file( variables.uan, z) read_write_file.write_file( variables.uanp, z_m) read_write_file.write_file( variables.aanp, al3) read_write_file.write_file( variables.am, variables.a_m) read_write_file.write_file( variables.uf, variables.all_friend) read_write_file.write_file( variables.um, variables.msg) print('\n******************************删除成功!******************************') start.start() elif a321 == b256: r -= 1 delete_2() else: print('\n条件错误!') r -= 0 delete_2()
def kai_shi(): """ :return: system 1.0.4 """ # print(b, 'b\n', e, 'e\n', a4, 'a4\n', a24, 'a24\n', l, 'l\n', f1, 'f1\n', c3c3, 'c3c3\n', ao3, 'ao3\n', d, 'd\n') qqq = str( input( '\n----system 1.0.4----\n\n --按1进入--\n\n --按2退出--\n\n----按3返回开始界面----\n\n请输入:' )) if qqq == '1': xuan_ze() elif qqq == '2': exit_2(kai_shi) elif qqq == '3': print('\n已返回!\n') start.start() else: print('\n无效选择!') kai_shi()
def bulk(): if ('id' in request.args and 'startingCode' in request.args and 'semester' in request.args and 'start' in request.args): return jsonify( start(request.args['id'], request.args['startingCode'], request.args['semester'], int(request.args['start']))) else: return jsonify({ "Error": 'Some Parameters are missing', "Reason": "You Must Enter RollNo ans semester" })
def index(): if request.method == "GET": return render_template("index.html") if request.method == "POST": # name file readin names_csv = request.files["names"] # codecs stream stream = codecs.iterdecode(names_csv.stream, 'utf-8') message = request.form["message"] subject = request.form["subject"] # attachments optional attachments = None if request.files["attachments"]: attachments = request.files["attachments"] names_dict = parseCSV(stream) print(names_dict) start(names_dict, message, subject, attachments) return render_template("success.html")
def 开始(): """ :return: system 1.0.0 """ qqq = str( input( '\n----system 1.0.0----\n\n --按1进入--\n\n --按2退出--\n\n----按3返回开始界面----\n//此版本为独立版本\n请输入:' )) if qqq == '1': 登录() elif qqq == '2': print(' \n程序已结束!') exit() elif qqq == '3': print('\n已返回!\n') start.start() else: print(' \n无效选择') 开始()
def start(): from start import start start(headers) from unit.ding import send_message, get_sign from unit.csvs import get_count import time t = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) mes = "接口自动化测试报告\n" + \ ">成功:" + str(get_count().get('success_count')) + "\n" + \ ">失败:" + str(get_count().get('error_count')) + "\n\n" + \ "测试报告地址:" + "http://0.0.0.0:5000/report\n" + \ "![screenshot](https://gw.alicdn.com/tfs/TB1ut3xxbsrBKNjSZFpXXcXhFXa-846-786.png)\n" + \ "###### " + t + " 发布 [测试报告](http://0.0.0.0:5000/report) \n" raw = send_message(mes, timestamp=get_sign().get('timestamp'), sign=get_sign().get('sign')) logging.info('DingTalk:' + raw) return render_template('index.html')
def sms_reply(): """Respond to incoming calls with a simple text message.""" # Fetch the message msg = request.form.get('Body') reply = start(msg) resp = MessagingResponse() resp.message(reply) return str(resp)
def __init__(self): self.SessionData = {} self.modules = [ wordGame(), reddit_news(), twitter_news(), twitter_menu(), easyQA(), jokeQA(), chitchat(), aimlbot(), textAdventure(), ghostAdventure(), horoscope(), riddle(), board(), search(), start() ] # TODO: Part of temporary fix for usage. Define all NPC names # here so we can increment and check their usage. self.moduleNames = [ "word game", "reddit news", "twitter news", "twitter trend", "ask question", "joke", "chitchat", "chat", "text adventure", "ghost adventure", "horoscope", "riddle game", "message board", "search", "startModule", ] self.badwords = sorted(open('data/dirty.txt', 'r').read().split('\n'), key=lambda x: len(x), reverse=True) self.deflecting = open('data/deflect.txt', 'r').read().split( '\n') #last line without next line self.LogTable = redisClient.redisClient("menuLog") self.flowControler = flowControler() self.IntentDetector = intentDetectMenu()
def main(): program = True while program == True: select = menus.mainMenu() if select == False: var = start.start() if var == 'hp': finalData, fileName = scans.scanMain() fill.fillIn(finalData, fileName) elif select == True: print('ramiz get working on the about screen!') else: program = False
def command_start(message, bot, chats, config): chat = message.chat user_id = str(str(chat.id)) if chat.type == 'private': if len(chats['private']['admin']) == 0 or user_id in chats['private']['admin']: chats['private']['admin'] = { user_id: 'default' } if user_id in chats['private']['student']: del chats['private']['student'][user_id] bot.send_message(user_id, 'Вы являетесь админом этого бота.\nКомандой /help можете получить доступные команды.') save_chats() else: answ = start.start(config) bot.send_message(user_id, answ['about']) bot.send_message(user_id, answ['info']) if chat.type == 'group': pass
def calculate_du(Blueprint): # noqa: E501 """returns the blueprint with associated the updated data utility values By passing the blueprint, the method returns the updated blueprint # noqa: E501 :param Blueprint: file json containing the abstract blueprint to be updated with the data utility values :type Blueprint: dict | bytes :rtype: Blueprint """ try: #if connexion.request.is_json: #Blueprint = Blueprint.from_dict(connexion.request.get_json()) # noqa: E501 BP = Blueprint dimensions = start.start(Blueprint) BP = WriteDim.writedim(Blueprint, dimensions) #BP = writedim.writedim(Blueprint, dimensions) except Exception: traceback.print_exc(file=sys.stderr) return BP
def swim(): """ Repeatable choice checker. If cannot determine, what should be done, returns False. """ decision = def_input() if decision == '1' or decision == '1.': print "You managed to survive and got off the water." print "You wander carefully, but finally, you find a golden cave." print "Yaaaaaaaay!" return cave() elif decision == '2' or decision == '2.': print "Darkness covers your sight. You lose conscience..." for i in range(0,5): print '...' sleep(1) print "You lucky bastard! A fisherman caught you and brought you "\ "home, where you can recover." print "You can start your adventure again!" return start.start() else: print "Unknown choice. Try again." return False
''' Created on 26/09/2011 Updated on 18/08/2012 Updated on 01/02/2013 @author: Jairo ''' #Vulnerability Graph Analyzer: Main '' import start, utils import sys, traceback, time if __name__ == '__main__': ti = time.time() dir1="crossbroker" dir2="wms" #print "Select a middleware:..." #dir=raw_input() #if (dir=="middleware_name"): start.start(dir2) tf = time.time() print (tf-ti) raw_input() sys.exit(0)
def main(): STATES = {'D':('Development',bcolors.WARNING), '':("Unknown",bcolors.FAIL)} if len(sys.argv) <= 1: help(); return app = sys.argv[1] if app == "pack": print "Packing project into game.zip..." pack() elif app == "validate": verify_game_auth() print "Everything seems to be ok." elif app == "listgames": print "Listing your games:" print games = get_all_games() for game in games: print bcolors.HEADER + game['name'] + bcolors.ENDC + ":" print " Game Id : " + game['game_id'] state = STATES[game['status']] print " Status : " + state[1] + state[0] + bcolors.ENDC print elif app == "auth": update_tokens() return elif app == "submit": submit() elif app == "wait": STATES = {'U':('Pending',bcolors.OKBLUE), 'T':("Processed",bcolors.OKGREEN), 'E':("Error",bcolors.FAIL)} collect = {} for sub in get_submited(): if sub['game']['key'] in collect: collect[sub['game']['key']].append(sub) else: collect[sub['game']['key']] = [ sub ] for key in collect.keys(): game = collect[key] print bcolors.HEADER + "%s" % (game[0]['game']['name']) + bcolors.ENDC + ":" print " Game ID : %s" % game[0]['game']['key'] for ver in game[:5]: print print (" Submited on %s by" + bcolors.OKGREEN + " %s " + bcolors.ENDC) % (ver['submission_date'].replace("T"," "), ver['user']['username']) state = STATES[ver['status']] print " Status : " + state[1] + state[0] + bcolors.ENDC print " Digest : " + ver['digest'] elif app == "start": if len(sys.argv) < 3: print "You must specify a project name.\n\nusage: intigos start <project name>" start(sys.argv[2]) return; elif app == "run": try: opts, args = getopt.getopt(sys.argv[2:], 'a:,', ['addr=']) except getopt.GetoptError, err: print str(err) # will print something like "option -a not recognized" sys.exit(2) addr = 'localhost:8000' for o, a in opts: if o in ("-a", "--addr"): addr = a run(addr=addr)
options.clientports[sid - 1], 'adminServerPort' : options.adminports[sid - 1], 'weights' : options.weights, 'groups' : options.groups, 'serverlist' : serverlist, 'maxClientCnxns' : options.maxclientcnxns, 'electionAlg' : options.electionalg, 'ssl' : options.ssl, 'sasl' : options.sasl, 'whitelist' : options.whitelist, 'whitelistAll' : options.whitelistAll}]) writefile(os.path.join(serverdir, "zoo.cfg"), str(conf)) writefile(os.path.join(serverdir, "data", "myid"), str(sid)) writescript("start.sh", str(start(searchList=[{'serverlist' : serverlist, 'trace' : options.trace, 'sasl' : options.sasl}]))) writescript("stop.sh", str(stop(searchList=[{'serverlist' : serverlist}]))) writescript("status.sh", str(status(searchList=[{'serverlist' : serverlist}]))) writescript("cli.sh", str(cli(searchList=[{'ssl' : options.ssl, 'sasl' : options.sasl}]))) if is_remote: writescript("copycat.sh", str(copycat(searchList=[{'serverlist' : serverlist, 'username' : options.username}]))) writescript("startcat.sh", str(startcat(searchList=[{'serverlist' : serverlist, 'username' : options.username, 'trace' : options.trace, 'sasl' : options.sasl}]))) writescript("stopcat.sh", str(stopcat(searchList=[{'serverlist' : serverlist, 'username' : options.username}]))) writescript("clearcat.sh", str(clearcat(searchList=[{'serverlist' : serverlist, 'username' : options.username}]))) for f in glob.glob(os.path.join(options.zookeeper_dir, 'lib', '*.jar')): shutil.copy(f, options.output_dir) for f in glob.glob(os.path.join(options.zookeeper_dir, 'src', 'java', 'lib', '*.jar')): shutil.copy(f, options.output_dir) for f in glob.glob(os.path.join(options.zookeeper_dir, 'build', 'lib', '*.jar')): shutil.copy(f, options.output_dir)
def main(): for i in range(1000): print('line', i) #raise SystemExit('foo') #raise IOError(1, 'foo') return 0 if __name__ == '__main__': from start import start start(main)
def test_start(self): start.start(7)
def start(): import start start.start()
def start(): from start import start start()
def start(self): start(self.key, self.secret, self.service, self.node_uuid)
":" + str(options.clientports[sid - 1])) os.mkdir(serverdir) os.mkdir(os.path.join(serverdir, "data")) conf = zoocfg(searchList=[{'sid' : sid, 'servername' : options.servers[sid - 1], 'clientPort' : options.clientports[sid - 1], 'weights' : options.weights, 'groups' : options.groups, 'serverlist' : serverlist, 'maxClientCnxns' : options.maxclientcnxns, 'electionAlg' : options.electionalg}]) writefile(os.path.join(serverdir, "zoo.cfg"), str(conf)) writefile(os.path.join(serverdir, "data", "myid"), str(sid)) writescript("start.sh", str(start(searchList=[{'serverlist' : serverlist}]))) writescript("stop.sh", str(stop(searchList=[{'serverlist' : serverlist}]))) content = """#!/bin/bash java -cp zookeeper.jar:log4j.jar:jline.jar:. org.apache.zookeeper.ZooKeeperMain -server "$1"\n""" writescript("cli.sh", content) content = '#!/bin/bash\n' for sid in xrange(1, len(options.servers) + 1) : content += ('echo "' + options.servers[sid - 1] + ":" + str(options.clientports[sid - 1]) + ' "' + ' $(echo stat | nc ' + options.servers[sid - 1] + " " + str(options.clientports[sid - 1]) + ' | egrep "Mode: ")\n') writescript("status.sh", content)
if sys.argv[2] in ['p', '-p', 'print', '-print']: prog_name = sys.argv[1] if os.path.isfile(prog_name): test.test(prog_name, 'p') else: print prog_name, 'does not exist' exit() # cf start <contest number> elif sys.argv[1] == 'start': try: n = int(sys.argv[2]) except: print 'Are you sure that "' + sys.argv[2] + '" is correct? y/n' answer = raw_input() while not answer.lower().startswith('y') and \ not answer.lower().startswith('n'): print 'Invalid answer. Enter y/n.' answer = raw_input() if answer.lower().startswith('n'): exit() contest_url = 'http://codeforces.com/contest/' + sys.argv[2] start.start(contest_url, '.') # No match else: print 'Invalid arguments.' exit()