diff --git a/.dockerignore b/.dockerignore deleted file mode 100644 index f4d5db4..0000000 --- a/.dockerignore +++ /dev/null @@ -1,5 +0,0 @@ -profiles/ -results/ -__pycache__/ -.venv/ -tests/ diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 31546f0..0000000 --- a/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -.venv/ -__pycache__/ -results/ -profiles/ -simc/ diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 1cfb745..0000000 --- a/Dockerfile +++ /dev/null @@ -1,21 +0,0 @@ -FROM simulationcraftorg/simc:latest - -ENV LANG=de_DE.UTF-8 - -RUN apk add --no-cache python3 py3-pip git - -ENV VIRTUAL_ENV=/opt/venv -RUN python3 -m venv $VIRTUAL_ENV -ENV PATH="$VIRTUAL_ENV/bin:$PATH" - -# Install dependencies: -COPY requirements.txt . -RUN pip install -r requirements.txt - -COPY . . - -EXPOSE 8000 - -ENTRYPOINT [] - -CMD ["fastapi", "run", "main.py", "--port", "8000"] diff --git a/README.md b/README.md deleted file mode 100644 index a40ddc7..0000000 --- a/README.md +++ /dev/null @@ -1,18 +0,0 @@ -# SIM Free - -## Description - -### Installation -```bash -git clone https://github.com/alexohneander/sim_free -cd sim_free - -python3 -m venv .venv -source .venv/bin/activate -pip install -r requirements.txt -``` - -### Run -```bash -fastapi run main.py -``` diff --git a/main.py b/main.py deleted file mode 100644 index 4c48a44..0000000 --- a/main.py +++ /dev/null @@ -1,85 +0,0 @@ -import os -import logging -import uuid -import time -import functools - -from pathlib import Path -from simcrunner import Simc, JsonExport, Arguments, Profile - -from typing import Union, Annotated -from fastapi import FastAPI, Form -from fastapi.staticfiles import StaticFiles -from pydantic import BaseModel -from starlette.responses import FileResponse, HTMLResponse -from simcrunner.simc import HtmlExport - -# SIMC Settings -logging.basicConfig(level=logging.INFO) -# simc_path = os.path.join('tests', 'simc') -simc_path = "./" - -app = FastAPI() -app.mount("/static", StaticFiles(directory="templates/static"), name="static") - -# ROUTES -@app.get("/") -def read_root(): - index_path = os.path.join('templates', 'index.html') - return FileResponse(index_path) - -@app.post("/sim/current_gear") -def simulate_current_gear(simcprofile: Annotated[str, Form()]): - - profile_path = create_sim_arguments(simcprofile) - export_path = create_html_export() - html_export = HtmlExport(export_path) - - profile = Profile(profile_path) - args = Arguments(profile, iterations=1000) - - runner = Simc(simc_path=simc_path) - (runner - .add_args(args) - .add_args('target_error=0.05', threads=4) - .add_args(html_export) - .run()) - - # response = FileResponse(export_path) - # remove_temp_files(profile_path, export_path) - - return FileResponse(export_path) - -# HELPER Functions -def create_profile(profile_path: str, profile_data: str): - with open(profile_path, 'w') as file: - # Write content to the file - file.write(profile_data) - -def create_html_export(): - rand_uuid = uuid.uuid4() - export_path = os.path.join('results', str(rand_uuid)+'.html') - - return export_path - -def create_sim_arguments(profile_data: str): - rand_uuid = uuid.uuid4() - profile_path = os.path.join('profiles', str(rand_uuid)+'.simc') - - create_profile(profile_path, profile_data) - - return profile_path - -def remove_temp_files(profile_path: str, export_path: str): - time.sleep(1) - os.remove(export_path) - os.remove(profile_path) - -@functools.lru_cache(maxsize=2) -def read_file_with_lru_cache(file_path): - # Read the file content - with open(file_path, 'r', encoding="utf-8") as file: - file_content = file.read() - print(f"Reading from file: {file_path}") - - return file_content diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 0abe759..0000000 --- a/requirements.txt +++ /dev/null @@ -1,2 +0,0 @@ -fastapi[standard]==0.115.0 -git+https://github.com/simcminmax/simcrunner.git diff --git a/templates/index.html b/templates/index.html deleted file mode 100644 index dcdef4c..0000000 --- a/templates/index.html +++ /dev/null @@ -1,223 +0,0 @@ - - - - - - SIM-Free - - - - - - - - - - - -
-
-
- -

Simulate form

-

- Copy/paste the text from the SimulationCraft addon. -

-
- -
-
-

Sim Data

-
-
-
-
- - -
-
-
- -
- -
-
-
-
-
- - -
- - - - diff --git a/templates/static/color-modes.js b/templates/static/color-modes.js deleted file mode 100644 index 059a140..0000000 --- a/templates/static/color-modes.js +++ /dev/null @@ -1,92 +0,0 @@ -/*! - * Color mode toggler for Bootstrap's docs (https://getbootstrap.com/) - * Copyright 2011-2024 The Bootstrap Authors - * Licensed under the Creative Commons Attribution 3.0 Unported License. - */ - -(() => { - "use strict"; - - const getStoredTheme = () => localStorage.getItem("theme"); - const setStoredTheme = (theme) => localStorage.setItem("theme", theme); - - const getPreferredTheme = () => { - const storedTheme = getStoredTheme(); - if (storedTheme) { - return storedTheme; - } - - return window.matchMedia("(prefers-color-scheme: dark)").matches - ? "dark" - : "light"; - }; - - const setTheme = (theme) => { - if (theme === "auto") { - document.documentElement.setAttribute( - "data-bs-theme", - window.matchMedia("(prefers-color-scheme: dark)").matches - ? "dark" - : "light", - ); - } else { - document.documentElement.setAttribute("data-bs-theme", theme); - } - }; - - setTheme(getPreferredTheme()); - - const showActiveTheme = (theme, focus = false) => { - const themeSwitcher = document.querySelector("#bd-theme"); - - if (!themeSwitcher) { - return; - } - - const themeSwitcherText = document.querySelector("#bd-theme-text"); - const activeThemeIcon = document.querySelector(".theme-icon-active use"); - const btnToActive = document.querySelector( - `[data-bs-theme-value="${theme}"]`, - ); - const svgOfActiveBtn = btnToActive - .querySelector("svg use") - .getAttribute("href"); - - document.querySelectorAll("[data-bs-theme-value]").forEach((element) => { - element.classList.remove("active"); - element.setAttribute("aria-pressed", "false"); - }); - - btnToActive.classList.add("active"); - btnToActive.setAttribute("aria-pressed", "true"); - activeThemeIcon.setAttribute("href", svgOfActiveBtn); - const themeSwitcherLabel = `${themeSwitcherText.textContent} (${btnToActive.dataset.bsThemeValue})`; - themeSwitcher.setAttribute("aria-label", themeSwitcherLabel); - - if (focus) { - themeSwitcher.focus(); - } - }; - - window - .matchMedia("(prefers-color-scheme: dark)") - .addEventListener("change", () => { - const storedTheme = getStoredTheme(); - if (storedTheme !== "light" && storedTheme !== "dark") { - setTheme(getPreferredTheme()); - } - }); - - window.addEventListener("DOMContentLoaded", () => { - showActiveTheme(getPreferredTheme()); - - document.querySelectorAll("[data-bs-theme-value]").forEach((toggle) => { - toggle.addEventListener("click", () => { - const theme = toggle.getAttribute("data-bs-theme-value"); - setStoredTheme(theme); - setTheme(theme); - showActiveTheme(theme, true); - }); - }); - }); -})(); diff --git a/templates/static/main.js b/templates/static/main.js deleted file mode 100644 index fc5b111..0000000 --- a/templates/static/main.js +++ /dev/null @@ -1,3 +0,0 @@ -// -// Place any custom JS here -// diff --git a/templates/static/styles.css b/templates/static/styles.css deleted file mode 100644 index 7980e26..0000000 --- a/templates/static/styles.css +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Custom CSS - */ - -:root { - --bs-body-bg: var(--bs-gray-100); -} - -.bd-placeholder-img { - font-size: 1.125rem; - text-anchor: middle; - -webkit-user-select: none; - -moz-user-select: none; - user-select: none; -} - -@media (min-width: 768px) { - .bd-placeholder-img-lg { - font-size: 3.5rem; - } -} - -.b-example-divider { - width: 100%; - height: 3rem; - background-color: rgba(0, 0, 0, 0.1); - border: solid rgba(0, 0, 0, 0.15); - border-width: 1px 0; - box-shadow: - inset 0 0.5em 1.5em rgba(0, 0, 0, 0.1), - inset 0 0.125em 0.5em rgba(0, 0, 0, 0.15); -} - -.b-example-vr { - flex-shrink: 0; - width: 1.5rem; - height: 100vh; -} - -.bi { - vertical-align: -0.125em; - fill: currentColor; -} - -.nav-scroller { - position: relative; - z-index: 2; - height: 2.75rem; - overflow-y: hidden; -} - -.nav-scroller .nav { - display: flex; - flex-wrap: nowrap; - padding-bottom: 1rem; - margin-top: -1px; - overflow-x: auto; - text-align: center; - white-space: nowrap; - -webkit-overflow-scrolling: touch; -} - -.btn-bd-primary { - --bd-violet-bg: #712cf9; - --bd-violet-rgb: 112.520718, 44.062154, 249.437846; - - --bs-btn-font-weight: 600; - --bs-btn-color: var(--bs-white); - --bs-btn-bg: var(--bd-violet-bg); - --bs-btn-border-color: var(--bd-violet-bg); - --bs-btn-hover-color: var(--bs-white); - --bs-btn-hover-bg: #6528e0; - --bs-btn-hover-border-color: #6528e0; - --bs-btn-focus-shadow-rgb: var(--bd-violet-rgb); - --bs-btn-active-color: var(--bs-btn-hover-color); - --bs-btn-active-bg: #5a23c8; - --bs-btn-active-border-color: #5a23c8; -} - -.bd-mode-toggle { - z-index: 1500; -} - -.bd-mode-toggle .dropdown-menu .active .bi { - display: block !important; -} diff --git a/templates/static/warcraft-icon-22.png b/templates/static/warcraft-icon-22.png deleted file mode 100644 index 5682004..0000000 Binary files a/templates/static/warcraft-icon-22.png and /dev/null differ