예제 #1
0
def add_pool_ui(json_file):
    pool_list = open_pool_list(json_file)
    new_pool = {}
    new_pool['pool_API_url'] = ''
    new_pool['pool_mining_urls'] = []
    new_pool['pool_name'] = ui.ask_string("Enter new pool name")
    pool_type_list = ["node-cryptonote-pool", "nodejs-pool", "other"]
    new_pool['pool_API_type'] = ui.ask_choice("API type ?", pool_type_list)
    new_pool['config_file'] = ui.ask_string(
        "Configuration file URL (usually config.js OR global.js) ?")
    new_pool = get_config(new_pool)
    if new_pool['pool_API_url'] == '':
        new_pool['pool_API_url'] = ui.ask_string(
            "Impossible to get API URL, please provide manually for next attempt"
        )
        new_pool = get_config(new_pool)
    print("*** Output ***")
    print(json.dumps(new_pool, indent=4))
    yesno = ["no", "yes"]
    accept = ui.ask_choice("Do you want to add to the pool list ?", yesno)
    if accept == "yes":
        pool_list.append(new_pool)
        output = {}
        output["pools"] = pool_list
        with open(json_file, 'w') as pouet:
            pouet.write(json.dumps(output, indent=4))
            print("Done ...")
    else:
        print("OK nevermind ...")
예제 #2
0
def intent(network):
    """Description: This creates a prompt for the user where they can choose to:  
    * Play a match  
    * Create/Join a room  
    * Replay a match  
    * Exit the application  
    Arguments:   
    * network: An `network`(pommerman.network.ion_client.network) object  
    """
    i = ui.ask_choice(
        constants.Strings.intent.value,
        [
            constants.Strings.intent_match.value,
            constants.Strings.intent_room.value,
            constants.Strings.intent_replay.value,
            constants.Strings.intent_exit.value,
        ],
    )
    if i == constants.Strings.intent_match.value:
        agent = _agent_prompt()
        match(network, agent=agent, ui_en=True)
    elif i == constants.Strings.intent_room.value:
        room = str(ui.ask_string(constants.Strings.room_code.value))
        agent = _agent_prompt()
        match(network, room=room, agent=agent, ui_en=True)
    elif i == constants.Strings.intent_replay.value:
        replay(network, ui_en=True)
    elif i == constants.Strings.intent_exit.value:
        exit(0)
예제 #3
0
def test_ask_choice():
    class Fruit:
        def __init__(self, name, price):
            self.name = name
            self.price = price

    def func_desc(fruit):
        return fruit.name

    fruits = [Fruit("apple", 42), Fruit("banana", 10), Fruit("orange", 12)]
    with mock.patch('builtins.input') as m:
        m.side_effect = ["nan", "5", "2"]
        actual = ui.ask_choice("Select a fruit",
                               fruits,
                               func_desc=operator.attrgetter("name"))
        assert actual.name == "banana"
        assert actual.price == 10
        assert m.call_count == 3
예제 #4
0
def init():
    """Description: Initiate the application by asking questions."""
    ui.info(ui.yellow, constants.Strings.sever_starting.value)
    port = int(ui.ask_string(constants.Strings.server_port.value))
    max_players = int(ui.ask_string(constants.Strings.server_maxp.value))
    if max_players < 4:
        # If the maximum players allowed on the server is less than 4
        # which is the minimum required for a pommerman match then
        # notify the user about that and quit.
        ui.fatal(ui.yellow, constants.Strings.server_playercount_too_low.value)
    modes = []
    for i in pommerman.configs.__dir__():
        if i[-4:] == "_env":
            id = getattr(pommerman.configs, i)()["env_id"]
            if id[-2:] != "v2":
                modes.append(id)
    timeout = float(ui.ask_string(constants.Strings.server_timeout.value))
    mode = str(ui.ask_choice(constants.Strings.server_mode.value, modes))
    run(port, max_players, timeout, mode, ui_en=True, exit_handler=True)
예제 #5
0
def test_ask_choice_ctrl_c():
    with pytest.raises(KeyboardInterrupt):
        with mock.patch('builtins.input') as m:
            m.side_effect = KeyboardInterrupt
            ui.ask_choice("Select a animal", ["cat", "dog", "cow"])
예제 #6
0
def test_ask_choice_empty_input():
    with mock.patch('builtins.input') as m:
        m.side_effect = [""]
        res = ui.ask_choice("Select a animal", ["cat", "dog", "cow"])
        assert res is None
예제 #7
0
def ask_table(db_file=TWEETS_DB,
              conn=create_conection(),
              table_name=TABLE_NAME):
    """Default table or new table.  Checks if table exists,
    creates one if not with name from user and calls user_ans_tweets().
    :param db_file: DEFAULT database
    :param conn: creates connection()
    :param table_name: name of table
    """
    def ploting(tweets_db=TWEETS_DB, csv_file=CSV_FILE):
        table_name = MyStreamListener.table_name
        plot_question = ui.ask_yes_no("Plot?", default=True)
        if plot_question:
            ui.info(ui.green, "Populating csv file with {}".format(table_name))
            q_four.db_into_csv(TWEETS_DB, CSV_FILE, table_name)
            ui.info_3("Ploting...")
            q_four.frecuency()
            q_four.senti()
        else:
            ui.info(ui.turquoise, "Program Finished")
            exit()

    tables_list = list()
    conn = create_conection()
    cur = conn.cursor()
    cur.execute("SELECT name FROM sqlite_master")
    for table in cur:
        tables = str(table).strip('(').strip(')').strip(',').strip("'")
        tables_list.append(tables)
    if "trump" in tables_list:
        ui.info_1(ui.yellow, ui.bold, "DEFAULT TABLE FOUND! =>", ui.blue,
                  ui.standout, "'trump'")
        new_db_ans = ui.ask_yes_no("Add tweets to table 'trump'?",
                                   default=True)
        if new_db_ans:
            ui.warning("Creating database (If it doesn't exist)")
            create_conection()
            ui.info_2(ui.green, "Accessing Database")
            MyStreamListener.table_name = TABLE_NAME
            user_ans_tweets()
            ploting()
        else:
            choices = ["Create New Table", "Load table", "Plot", "Quit"]
            new = ui.ask_choice("Select: ", choices)
            if new == "Create New Table":
                ui.warning("Tables with the same name will not be created")
                new_table_name = ui.ask_string("Enter new table name:")
                new_table_name = new_table_name.lower()
                new_table_name = new_table_name.replace(" ", "_")
                ui.info("Table name with format:", ui.blue, new_table_name)
                create_ans = ui.ask_yes_no("Create?")
                if create_ans:
                    tweets_table_create(create_conection(), TWEETS_DB,
                                        new_table_name)
                    insert_new_tbl = ui.ask_yes_no(
                        "Insert new tweets into {}?".format(new_table_name))
                    if insert_new_tbl:
                        MyStreamListener.table_name = new_table_name
                        user_ans_tweets()
                        ploting()
                    else:
                        ui.info(ui.bold, ("Program Finished"))
                else:
                    ui.info(ui.bols, "Program Finished")
            elif new == "Load table":
                new_table_name = ui.ask_choice("Select Table to load:",
                                               tables_list)
                MyStreamListener.table_name = new_table_name
                user_ans_tweets()
                ploting()

            elif new == "Plot":
                new_table_name = ui.ask_choice("Select Table to plot:",
                                               tables_list)
                MyStreamListener.table_name = new_table_name
                ploting()

            elif new == "Quit":
                ui.warning("Program Finished")
                exit()
예제 #8
0
game = '高速模式   (比标准版更高的转码速度,合理的画质)'

wechat = '微信模式   (把视频暴力压缩到25m以下,视频时长越长,画质越差)'

demo = "演示模式   (高速,画质一般,文件小,适合给客户看的DEMO)"

user = "******"

audio = "音频提取   (把音轨提取出来转成320k的mp3)"

if classical_mode:
    preset = slow
else:
    choices = [slow, slower, wechat, game, demo, user, audio]
    preset = ui.ask_choice("选择一个预设", choices=choices)

if preset == slow:
    show_prompt('标准版')
    paomao(encode_arg)
    pass
elif preset == slower:

    encode_arg = " -e x264 --encoder-tune psnr --crop 0:0:0:0 --encoder-preset slower -X 1920 --encoder-level 4.0 -2 -T -R 44.1 --vb 5800"
    show_prompt('超清版')
    paomao(encode_arg)

elif preset == wechat:
    try:
        duration = float(getLength(input_file))
    except:
예제 #9
0
파일: setup.py 프로젝트: adespawn/OI_tools
import ui
import os
import subprocess

tools = [
    'compiler', 'diff', 'memcheck', 'backup-server', 'backup-client', 'quit'
]

while 1:
    out = ui.ask_choice('Co zainstalować?', tools)
    if out == 'quit':
        exit()
    if out == 'compiler':
        ui.info_2('installing')
        os.system(
            f'bash -c "cd  {   os.path.dirname(os.path.abspath(__file__))  }/compiler++ && source compile.sh" '
        )
        #subprocess.run(['sh','./compiler++/compile.sh'],)
        ui.info_2(
            'Zainstalowano - od teraz można w terminalu uzyć komendy c [nazwaprogramu]'
        )
    if out == 'backup-client':
        ui.info_2('installing')
        os.system(
            f'bash -c "cd  { os.path.dirname(os.path.abspath(__file__))  }/backup/client"'
        )
        ip = ui.ask_string(
            'podaj ip serwera backupowego, dla lokalnego wpisz 127.0.0.1')
        port = ui.ask_string('podaj port serwera backupowego')
        pswd = ui.ask_password(
            'podaj haslo do serwera backupowego (ustawisz je przy instalacji serwera)'
예제 #10
0
파일: push.py 프로젝트: timofonic-git/tsrc
def select_assignee(choices):
    return ui.ask_choice("Select an assignee",
                         choices,
                         func_desc=lambda x: x["name"])