Skip to content

Commit

Permalink
improve support for arm, fix minor bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
mjishnu committed Jun 19, 2024
1 parent 3619afc commit fa6fb8c
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 11 deletions.
10 changes: 7 additions & 3 deletions app/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,17 @@

from modules.gui import Ui_MainProgram
from modules.url_gen import url_generator
from utls import Worker
from utls import Worker, default_logger

script_dir = os.path.dirname(os.path.abspath(__file__))
clr.AddReference(rf"{script_dir}\data\System.Management.Automation.dll")


class internal_func(Ui_MainProgram):
def __init__(self):
super().__init__()
self.logger = default_logger("Downloader")

def error_msg(self, text, msg_details, title="Error", critical=False):
msg = QMessageBox()
msg.setWindowTitle(title)
Expand Down Expand Up @@ -246,7 +250,7 @@ def download_install_thread(data, progress_current, progress_main):
if not os.path.exists(dwnpath):
os.makedirs(dwnpath)
path_lst = {}
d = Pypdl(allow_reuse=True)
d = Pypdl(allow_reuse=True, logger=self.logger)
for f_name in final_data:
# Define the remote file to retrieve
remote_url = main_dict[f_name] # {f_name:url}
Expand Down Expand Up @@ -277,7 +281,7 @@ def new_url_gen():
display=False,
overwrite=False,
)
print(remote_url)

while not d.completed:
download_percentage = int(d.progress)
progress_current.emit(download_percentage)
Expand Down
14 changes: 8 additions & 6 deletions app/modules/url_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,19 @@ def check(Event):


def os_arc():
if platform.machine().endswith("64"):
machine = platform.machine().lower()

if machine.endswith("arm64"):
return "arm64"
if machine.endswith("64"):
return "x64"
if platform.machine().endswith("32") or platform.machine().endswith("86"):
if machine.endswith("32") or machine.endswith("86"):
return "x86"
################################
return "arm" # not sure wheather work or not, needs testing
else:
return "arm"


# cleans My.name.1.2 -> myname


def clean_name(badname):
name = "".join(
[(i if (64 < ord(i) < 91 or 96 < ord(i) < 123) else "") for i in badname]
Expand Down
17 changes: 15 additions & 2 deletions app/utls.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,29 @@
import logging
import os
import sys
import traceback
import webbrowser

from PyQt6 import QtCore, QtWidgets
from PyQt6.QtCore import QObject, QRunnable, pyqtSignal, pyqtSlot
from PyQt6.QtGui import QIcon, QPixmap, QFont
from PyQt6.QtGui import QFont, QIcon, QPixmap
from PyQt6.QtWidgets import QDialog
import os

curr_dir = os.path.dirname(os.path.abspath(__file__))


def default_logger(name: str) -> logging.Logger:
"""Creates a default debugging logger."""
logger = logging.getLogger(name)
handler = logging.FileHandler(f"{curr_dir}/log.txt", mode="a", delay=True)
custom_format = (
f"[{name} logs] \n[%(asctime)s]\n\n %(levelname)s: %(message)s\n{82*"-"}\n"
)
handler.setFormatter(logging.Formatter(custom_format, datefmt="%d-%m-%Y %H:%M:%S"))
logger.addHandler(handler)
return logger


class UrlBox(QDialog):
closed = QtCore.pyqtSignal(object)

Expand Down

0 comments on commit fa6fb8c

Please sign in to comment.