-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathscripts.py
More file actions
72 lines (51 loc) · 1.72 KB
/
scripts.py
File metadata and controls
72 lines (51 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import os
import subprocess
import sys
from pathlib import Path
from subprocess import CalledProcessError, check_call
import click
from loguru import logger
from src.run_scripts import run_fbref, run_fpl_official, run_stats_combiner
THIS_DIRECTORY = Path(__file__).parent
files = ["tests/", "src/", "scripts.py"]
def _call(cmd, options=[]) -> None:
command = cmd.split(" ") + options
logger.info(">>>>>>>> {}".format(" ".join(command)))
try:
check_call(command)
except CalledProcessError as ex:
print(f"[FAIL] {ex}")
logger.info("<<<<<<<<<< ")
sys.exit(2)
logger.info("<<<<<<<<<< ")
def lint() -> None:
_call("black --check --diff --color", files)
def test() -> None:
_call("pytest --disable-pytest-warnings -v -s")
@click.command()
def migrations():
logger.info("Running migrations...")
os.chdir(THIS_DIRECTORY / "db")
subprocess.run(
["poetry", "run", "alembic", "upgrade", "head"],
check=True,
universal_newlines=True,
)
logger.info("Completed successfully")
@click.command()
@click.option("--debug/--no-debug", default=False, help="Prints debug info")
def fbref_scraper(debug: bool):
logger.info("Starting scraping for Fbref...")
run_fbref(debug=debug)
@click.command()
@click.option("--debug/--no-debug", default=False, help="Prints debug info")
def fpl_data_fetcher(debug: bool):
logger.info("Starting scraping for FPL Official Data...")
run_fpl_official(debug=debug)
@click.command()
def stats_combiner():
logger.info("Starting data processing and combining Fbref and official FPL stats...")
run_stats_combiner()
@click.command()
def test_script():
subprocess.run(["echo", "Subprocess works --->"])