Merge branch 'dev/updater' of github.com:FAUSheppy/homelab_gamevault into dev/updater

This commit is contained in:
Yannik Schmidt
2025-06-07 13:52:23 +02:00
5 changed files with 60 additions and 19 deletions

37
.github/workflows/server.yaml vendored Normal file
View File

@@ -0,0 +1,37 @@
name: ci
on:
push:
branches:
- "master"
jobs:
docker:
runs-on: ubuntu-latest
environment:
name: prod
steps:
-
name: Checkout
uses: actions/checkout@v3
-
name: Set up QEMU
uses: docker/setup-qemu-action@v2
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
-
name: Login to Docker Registry
uses: docker/login-action@v2
with:
registry: ${{ secrets.REGISTRY }}
username: ${{ secrets.REGISTRY_USER }}
password: ${{ secrets.REGISTRY_PASS }}
-
name: Build and push async-icinga image
uses: docker/build-push-action@v3
with:
context: server
platforms: linux/amd64
push: true
tags: "${{ secrets.REGISTRY }}/atlantishq/gamevault-server:latest"

View File

@@ -359,10 +359,11 @@ if __name__ == "__main__":
elif backend_type == "HTTP/HTTPS": elif backend_type == "HTTP/HTTPS":
server = config_loaded["Server/Path:"] server = config_loaded["Server/Path:"]
remote_root_dir = None remote_root_dir = None
if not server.startswith("http://") or "https://": if not any(server.startswith(s) for s in ["http://", "https://"]):
server = "http://" + server server = "http://" + server
if not ":" in server.split("://")[1]: #if not ":" in server.split("://")[1]:
server = server + ":5000" # server = server + ":5000"
print(server)
elif backend_type == "Local Filesystem": elif backend_type == "Local Filesystem":
remote_root_dir = config_loaded["Server/Path:"] remote_root_dir = config_loaded["Server/Path:"]
server = None server = None
@@ -374,7 +375,8 @@ if __name__ == "__main__":
# add db backend # # add db backend #
if backend_type == "HTTP/HTTPS": if backend_type == "HTTP/HTTPS":
db = data_backend.HTTP(None, None, install_dir, remote_root_dir="./", server=server, progress_bar_wrapper=pgw, db = data_backend.HTTP(user, password, install_dir,
remote_root_dir="./", server=server, progress_bar_wrapper=pgw,
tkinter_root=app, hide_above_age=hide_above_age) tkinter_root=app, hide_above_age=hide_above_age)
elif backend_type == "FTP/FTPS": elif backend_type == "FTP/FTPS":
db = data_backend.FTP(user, password, install_dir, server=server, db = data_backend.FTP(user, password, install_dir, server=server,

View File

@@ -20,6 +20,7 @@ class DataBackend:
self.user = user self.user = user
self.password = password self.password = password
self.auth = (self.user, self.password)
self.remote_root_dir = remote_root_dir self.remote_root_dir = remote_root_dir
self.server = server self.server = server
self.install_dir = install_dir self.install_dir = install_dir
@@ -92,6 +93,7 @@ class LocalFS(DataBackend):
meta_info_list.append(software.Software(meta_file, self, self.progress_bar_wrapper)) meta_info_list.append(software.Software(meta_file, self, self.progress_bar_wrapper))
return list(filter(lambda x: not x.invalid, meta_info_list)) return list(filter(lambda x: not x.invalid, meta_info_list))
class HTTP(DataBackend): class HTTP(DataBackend):
paths_listed = {} paths_listed = {}
@@ -165,7 +167,7 @@ class HTTP(DataBackend):
# this is with streaming # this is with streaming
chunk_size = 1024 * 1024 * 5 # 5MB chunk_size = 1024 * 1024 * 5 # 5MB
r = requests.get(self._get_url(), params={"path": path, "as_string": True}, stream=True) r = requests.get(self._get_url(), params={"path": path, "as_string": True}, stream=True, auth=(self.user, self.password))
r.raise_for_status() r.raise_for_status()
if path.endswith(".txt"): if path.endswith(".txt"):
@@ -197,7 +199,7 @@ class HTTP(DataBackend):
else: else:
print("Async Requested for:", local_file) print("Async Requested for:", local_file)
statekeeper.add_to_download_queue(self._get_url(), path) statekeeper.add_to_download_queue(self._get_url(), path, auth=(self.user, self.password))
return local_file return local_file
elif return_content: elif return_content:
@@ -220,7 +222,7 @@ class HTTP(DataBackend):
paths = self.paths_listed[fullpath] paths = self.paths_listed[fullpath]
else: else:
r = requests.get(self._get_url(), params={ "path" : path }) r = requests.get(self._get_url(), params={ "path" : path }, auth=(self.user, self.password))
r.raise_for_status() r.raise_for_status()
#print(r, r.status_code, r.content) #print(r, r.status_code, r.content)
paths = r.json()["contents"] paths = r.json()["contents"]
@@ -273,4 +275,4 @@ class HTTP(DataBackend):
print("Age limit set to", self.hide_above_age, "games have", [x.age_limit for x in software_list]) print("Age limit set to", self.hide_above_age, "games have", [x.age_limit for x in software_list])
results_with_age = list(filter(lambda x: x.age_limit <= self.hide_above_age, results_valid)) results_with_age = list(filter(lambda x: x.age_limit <= self.hide_above_age, results_valid))
return results_with_age return results_with_age

View File

@@ -86,7 +86,7 @@ class ProgressBarApp:
return return
try: try:
percent_filled = statekeeper.get_percent_filled(path) percent_filled = statekeeper.get_percent_filled(path, self.data_backend.auth)
except OSError as e: except OSError as e:
fail_count += 1 fail_count += 1
if fail_count > 6: if fail_count > 6:
@@ -143,4 +143,4 @@ class ProgressBarApp:
def on_close(self): def on_close(self):
self.running = False self.running = False
self.root.destroy() self.root.destroy()

View File

@@ -8,10 +8,10 @@ from sqlalchemy import or_, and_
def _bytes_to_mb(size): def _bytes_to_mb(size):
return size / (1024*1024) return size / (1024*1024)
def add_to_download_queue(url, path): def add_to_download_queue(url, path, auth):
'''The download is added to the global queue and downloaded eventually''' '''The download is added to the global queue and downloaded eventually'''
#_download(url, path) #_download(url, path)
thread = threading.Thread(target=_download, args=(url, path)) thread = threading.Thread(target=_download, args=(url, path, auth))
thread.start() thread.start()
def add_to_task_queue(task): def add_to_task_queue(task):
@@ -21,9 +21,9 @@ def add_to_task_queue(task):
thread.start() thread.start()
#task() #task()
def _download(url, path): def _download(url, path, auth):
response = requests.get(url + "?path=" + path, stream=True) response = requests.get(url + "?path=" + path, stream=True, auth=auth)
# Check if the request was successful # Check if the request was successful
if response.status_code == 200: if response.status_code == 200:
@@ -90,7 +90,7 @@ def log_end_download(path, type="download"):
db.close_session() db.close_session()
def get_download_size(path): def get_download_size(path, auth):
session = db.session() session = db.session()
obj = session.query(Download).filter(Download.path==path).first() obj = session.query(Download).filter(Download.path==path).first()
@@ -103,7 +103,7 @@ def get_download_size(path):
return obj.size return obj.size
# query size # # query size #
r = requests.get(obj.url, params={"path": path, "info": 1}) r = requests.get(obj.url, params={"path": path, "info": 1}, auth=auth)
r.raise_for_status() r.raise_for_status()
size = r.json()["size"] size = r.json()["size"]
@@ -114,7 +114,7 @@ def get_download_size(path):
return size return size
def get_percent_filled(path): def get_percent_filled(path, auth):
session = db.session() session = db.session()
obj = session.query(Download).filter(Download.path==path, Download.finished==False).first() obj = session.query(Download).filter(Download.path==path, Download.finished==False).first()
@@ -129,7 +129,7 @@ def get_percent_filled(path):
return 100 # means its finished return 100 # means its finished
size = _bytes_to_mb(os.stat(obj.local_path).st_size) size = _bytes_to_mb(os.stat(obj.local_path).st_size)
total_size = get_download_size(obj.path) total_size = get_download_size(obj.path, auth)
session.close() session.close()
if total_size == 0: if total_size == 0:
@@ -148,4 +148,4 @@ def get_download(path=None):
downloads = session.query(Download).filter(Download.finished==False).all() downloads = session.query(Download).filter(Download.finished==False).all()
session.close() session.close()
return downloads return downloads