示例#1
0
def configure_cef(debug):
    from webview.platforms.cef import (  # pylint: disable=import-outside-toplevel
        settings, )

    cache = util.get_storage_dir() / "cef_cache"
    settings.update({
        "cache_path": str(cache),
        "context_menu": {
            "enabled": debug,
            "devtools": True
        }
    })
    if not cache.exists():
        cache.mkdir(parents=True, exist_ok=True)
示例#2
0
def create_backup(name: str = ""):
    if not name:
        name = f'BCML_Backup_{datetime.datetime.now().strftime("%Y-%m-%d")}'
    else:
        name = re.sub(r"(?u)[^-\w.]", "", name.strip().replace(" ", "_"))
    num_mods = len([d for d in util.get_modpack_dir().glob("*") if d.is_dir()])
    output = util.get_storage_dir() / "backups" / f"{name}---{num_mods - 1}.7z"
    output.parent.mkdir(parents=True, exist_ok=True)
    print(f"Saving backup {name}...")
    x_args = [ZPATH, "a", str(output), f'{str(util.get_modpack_dir() / "*")}']
    if system() == "Windows":
        subprocess.run(
            x_args,
            stdout=subprocess.PIPE,
            stderr=subprocess.PIPE,
            creationflags=util.CREATE_NO_WINDOW,
            check=True,
        )
    else:
        subprocess.run(x_args,
                       stdout=subprocess.PIPE,
                       stderr=subprocess.PIPE,
                       check=True)
    print(f'Backup "{name}" created')
示例#3
0
def get_backups() -> List[Path]:
    return list((util.get_storage_dir() / "backups").glob("*.7z"))