コード例 #1
0
def main(json_input):
    data = json.loads(json_input)
    execArgs = ExecArgs(**data)
    update_settings(data)

    start = time()
    return_info = ReturnInfo("", "{}", None, None)

    try:
        return_info = exec_input(execArgs)
    except (KeyboardInterrupt, SystemExit):
        raise
    except UserError as e:
        return_info.userError = pickle_user_error(e.traceback_exception)
        return_info.userErrorMsg = e.friendly_message
        return_info.userVariables = e.varsSoFar
        return_info.execTime = e.execTime
    except Exception as e:
        return_info.internalError = "Sorry, AREPL has ran into an error\n\n" + traceback.format_exc(
        )

    return_info.totalPyTime = time() - start

    print_output(return_info)
    return return_info
コード例 #2
0
def test_dont_show_global_vars():
    update_settings({"showGlobalVars": False})
    return_info = python_evaluator.exec_input(
        python_evaluator.ExecArgs("x = 1"))
    assert jsonpickle.decode(
        return_info.userVariables
    )["zz status"] == "AREPL is configured to not show global vars"
コード例 #3
0
ファイル: commands.py プロジェクト: edwardslabs/POPM
def do_set(target, userlist, line):
    try:
        if access_level(target, userlist) >= get_level_req("access_set"):
            if is_settable(line[4]):
                try:
                    newlevel = line[5]
                    if newlevel.lower() == "on":
                        newlevel = 1
                    elif newlevel.lower() == "off":
                        newlevel = 0
                    else:
                        newlevel = int(newlevel)
                    if newlevel <= 1000 and newlevel >= 0:
                        update_settings(line[4], newlevel, target)
                    else:
                        config.confproto.notice(
                            target,
                            "Paramater must be an integer between 0 and 1000.")
                except ValueError:
                    config.confproto.notice(target,
                                            "Paramater must be an integer.")
                except IndexError:
                    get_set_value(line[4], target)
            else:
                config.confproto.notice(target, "Invalid SET option.")
        else:
            config.confproto.notice(target, "You lack access to this command.")
    except IndexError:
        if access_level(target, userlist) >= get_level_req("setters"):
            get_set(target)
        else:
            config.confproto.notice(target, "You lack access to this command.")
コード例 #4
0
ファイル: router.py プロジェクト: Aclz/Squid-Tentacles
def update_settings():
    return settings.update_settings(Session)
コード例 #5
0
ファイル: main.py プロジェクト: yliu1021/CodeHawk
import sys

import CLI
import settings


if __name__ == '__main__':
    try:
        if len(sys.argv) == 1:
            # Update settings
            settings.update_settings()
        elif len(sys.argv) == 2:
            # Run normally with CLI
            CLI.run(sys.argv[1])
        else:
            print('Received many arguments!', file=sys.stderr)
            exit(1)
    except KeyboardInterrupt:
        print()
コード例 #6
0
ファイル: create_tables.py プロジェクト: fpaludi/BooksAPI
    books_df = pd.read_csv("src/data/books.csv")
    print("Saving books...")
    for idx, row in books_df.iterrows():
        book = Books(
            isbn=row["isbn"], title=row["title"], author=row["author"], year=row["year"]
        )
        session.add(book)

    # Commit Changes
    print("Commiting changes...")
    session.commit()


def delete_tables(engine, session):
    print("\nRemoving Tables...\n")
    with contextlib.closing(engine.connect()) as con:
        trans = con.begin()
        for table in reversed(metadata.sorted_tables):
            con.execute(table.delete())
        trans.commit()


if __name__ == "__main__":
    update_settings("default")
    from src.repositories import RepositoryContainer

    engine = RepositoryContainer.engine()
    session = RepositoryContainer.DEFAULT_SESSIONFACTORY()

    create_tables(engine, session)
コード例 #7
0
ファイル: router.py プロジェクト: Aclz/Squid-Tentacles
def update_settings():
    return settings.update_settings(Session)
コード例 #8
0
def setup_function():
    update_settings(default_settings)
コード例 #9
0
def pytest_configure():
    print("INITIAL Test configuration")
    print("Upload Setting object for testing pourposes")
    update_settings(CONF_NAME)