Skip to content

Commit

Permalink
New OSM tags in FS25 schema, SL max upload size update, automatic che…
Browse files Browse the repository at this point in the history
…ck for the updates

* Schema, SL config and actions update.

* README update.

* Check for the latest version.
  • Loading branch information
iwatkot authored Dec 21, 2024
1 parent 4a85861 commit 8ae224d
Show file tree
Hide file tree
Showing 8 changed files with 93 additions and 10 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/issues.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
name: Answer issues

on:
issues:
types:
Expand Down
24 changes: 24 additions & 0 deletions .github/workflows/update_readme.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Update docker tag in README
on:
release:
types: [published]

jobs:
update-readme:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Update README.md
run: |
sed -i "s|docker run -d -p 8501:8501 --name maps4fs iwatkot/maps4fs.*|docker run -d -p 8501:8501 --name maps4fs iwatkot/maps4fs:${{ github.ref_name }}|g" README.md
- name: Commit changes
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git add README.md
git commit -m "Update Docker tag in README to ${{ github.ref_name }}"
git push
2 changes: 1 addition & 1 deletion .streamlit/config.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# .streamlit/config.toml

[server]
maxUploadSize = 500
maxUploadSize = 1000
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ RUN apt-get update && apt-get install -y \

WORKDIR /usr/src/app

COPY .streamlit /usr/src/app/.streamlit
COPY data /usr/src/app/data
COPY docs /usr/src/app/docs
COPY webui /usr/src/app/webui
Expand Down
13 changes: 6 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,16 @@
<p align="center">
<img src="https://github.com/user-attachments/assets/cf8f5752-9c69-4018-bead-290f59ba6976"><br>
🌎 Detailed terrain based on real-world data.<br><br>
<img src="https://github.com/user-attachments/assets/7f238ab4-9ff4-4c6e-ba07-5796be012baa"><br>
🛰️ Realistic background terrain objects with satellite images.<br><br>
<img src="https://github.com/user-attachments/assets/dc40d0bb-c20b-411c-8833-9925d0389452"><br>
🛰️ Realistic background terrain with satellite images.<br><br>
<img src="https://github.com/user-attachments/assets/6e3c0e99-2cce-46ac-82db-5cb60bba7a30"><br>
📐 Perfectly aligned background terrain.<br><br>
<img src="https://github.com/user-attachments/assets/80e5923c-22c7-4dc0-8906-680902511f3a"><br>
🗒️ True-to-life blueprints for fast and precise modding.<br><br>
<img width="480" src="https://github.com/user-attachments/assets/1a8802d2-6a3b-4bfa-af2b-7c09478e199b"><br>
🌾 Field generation with one click.<br><br>
<img width="480" src="https://github.com/user-attachments/assets/4d1fa879-5d60-438b-a84e-16883bcef0ec"><br>
🌽 Automatic farmlands generation based on the fields.<br><br>
<img src="https://github.com/user-attachments/assets/cce45575-c917-4a1b-bdc0-6368e32ccdff"><br>
📏 Almost any possible map sizes.
</p>

📹 A complete step-by-step video tutorial is here!
<a href="https://www.youtube.com/watch?v=Nl_aqXJ5nAk" target="_blank"><img src="https://github.com/user-attachments/assets/4845e030-0e73-47ab-a5a3-430308913060"/></a>
Expand All @@ -88,7 +87,7 @@ So, jump to [Docker version](#option-2-docker-version) to launch the tool with o
### 😎 For advanced users
**Option 2:** Run the Docker version in your browser. Launch the following command in your terminal:
```bash
docker run -d -p 8501:8501 iwatkot/maps4fs
docker run -d -p 8501:8501 --name maps4fs iwatkot/maps4fs
```
And open [http://localhost:8501](http://localhost:8501) in your browser.<br>
If you don't know how to use Docker, navigate to the [Docker version](#option-2-docker-version), it's really simple.<br>
Expand Down Expand Up @@ -151,7 +150,7 @@ You can launch the project with minimalistic UI in your browser using Docker. Fo
1. Install [Docker](https://docs.docker.com/get-docker/) for your OS.
2. Run the following command in your terminal:
```bash
docker run -d -p 8501:8501 iwatkot/maps4fs
docker run -d -p 8501:8501 --name maps4fs iwatkot/maps4fs
```
3. Open your browser and go to [http://localhost:8501](http://localhost:8501).
4. Fill in the required fields and click on the `Generate` button.
Expand Down
4 changes: 2 additions & 2 deletions data/fs25-texture-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
{
"name": "grassDirtPatchy",
"count": 2,
"tags": { "natural": ["wood", "tree_row"] },
"tags": { "natural": ["wood", "tree_row", "forest"] },
"width": 2,
"color": [0, 252, 124]
},
Expand Down Expand Up @@ -199,7 +199,7 @@
{
"name": "sand",
"count": 2,
"tags": { "natural": "water", "waterway": true },
"tags": { "natural": "water", "waterway": true, "landuse": "basin" },
"width": 10,
"color": [255, 20, 20]
}
Expand Down
38 changes: 38 additions & 0 deletions webui/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
import threading
from time import sleep

import requests

import maps4fs as mfs

WORKING_DIRECTORY = os.getcwd()
Expand Down Expand Up @@ -80,3 +82,39 @@ def remove_file() -> None:

logger.debug("Starting a new thread to remove the file %s.", file_path)
threading.Thread(target=remove_file).start()


def get_versions(logger: mfs.Logger) -> tuple[str, str] | None:
"""Get the latest version and the current version of the package.
Returns:
tuple[str, str] | None: The latest version and the current version if the package is not
the latest version, None otherwise
"""
try:
response = requests.get("https://pypi.org/pypi/maps4fs/json")
response.raise_for_status()

latest_version = response.json()["info"]["version"]
logger.debug("Latest version on PyPI: %s. Length: %s", latest_version, len(latest_version))

current_version = get_package_version("shapely", logger)
logger.debug("Current version: %s. Length: %s", current_version, len(current_version))

return latest_version, current_version
except Exception as e:
logger.error("An error occurred while checking the package version: %s", e)
return


def get_package_version(package_name: str, logger: mfs.Logger) -> str:
"""Get the package version.
Returns:
str: The package version.
"""
response = os.popen(f"pip list | grep {package_name}").read()
logger.debug("Grepped response: %s", response)
cleared_response = response.replace(" ", "")
logger.debug("Cleared response: %s", cleared_response)
return response.replace(package_name, "").strip()
19 changes: 19 additions & 0 deletions webui/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,25 @@ def add_left_widgets(self) -> None:
self.logger.debug("Adding widgets to the left column...")

st.title(Messages.TITLE)
versions = config.get_versions(self.logger)
try:
if versions:
latest_version, current_version = versions
if current_version != latest_version:
st.warning(
f"🆕 New version is available! \n"
f"Your current version: `{current_version}`, "
f"latest version: `{latest_version}`. \n"
"Use the following commands to upgrade: \n"
"```bash \n"
"docker stop maps4fs \n"
"docker run -d -p 8501:8501 --name maps4fs "
f"iwatkot/maps4fs:{latest_version} \n"
"```"
)
except Exception as e:
self.logger.error("An error occurred while checking the package version: %s", e)

st.write(Messages.MAIN_PAGE_DESCRIPTION)
if self.community:
st.info(Messages.MAIN_PAGE_COMMUNITY_WARNING)
Expand Down

0 comments on commit 8ae224d

Please sign in to comment.