Ejemplo n.º 1
0
def upgrade(dependencies: List[Dependency]) -> None:
    """
    Upgrade one or more out-of-date pip packages.
    """
    venv.activate()
    sys_calls.run(["pip", "install", "--upgrade"] + dependencies)
    _freeze_requirements()
Ejemplo n.º 2
0
def remove(dependencies: List[Dependency]) -> None:
    """
    Remove one or more pip packages.
    """
    venv.activate()
    sys_calls.run(["pip-autoremove"] + dependencies + ['-y'])
    _freeze_requirements()
Ejemplo n.º 3
0
def check_types() -> None:
    """
    Calls MyPy to check for type errors.
    """
    venv.activate()
    sys_calls.run(["mypy", "--strict-optional", "--ignore-missing-imports",
                   "--package", "scripts"])
Ejemplo n.º 4
0
def add(dependencies: List[Dependency]) -> None:
    """
    Add one or more pip packages.
    """
    venv.activate()
    sys_calls.run(["pip", "install"] + dependencies)
    _freeze_requirements()
Ejemplo n.º 5
0
def install() -> None:
    """
    Downloads & installs all dependencies for the backend.
    """
    venv.create()
    venv.activate()
    sys_calls.run(["pip", "install", "--upgrade", 'pip', 'setuptools'])
    sys_calls.run(["pip", "install", "-r", "requirements.txt"])
Ejemplo n.º 6
0
def run() -> None:
    """
    Start backend server normally.
    """
    venv.activate()
    os.environ['FLASK_APP'] = 'backend/src/app.py'
    try:
        sys_calls.run(["flask", "run"])
    except KeyboardInterrupt:
        pass
Ejemplo n.º 7
0
def test() -> None:
    """
    Run unit tests.
    """
    venv.activate()
    if sys_calls.is_windows_environment():
        py = 'python'
    else:
        py = 'python3'
    sys_calls.run([py, '-m', 'unittest', 'discover', 'tests'], cwd='backend/')
Ejemplo n.º 8
0
def run_detached() -> None:
    """
    Start backend server in detached mode, meaning it will not output anything.

    Must later kill process.
    """
    venv.activate()
    os.environ['FLASK_APP'] = 'backend/src/app.py'
    sys_calls.run_detached(["flask", "run"])
    print(
        "Backend server started at localhost:5000. Remember to stop it after.")
Ejemplo n.º 9
0
def catchup() -> None:
    """
    Check server for changes, and install new dependencies if necessary.
    """
    if not git.is_clean_local():
        raise SystemExit('Must first commit your changes before catching up.')
    old_hash = git.get_file_hash('requirements.txt')
    git.fast_forward('origin', git.get_current_branch())
    new_hash = git.get_file_hash('requirements.txt')
    if old_hash != new_hash:
        venv.activate()
        sys_calls.run(["pip", "install", "-r", "requirements.txt"])
Ejemplo n.º 10
0
def dependency_tree() -> None:
    """
    Visualize which dependencies depend upon which.
    """
    venv.activate()
    sys_calls.run(["pipdeptree"])
Ejemplo n.º 11
0
def list_outdated() -> None:
    """
    List pip packages that should be updated.
    """
    venv.activate()
    sys_calls.run(["pip", "list", "--outdated", "--format=columns"])