def setup_network_configurations(data): print() proceed = YesNo(prompt=_("Do you want to adjust network configurations? " "(connection timeout) "), default="n", prompt_prefix="[yN] ").launch() if not proceed: return print_wrapped(_( "For meanings and significances of the following values, please " "consult the module documentations." )) print() print("https://etm.1a23.studio/") print() if YesNo(prompt=_("Do you want to change timeout settings? "), prompt_prefix="[yN] ", default="n").launch(): if data.data.get('request_kwargs') is None: data.data['request_kwargs'] = {} data.data['request_kwargs']['read_timeout'] = \ Numbers(prompt=_("read_timeout (in seconds): ")).launch() data.data['request_kwargs']['connect_timeout'] = \ Numbers(prompt=_("connect_timeout (in seconds): ")).launch()
def AddAdvice(): clear() Add = SlidePrompt([ Input("Marca del teléfono: ", default="", word_color=colors.foreground["yellow"]), Bullet("Sistema operativo:", choices=["Android", "IOS"], margin=2, background_on_switch=colors.background["white"], word_on_switch=colors.foreground["black"]), Numbers("RAM: ", word_color=colors.foreground["yellow"], type=int), Input("CPU: ", default="", word_color=colors.foreground["yellow"]), Numbers("Números de ventas en el año: ", word_color=colors.foreground["yellow"], type=int) ]) actualDevice = Add.launch() deviceDic = { 'brand': actualDevice[0][1], 'os': actualDevice[1][1], 'ram': actualDevice[2][1], 'cpu': actualDevice[3][1], 'sales': actualDevice[4][1] } devices.append(deviceDic)
def setup_experimental_flags(data): print_wrapped( _("EWS does not require any configuration, you only need to scan " "a QR code when you start up EH Forwarder Bot. It’s as simple as " "that.\n" "\n" "We has provided some experimental features that you can use. " "They are not required to be enabled for EWS to work. If you do not " "want to enable these feature, just press ENTER, and you are good to go." )) widget = YesNo(prompt=_("Do you want to config experimental features? "), prompt_prefix="[yN] ") if not widget.launch(default="n"): return for key, value in flags_settings.items(): default, cat, params, desc = value if data.data['flags'].get(key) is not None: default = data.data['flags'].get(key) print() print(key) print_wrapped(desc) if cat == 'bool': prompt_prefix = '[Yn] ' if default else '[yN] ' ans = YesNo(prompt=f"{key}? ", prompt_prefix=prompt_prefix) \ .launch(default='y' if default else 'n') data.data['flags'][key] = ans elif cat == 'int': ans = Numbers(prompt=f"{key} [{default}]? ") \ .launch(default=default) data.data['flags'][key] = ans elif cat == 'choices': ans = Bullet(prompt=f"{key}?", choices=params) \ .launch(default=default) data.data['flags'][key] = ans elif cat == 'multiple': ans = Check(prompt=f"{key}?", choices=params).launch(default=default) data.data['flags'][key] = ans elif cat == 'str': ans = input(f"{key} [{default}]: ") data.data['flags'][key] = ans or default else: print(_("Skipped.")) print(_("Saving configurations..."), end="", flush=True) data.save() print(_("OK"))
def setup_experimental_flags(data): print() print_wrapped( _("EFMS has also provided some experimental features that you can use. " "They are not required to be enabled for EFMS to work.")) widget = YesNo(prompt=_("Do you want to config experimental features? "), prompt_prefix="[yN] ", default="n") if not widget.launch(): return for key, value in flags_settings.items(): default, cat, params, desc = value if data.data['flags'].get(key) is not None: default = data.data['flags'].get(key) if cat == 'bool': prompt_prefix = '[Yn] ' if default else '[yN] ' print() print(key) print_wrapped(desc) ans = YesNo(prompt=f"{key}? ", prompt_prefix=prompt_prefix, default='y' if default else 'n') \ .launch() data.data['flags'][key] = ans elif cat == 'int': print() print(key) print_wrapped(desc) ans = Numbers(prompt=f"{key} [{default}]? ", type=int) \ .launch(default=default) data.data['flags'][key] = ans elif cat == 'choices': print() print(key) print_wrapped(desc) ans = Bullet(prompt=f"{key}?", choices=params) \ .launch(default=default) data.data['flags'][key] = ans print(_("Saving configurations..."), end="", flush=True) data.save() print(_("OK"))
def setup_experimental_flags(data): print() widget = YesNo(prompt=_("Do you want to config experimental features? "), prompt_prefix="[yN] ", default="n") if not widget.launch(): return for key, value in flags_settings.items(): default, cat, params, desc = value if data.data['flags'].get(key) is not None: default = data.data['flags'].get(key) if cat == 'bool': prompt_prefix = '[Yn] ' if default else '[yN] ' print() print(key) print_wrapped(desc) ans = YesNo(prompt=f"{key}? ", default='y' if default else 'n', prompt_prefix=prompt_prefix) \ .launch() data.data['flags'][key] = ans elif cat == 'int': print() print(key) print_wrapped(desc) ans = Numbers(prompt=f"{key} [{default}]? ", type=int) \ .launch(default=default) data.data['flags'][key] = ans elif cat == 'choices': try: assert isinstance(params, list) default = params.index(default) except ValueError: default = 0 print() print(key) print_wrapped(desc) ans = Bullet(prompt=f"{key}?", choices=params) \ .launch(default=default) data.data['flags'][key] = ans
def setup_network_configurations(data): print() proceed = YesNo(prompt=_("Do you want to adjust network configurations? " "(connection timeout and proxy) "), prompt_prefix="[yN] ").launch(default='n') if not proceed: return print_wrapped( _("For meanings and significances of the following values, please " "consult the module documentations.")) print() print("https://github.com/blueset/efb-telegram-master/") print() if YesNo(prompt=_("Do you want to change timeout settings? "), prompt_prefix="[yN] ").launch(default='n'): if data.data.get('request_kwargs') is None: data.data['request_kwargs'] = {} data.data['request_kwargs']['read_timeout'] = \ Numbers(prompt=_("read_timeout (in seconds): ")).launch() data.data['request_kwargs']['connect_timeout'] = \ Numbers(prompt=_("connect_timeout (in seconds): ")).launch() if YesNo(prompt=_("Do you want to run ETM behind a proxy? "), prompt_prefix="[yN] ").launch(default='n'): if data.data.get('request_kwargs') is None: data.data['request_kwargs'] = {} proxy_type = Bullet(prompt=_("Select proxy type"), choices=['http', 'socks5']).launch() host = input(_("Proxy host (domain/IP): ")) port = input(_("Proxy port: ")) username = None password = None if YesNo(prompt=_("Does it require authentication?"), prompt_prefix="[yN] ").launch(default='n'): username = input(_("Username: "******"Password: "******"http://{host}:{port}/" if username is not None and password is not None: data.data['request_kwargs']['username'] = username data.data['request_kwargs']['password'] = password elif proxy_type == 'socks5': try: import socks except ModuleNotFoundError as e: print_wrapped( _("You have not installed required extra package " "to use SOCKS5 proxy, please install with the " "following command:")) print() print("pip install python-telegram-bot[socks]") print() raise e data.data['request_kwargs'][ 'proxy_url'] = f"socks5://{host}:{port}" if username is not None and password is not None: data.data['request_kwargs']['urllib3_proxy_kwargs'] = { "username": username, "password": password }
from bullet import SlidePrompt, Bullet, Numbers DISTRIBUTIONS = [ 'Uniform', 'Normal', ] cli = SlidePrompt( [ Bullet(prompt="Choose the distribution(Y)", choices=DISTRIBUTIONS), Numbers(prompt="Distribution mean(μ) / Starting point(a): ", type=float), Numbers(prompt="Distribution standard deviation(σ) / End point(b): ", type=float), Numbers(prompt="Delivery time(l): ", type=float), Numbers(prompt="Fixed cost of the order(A): ", type=float), Numbers(prompt="Unitary item cost(c): ", type=float), Numbers(prompt="Storage cost per item per timestep(h): ", type=float), Numbers(prompt="Out of stock cost per item(p'): ", type=float), Numbers(prompt="Stopping rate of change(ε): ", type=float), ] ) def get_args_from_cli(cli_obj): args = cli_obj.launch() return dict( distribution=args[0][1], mean=args[1][1], std_deviation=args[2][1], delivery_time=args[3][1],
from bullet import colors cli = SlidePrompt( [ YesNo("Are you a student? ", word_color = colors.foreground["yellow"]), YesNo("Are you a good student? ", default = 'y', word_color = colors.foreground["yellow"]), Input("Who are you? ", default = "Batman", word_color = colors.foreground["yellow"]), Input("Really? ", word_color = colors.foreground["yellow"]), Numbers("How old are you? ", word_color = colors.foreground["yellow"], type = int), Bullet("What is your favorite programming language? ", choices = ["C++", "Python", "Javascript", "Not here!"], bullet = " >", margin = 2, bullet_color = colors.bright(colors.foreground["cyan"]), background_color = colors.background["black"], background_on_switch = colors.background["black"], word_color = colors.foreground["white"], word_on_switch = colors.foreground["white"] ), Check("What food do you like? ", choices = ["🍣 Sushi", "🍜 Ramen", "🌭 Hotdogs",
# for every line, take the points and store them nodelist = [] for i in range(start_index, dimension + start_index - 1): x, y = lines[i].strip().split()[1:] nodelist.append([float(x), float(y)]) # calculate the euclidean distances between every point. # this creates a matrix of distances between every pair # of points. now we are ready to calculate the optimal path. dists = euclidean_distances(nodelist) print() print("> Starting execution for file: {}".format(name)) print("> Matrix dimensions: {}\n".format(dists.shape)) cli_n = Numbers(prompt="> Select number of iterations: ") iterations = cli_n.launch() print() print( "> Calculating solution. \nProblems over 500 cities can take several minutes...\n" ) start_time = time.time() solution = solve_float_matrix(dists, runs=iterations) end_time = time.time() - start_time solution_pairs = sliding_window_view(solution, 2) total_length = np.sum([dists[pair[0], pair[1]] for pair in solution_pairs])
training_dir, _, base_pipeline_config_path = load_model_paths( model2resume, model2download, alt_model_name) checkpoints = [ ckpt.replace('.meta', '') for ckpt in listdir(training_dir) if '.meta' in ckpt ] ckpt_prefix = Bullet(prompt="Choose checkpoint to resume from:", choices=['[ last checkpoint ]'] + checkpoints, **ocean_style_dolphin).launch() # the function pipeline.set_training_config below figures this out on its own. ckpt_prefix = None if ckpt_prefix == '[ last checkpoint ]' else ckpt_prefix num_steps = Numbers(prompt="\nPick a number of training epochs: ", type=int, indent=alignment['indent']).launch() num_eval_steps = Numbers(prompt="\nEnter max number of evaluations: ", type=int, indent=alignment['indent']).launch() batch_size = Numbers(prompt="\nEnter desired batch size: ", type=int, indent=alignment['indent']).launch() training_config_file_path = join(training_dir, 'training.config') print('\n⇒ writing training config to {}'.format(training_config_file_path)) # defaults :: current input dataset converted to tfrecords test_record_fname = './input/tf_records/test.record'
from bullet import Bullet, Prompt, Check, Input, YesNo, Numbers from bullet import styles from bullet import colors cli = Prompt( [ YesNo("Are you a student? "), Input("Who are you? "), Numbers("How old are you? "), Bullet("What is your favorite programming language? ", choices = ["C++", "Python", "Javascript", "Not here!"]), ], spacing = 1, separator = "-", separator_color = colors.foreground["cyan"] ) result = cli.launch() cli.summarize()
from bullet import Numbers prompt = Numbers("How old are you? ", type=int) prompt.launch()