Compare commits

...

7 Commits

Author SHA1 Message Date
Amazed 6802b12abb added more logs in case of error 2021-12-23 22:59:39 +01:00
Amazed ba70cdac89 Added .ico... 2021-12-23 17:41:23 +01:00
Amazed 324de3b126 Changed .png to .ico 2021-12-23 17:41:04 +01:00
Amazed 4e258543c2 Added icon. Fix #2 2021-12-23 17:33:44 +01:00
Amazed 6fe13463fa Fix #1 2021-12-23 15:22:10 +01:00
Amazed 30f838008c added gitignore 2021-12-23 01:56:38 +01:00
Amazed f6b7fbc8bf increase polling time to 1 min 2021-12-23 01:56:12 +01:00
6 changed files with 25 additions and 5 deletions

6
.gitignore vendored Normal file
View File

@ -0,0 +1,6 @@
build/
dist/
venv/
.idea/
__pycache__/
*.pyc

BIN
icon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 90 KiB

15
main.py
View File

@ -6,7 +6,7 @@ import socket
import zlib import zlib
import sys import sys
from PySide6.QtCore import QThread, QTimer, Signal from PySide6.QtCore import QThread, QTimer, Signal
from PySide6.QtWidgets import QApplication, QMainWindow, QFileDialog from PySide6.QtWidgets import QApplication, QMainWindow, QFileDialog, QMessageBox
from lib.enumresponse import EnumResponse from lib.enumresponse import EnumResponse
from lib.giantsenumresponseparser import GiantsEnumResponseParser from lib.giantsenumresponseparser import GiantsEnumResponseParser
from lib.packet import Packet from lib.packet import Packet
@ -18,7 +18,7 @@ import yaml
installed_maps = {} installed_maps = {}
API_BASE_URL = "https://gckmaps.hipstercat.fr" API_BASE_URL = "https://gckmaps.hipstercat.fr"
SLEEP_TIME = 20 * 1000 SLEEP_TIME = 1 * 60 * 1000
CONFIG = {} CONFIG = {}
@ -132,6 +132,7 @@ def read_configuration():
global CONFIG global CONFIG
if not os.path.exists(config_file): if not os.path.exists(config_file):
# create it # create it
QMessageBox.information(None, "GMD - Giants Maps Downloader", "Welcome to GMD!\n\nThis tool runs in the background to automatically download and upload hosted maps. For this to work, GMD needs to know where maps must be installed.\n\nPlease select where Giants.exe is after clicking OK.", QMessageBox.Ok)
giants_exe_path, _filename = QFileDialog.getOpenFileName(None, caption="Open Giants.exe", filter="Giants.exe") giants_exe_path, _filename = QFileDialog.getOpenFileName(None, caption="Open Giants.exe", filter="Giants.exe")
if not giants_exe_path: if not giants_exe_path:
sys.exit(1) sys.exit(1)
@ -207,7 +208,7 @@ class MapsBackground(QThread):
self.log(f"Error while fetching map info: {e}") self.log(f"Error while fetching map info: {e}")
return return
if req.status_code != 200: if req.status_code != 200:
self.log(f"Could not download map from server, got status_code {req.status_code}") self.log(f"Could not download map from server, got status_code {req.status_code}: {req.text}")
return return
j = req.json() j = req.json()
blob_location = j["blob_location"] blob_location = j["blob_location"]
@ -249,10 +250,16 @@ class MapsBackground(QThread):
map_data = {"name": map_name, "b64_data": b64_data} map_data = {"name": map_name, "b64_data": b64_data}
try: try:
req = requests.post(f"{API_BASE_URL}/maps", json=map_data) req = requests.post(f"{API_BASE_URL}/maps", json=map_data)
except Exception as e:
self.log(f"There was an error while uploading map: {e} {req.text}")
return
try:
req.raise_for_status() req.raise_for_status()
except Exception as e: except Exception as e:
self.log(f"There was an error while uploading map: {e}") self.log(f"There was an error while uploading map: {e} {req.text}")
return return
self.log("Upload successful") self.log("Upload successful")
def all_servers_download(self) -> None: def all_servers_download(self) -> None:

View File

@ -37,4 +37,4 @@ exe = EXE(pyz,
disable_windowed_traceback=False, disable_windowed_traceback=False,
target_arch=None, target_arch=None,
codesign_identity=None, codesign_identity=None,
entitlements_file=None ) entitlements_file=None , icon='icon.ico')

View File

@ -24,6 +24,9 @@ class Ui_MainWindow(object):
if not MainWindow.objectName(): if not MainWindow.objectName():
MainWindow.setObjectName(u"MainWindow") MainWindow.setObjectName(u"MainWindow")
MainWindow.resize(449, 230) MainWindow.resize(449, 230)
icon = QIcon()
icon.addFile(u"icon.png", QSize(), QIcon.Normal, QIcon.Off)
MainWindow.setWindowIcon(icon)
self.centralwidget = QWidget(MainWindow) self.centralwidget = QWidget(MainWindow)
self.centralwidget.setObjectName(u"centralwidget") self.centralwidget.setObjectName(u"centralwidget")
self.centralwidget.setEnabled(True) self.centralwidget.setEnabled(True)

View File

@ -13,6 +13,10 @@
<property name="windowTitle"> <property name="windowTitle">
<string>GMD - Giants Maps Downloader</string> <string>GMD - Giants Maps Downloader</string>
</property> </property>
<property name="windowIcon">
<iconset>
<normaloff>icon.png</normaloff>icon.png</iconset>
</property>
<widget class="QWidget" name="centralwidget"> <widget class="QWidget" name="centralwidget">
<property name="enabled"> <property name="enabled">
<bool>true</bool> <bool>true</bool>